diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-12-02 22:12:55 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-12-02 22:12:55 -0800 |
commit | 124f515826f30da1379dad5c921117e206040fa2 (patch) | |
tree | bd3263ef54ef22620fdead455859b92d0e7088a8 | |
parent | 36b4bf1f1b8aaf9a036bfe77e1c8045b24d652eb (diff) | |
download | mu-124f515826f30da1379dad5c921117e206040fa2.tar.gz |
7321 - advent day 3 part 1
-rw-r--r-- | apps/advent2020/3a.mu | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/apps/advent2020/3a.mu b/apps/advent2020/3a.mu index a2cc6fb6..777a7be0 100644 --- a/apps/advent2020/3a.mu +++ b/apps/advent2020/3a.mu @@ -69,28 +69,25 @@ fn main -> _/ebx: int { print-string 0, "x" print-int32-decimal 0, width print-string 0, "\n" - var i/eax: int <- copy 0 + var row/ecx: int <- copy 0 + var col/edx: int <- copy 0 + var num-trees-hit/edi: int <- copy 0 { - compare i, num-rows + compare row, num-rows break-if->= - var j/ecx: int <- copy 0 + var curr/eax: int <- index2d trees, row, col, width + compare curr, 0 { - compare j, width - break-if->= -#? print-int32-decimal 0, i -#? print-string 0, " " -#? print-int32-decimal 0, j -#? print-string 0, "\n" - var src/eax: int <- index2d trees, i, j, width - print-int32-decimal 0, src -#? print-string 0, "\n" - j <- increment - loop + break-if-= + num-trees-hit <- increment } - print-string 0, "\n" - i <- increment + # right 3, down 1 + col <- add 3 + row <- add 1 loop } + print-int32-decimal 0, num-trees-hit + print-string 0, "\n" return 0 } |