use index assignment in existing code
This commit is contained in:
@@ -16,13 +16,13 @@ func main[] : i64
|
||||
else if op == '<'
|
||||
p = p - 1
|
||||
else if op == '+'
|
||||
str.set(memory, p, memory[p] + 1)
|
||||
memory[p] = memory[p] + 1
|
||||
else if op == '-'
|
||||
str.set(memory, p, memory[p] - 1)
|
||||
memory[p] = memory[p] - 1
|
||||
else if op == '.'
|
||||
io.print_char(memory[p])
|
||||
else if op == ','
|
||||
str.set(memory, p, io.read_char())
|
||||
memory[p] = io.read_char()
|
||||
else if op == '['
|
||||
if !memory[p]
|
||||
i = i + 1
|
||||
|
||||
@@ -32,7 +32,7 @@ func main[] : i64
|
||||
|
||||
let base_point: ptr = mem.alloc(32)
|
||||
mem.zero(base_point, 32)
|
||||
mem.write8(base_point, 9)
|
||||
base_point[0] = 9
|
||||
|
||||
let alice_private: ptr = str.hex_decode("77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a")
|
||||
io.print("A_priv: ")
|
||||
|
||||
@@ -44,11 +44,11 @@ func part2[lines: array] : void
|
||||
for y in 1..str.len(array.nth(lines, x))-1
|
||||
if array.nth(lines, x)[y] == 'A'
|
||||
let s: str = mem.alloc(5)
|
||||
str.set(s, 0, array.nth(lines, x - 1)[y - 1])
|
||||
str.set(s, 1, array.nth(lines, x + 1)[y - 1])
|
||||
str.set(s, 2, array.nth(lines, x + 1)[y + 1])
|
||||
str.set(s, 3, array.nth(lines, x - 1)[y + 1])
|
||||
str.set(s, 4, 0)
|
||||
s[0] = array.nth(lines, x - 1)[y - 1]
|
||||
s[1] = array.nth(lines, x + 1)[y - 1]
|
||||
s[2] = array.nth(lines, x + 1)[y + 1]
|
||||
s[3] = array.nth(lines, x - 1)[y + 1]
|
||||
s[4] = 0
|
||||
|
||||
if str.equal(s, "MSSM") || str.equal(s, "SMMS") || str.equal(s, "MMSS") || str.equal(s, "SSMM")
|
||||
out = out + 1
|
||||
|
||||
@@ -8,9 +8,9 @@ func part1[lines: array] : void
|
||||
for j in 0..str.len(line)
|
||||
for k in (j+1)..str.len(line)
|
||||
let s: str = mem.alloc(3)
|
||||
str.set(s, 0, line[j])
|
||||
str.set(s, 1, line[k])
|
||||
str.set(s, 2, 0)
|
||||
s[0] = line[j]
|
||||
s[1] = line[k]
|
||||
s[2] = 0
|
||||
let n: i64 = str.parse_i64(s)
|
||||
if n > largest
|
||||
largest = n
|
||||
|
||||
Reference in New Issue
Block a user