Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 2022/07/ChAoSUnItY.v
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fn (mut fs FileSystem) update_parent_dir_size(size u32, parent usize) {
match mut parent_node {
DirNode {
parent_node.size += size
fs.nodes[parent] = parent_node

if grand_parent := parent_node.parent {
fs.update_parent_dir_size(size, grand_parent)
Expand All @@ -91,6 +92,7 @@ fn (mut fs FileSystem) add_node(node Node) {
match mut current_node {
DirNode {
current_node.children << usize(index)
fs.nodes[fs.current_node] = current_node
}
else {}
}
Expand Down
4 changes: 2 additions & 2 deletions 2023/02/JalonSolov.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mut sum_of_powers := 0

for l in lines {
game_num := l[5..].int()
draws := l[l.index(':')! + 1..].split(';').map(it.trim_space())
draws := l[(l.index(':') or { panic('missing colon') }) + 1..].split(';').map(it.trim_space())
mut possible := true
mut min_red := 0
mut min_green := 0
Expand All @@ -22,7 +22,7 @@ for l in lines {

for cube in cubes {
num_cubes := cube.int()
cube_color := cube[cube.index(' ')! + 1..]
cube_color := cube[(cube.index(' ') or { panic('missing space') }) + 1..]

match cube_color {
'red' {
Expand Down
4 changes: 2 additions & 2 deletions 2023/02/jacksonmowry.v
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ fn main() {
}

fn part_2(input []string) !int {
return arrays.sum[int](input.map(it.split(': ')[1]).map(it.split_any(',;').map(it.trim_space().split(' '))).map(it.power()))
return arrays.sum[int](input.map(it.split(': ')[1]).map(it.split_any(',;').map(it.trim_space().split(' '))).map(power(it)))
}

fn (s [][]string) power() int {
fn power(s [][]string) int {
mut arr := [1, 1, 1]
for hand in s {
num := hand[0].int()
Expand Down
4 changes: 2 additions & 2 deletions 2024/03/leodev.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
mut re := regex.regex_opt(r'mul\(\d{1,3},\d{1,3}\)')!
mut total := 0
for value in re.find_all_str(content) {
a, b := value[4..value.len - 1].split_once(',') or { panic(err) }
a, b := value[4..value.len - 1].split_once(',') or { panic('missing delimiter') }
total += a.int() * b.int()
}

Expand All @@ -28,7 +28,7 @@ fn main() {
continue
}

a, b := content2[start + 4..end - 1].split_once(',') or { panic(err) }
a, b := content2[start + 4..end - 1].split_once(',') or { panic('missing delimiter') }
total2 += a.int() * b.int()
}

Expand Down
2 changes: 1 addition & 1 deletion 2024/05/leodev.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
break
}

a, b := line.split_once('|') or { panic(err) }
a, b := line.split_once('|') or { panic('missing delimiter') }
rules[a.int()] << b.int()
rules2[b.int()] << a.int()
}
Expand Down
2 changes: 1 addition & 1 deletion 2024/07/leodev.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
mut total1 := i64(0)
mut total2 := i64(0)
for line in lines {
expected_str, value_str := line.split_once(': ') or { panic(err) }
expected_str, value_str := line.split_once(': ') or { panic('missing delimiter') }
expected := expected_str.i64()
values := value_str.split(' ').map(it.i64())

Expand Down
Loading