about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-12-02 22:32:27 -0800
committerKartik Agaram <vc@akkartik.com>2020-12-02 22:32:27 -0800
commited59e2eda99c1d7ae048b43a63bfc6869520c5d5 (patch)
tree74e534b24452c9f92150244804b267f6be15aac4
parent50973ad178bdbb8bca9893f4f1129876a68fb7df (diff)
downloadmu-ed59e2eda99c1d7ae048b43a63bfc6869520c5d5.tar.gz
7323 - advent day 3 done
Stupid mistake; I missed one slope in the question.
-rw-r--r--apps/advent2020/3b.mu16
1 files changed, 15 insertions, 1 deletions
diff --git a/apps/advent2020/3b.mu b/apps/advent2020/3b.mu
index 6f9d52d6..531d18fb 100644
--- a/apps/advent2020/3b.mu
+++ b/apps/advent2020/3b.mu
@@ -78,22 +78,33 @@ fn main -> _/ebx: int {
   print-int32-decimal 0, result
   print-string 0, " x "
   product <- multiply result
+  var result/eax: int <- num-trees-hit trees, width, num-rows, 7, 1
+  print-int32-decimal 0, result
+  print-string 0, " x "
+  product <- multiply result
   var result/eax: int <- num-trees-hit trees, width, num-rows, 1, 2
   print-int32-decimal 0, result
   print-string 0, " = "
   product <- multiply result
-  print-int32-decimal 0, product
+  print-int32-hex 0, product
   print-string 0, "\n"
   return 0
 }
 
 fn num-trees-hit trees: (addr array int), width: int, num-rows: int, right: int, down: int -> _/eax: int {
+#?   print-string 0, "== "
+#?   print-int32-decimal 0, right
+#?   print-string 0, " "
+#?   print-int32-decimal 0, down
+#?   print-string 0, "\n"
   var row/ecx: int <- copy 0
   var col/edx: int <- copy 0
   var num-trees-hit/edi: int <- copy 0
   {
     compare row, num-rows
     break-if->=
+#?     print-int32-decimal 0, col
+#?     print-string 0, "\n"
     var curr/eax: int <- index2d trees, row, col, width
     compare curr, 0
     {
@@ -112,6 +123,9 @@ fn index2d _arr: (addr array int), _row: int, _col: int, width: int -> _/eax: in
   var dummy/eax: int <- copy 0
   var col/edx: int <- copy 0
   dummy, col <- integer-divide _col, width
+#?   print-string 0, "  "
+#?   print-int32-decimal 0, col
+#?   print-string 0, "\n"
   # compute index
   var index/eax: int <- copy _row
   index <- multiply width