Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Dec 4, 2023
1 parent c37d63b commit 985bed2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions examples/aoc2023/day04/part1.jou
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import "stdlib/io.jou"
import "stdlib/mem.jou"
import "stdlib/str.jou"
import "stdlib/ascii.jou"


def main() -> int:
f = fopen("input.txt", "r")
f = fopen("sampleinput.txt", "r")
assert f != NULL

total_score = 0
Expand Down Expand Up @@ -41,7 +42,9 @@ def main() -> int:
k *= 2
total_score += k

free(words)

fclose(f)

printf("%d\n", total_score)
printf("%d\n", total_score) # Output: 13
return 0
8 changes: 5 additions & 3 deletions examples/aoc2023/day04/part2.jou
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import "stdlib/io.jou"
import "stdlib/str.jou"
import "stdlib/mem.jou"
import "stdlib/ascii.jou"



# returned array is -1 terminated and should be free()d
def read_win_counts() -> int[500]:
f = fopen("input.txt", "r")
f = fopen("sampleinput.txt", "r")
assert f != NULL

result: int[500]
Expand Down Expand Up @@ -41,6 +41,8 @@ def read_win_counts() -> int[500]:
assert result_len < sizeof(result)/sizeof(result[0])
result[result_len++] = match_count

free(words)

fclose(f)

assert result_len < sizeof(result)/sizeof(result[0])
Expand Down Expand Up @@ -68,6 +70,6 @@ def main() -> int:
sum = 0
for i = 0; i < num_cards; i++:
sum += card_counts[i]
printf("%d\n", sum)
printf("%d\n", sum) # Output: 30

return 0

0 comments on commit 985bed2

Please sign in to comment.