type inference for variables
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
func concat[a: i64, b: i64] : i64
|
||||
let a_str: str = str.from_i64(a)
|
||||
let b_str: str = str.from_i64(b)
|
||||
let ab_str: str = str.concat(a_str, b_str)
|
||||
let out: i64 = str.parse_i64(ab_str)
|
||||
let a_str = str.from_i64(a)
|
||||
let b_str = str.from_i64(b)
|
||||
let ab_str = str.concat(a_str, b_str)
|
||||
let out = str.parse_i64(ab_str)
|
||||
// without freeing the program works but leaks 2GB of memory :p
|
||||
mem.free(a_str)
|
||||
mem.free(b_str)
|
||||
@@ -11,8 +11,8 @@ func concat[a: i64, b: i64] : i64
|
||||
|
||||
func solve[ops: Array, e: Array] : i64
|
||||
let e_1: Array = array.nth(e, 1)
|
||||
let n: i64 = e_1->size - 1
|
||||
let indices: Array = []
|
||||
let n = e_1->size - 1
|
||||
let indices = []
|
||||
for i in 0..n
|
||||
array.push(indices, 0)
|
||||
|
||||
@@ -30,8 +30,8 @@ func solve[ops: Array, e: Array] : i64
|
||||
if res == array.nth(e, 0)
|
||||
return res
|
||||
|
||||
let done: bool = true
|
||||
let i: i64 = n - 1
|
||||
let done = true
|
||||
let i = n - 1
|
||||
|
||||
while i >= 0
|
||||
array.set(indices, i, array.nth(indices, i) + 1)
|
||||
@@ -61,14 +61,14 @@ func part2[equations: Array] : void
|
||||
io.println_i64(out)
|
||||
|
||||
func main[] : i64
|
||||
let lines: Array = must(io.read_text_file?("input.txt")) |> str.split("\n")
|
||||
let equations: Array = []
|
||||
let lines = must(io.read_text_file?("input.txt")) |> str.split("\n")
|
||||
let equations = []
|
||||
|
||||
for i in 0..lines->size
|
||||
let line: str = array.nth(lines, i)
|
||||
let parts: Array = str.split(line, ": ")
|
||||
let parts = str.split(line, ": ")
|
||||
|
||||
let xs: Array = str.split(array.nth(parts, 1), " ")
|
||||
let xs = str.split(array.nth(parts, 1), " ")
|
||||
for j in 0..xs->size
|
||||
array.set(xs, j, str.parse_i64(array.nth(xs, j)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user