You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

#### 42 lines 855 B Raw Permalink Normal View History

 Solve a few more puzzles. 6 months ago​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ ```require "advent"require "./intcode_fibers.cr" painted_white = Set({Int64, Int64}).newcolor = {} of {Int64,Int64} => Int64color[{0_i64, 0_i64}] = 1_i64 input, output = new_interpreter("", input(2019, 11).split(",").map &.to_i64)pos = {0_i64, 0_i64}facing = {0_i64, 1_i64} struct Tuple(*T) def turn_left {-self[1], self[0]} end def turn_right turn_left.turn_left.turn_left end def add(other) {self[0] + other[0], self[1] + other[1]} endend loop do c = color[pos]? || 0_i64 input.send c break unless nc = output.receive break unless turn = output.receive color[pos] = nc painted_white << pos if nc == 1 facing = (turn == 0 ? facing.turn_left : facing.turn_right) pos = pos.add facingend 6.times do |y| y = - y 45.times do |x| print (color[{x.to_i64, y.to_i64}]? == 1 ? '#' : ' ') end putsend```