-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56947e2
commit cd99c45
Showing
4 changed files
with
55 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,5 @@ go.work | |
|
||
# Binaries & executables | ||
**/aoc202* | ||
2021/2021 | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
package main | ||
|
||
import "core:fmt" | ||
import "core:strconv" | ||
import "utils" | ||
|
||
main :: proc() { | ||
lines := utils.read_lines("./inputs/01p1.txt") | ||
depth_increase_count := get_depth_increase_count(lines) | ||
|
||
fmt.printfln("Depth increasd %v times.", depth_increase_count) | ||
} | ||
|
||
get_depth_increase_count :: proc(input: [dynamic]string) -> int { | ||
depth_increase_count := 0 | ||
prev_depth := strconv.atoi(input[0]) | ||
|
||
for line in input { | ||
depth := strconv.atoi(line) | ||
|
||
if prev_depth < depth { | ||
depth_increase_count += 1 | ||
} | ||
prev_depth = depth | ||
} | ||
return depth_increase_count | ||
} | ||
package main | ||
|
||
import "core:fmt" | ||
import "core:strconv" | ||
import "utils" | ||
|
||
D01P1 :: proc() { | ||
lines := utils.read_lines("./inputs/01p1.txt") | ||
depth_increase_count := get_depth_increase_count(lines) | ||
|
||
fmt.printfln("Depth increasd %v times.", depth_increase_count) | ||
} | ||
|
||
get_depth_increase_count :: proc(input: [dynamic]string) -> int { | ||
depth_increase_count := 0 | ||
prev_depth := strconv.atoi(input[0]) | ||
|
||
for line in input { | ||
depth := strconv.atoi(line) | ||
|
||
if prev_depth < depth { | ||
depth_increase_count += 1 | ||
} | ||
prev_depth = depth | ||
} | ||
return depth_increase_count | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import "core:fmt" | ||
import "core:os" | ||
import "core:strconv" | ||
import "core:strings" | ||
import "utils" | ||
|
||
|
||
main :: proc() { | ||
solutions: map[string]proc() = { | ||
"01P1:Sonar Sweep" = D01P1, | ||
} | ||
|
||
for _, solution in solutions { | ||
utils.benchmark(solution) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters