uniform function call syntax
This commit is contained in:
@@ -2,7 +2,7 @@ func part1[l1: Array, l2: Array] : void
|
||||
out := 0
|
||||
|
||||
for i in 0..l1->size
|
||||
out += math.abs(array.nth(l1, i) - array.nth(l2, i))
|
||||
out += (l1->nth(i) as i64 - l2->nth(i) as i64)->abs()
|
||||
|
||||
io.println_i64(out)
|
||||
|
||||
@@ -10,7 +10,7 @@ func part2[l1: Array, l2: Array] : void
|
||||
out := 0
|
||||
|
||||
for i in 0..l1->size
|
||||
out += array.nth(l1, i) * alg.count(l2, array.nth(l1, i))
|
||||
out += l1->nth(i) * l2->count(l1->nth(i))
|
||||
|
||||
io.println_i64(out)
|
||||
|
||||
@@ -19,21 +19,21 @@ func main[] : i64
|
||||
if !ok
|
||||
panic("failed to open input.txt")
|
||||
|
||||
lines := str.split(input, "\n")
|
||||
lines := input->split("\n")
|
||||
|
||||
l1 := []
|
||||
l2 := []
|
||||
|
||||
for i in 0..lines->size
|
||||
line : str = array.nth(lines, i)
|
||||
line : str = lines->nth(i)
|
||||
|
||||
parts := str.split(line, " ")
|
||||
parts := line->split(" ")
|
||||
|
||||
array.push(l1, str.parse_i64(array.nth(parts, 0)))
|
||||
array.push(l2, str.parse_i64(array.nth(parts, 1)))
|
||||
l1->push((parts->nth(0) as str)->parse_i64())
|
||||
l2->push((parts->nth(1) as str)->parse_i64())
|
||||
|
||||
alg.quicksort(l1)
|
||||
alg.quicksort(l2)
|
||||
l1->quicksort()
|
||||
l2->quicksort()
|
||||
|
||||
part1(l1, l2)
|
||||
part2(l1, l2)
|
||||
|
||||
Reference in New Issue
Block a user