fn corrected_course_path(path: &str) -> u32 {
    let commands = parse(path);
    let mut horizontal = 0;
    let mut depth = 0;
    let mut aim = 0;

    for command in commands {
        match command.direction.as_str() {
            "forward" => {
                horizontal += command.position;
                depth += aim * command.position
            },
            "down" => aim += command.position,
            "up" => aim -= command.position,
            _ => ()
        }
    }

    return horizontal * depth;
}
// Part Two: Calculates the horizontal position and depth, using new interpretation of the commands
Part Two: Calculates the horizontal position and depth, using new interpretation of the commands
Part Two : Calculates the horizontal position and depth using new interpretation of the commands
fn corrected_course_path(path: &str) -> u32 {
    let commands = parse(path);
    let mut horizontal = 0;
    let mut depth = 0;
    let mut aim = 0;
    for command in commands {
        match command.direction.as_str() {
            "forward" => {
                horizontal += command.position;
                depth += aim * command.position
            },
            "down" => aim += command.position,
            "up" => aim -= command.position,
            _ => ()
        }
    }
    return horizontal * depth;
}
fn corrected_course_path ( path : & str ) -> u32 { let commands = parse ( path ) ; let mut horizontal = 0 ; let mut depth = 0 ; let mut aim = 0 ; for command in commands { match command . direction . as_str ( ) { " " => { horizontal += command . position ; depth += aim * command . position } , " " => aim += command . position , " " => aim -= command . position , _ => ( ) } } return horizontal * depth ; }
Part Two: Calculates the horizontal position and depth, using new interpretation of the commands
Part Two : Calculates the horizontal position and depth using new interpretation of the commands
path
&str