Browse Source

Use enum() instead of manual incrementing

Getty Ritter 4 years ago
parent
commit
bac7cfbf9c
1 changed files with 2 additions and 3 deletions
  1. 2 3
      03/main.pony

+ 2 - 3
03/main.pony

@@ -1,6 +1,7 @@
 use "collections"
 use "files"
 use "format"
+use "itertools"
 
 // The cardinal directions
 primitive U
@@ -181,8 +182,7 @@ class Grid
 
   // follow each `LinePlan` and adds the description of the wires to the grid
   fun ref addLines(plans: Array[LinePlan]) =>
-    var line_number: U8 = 1
-    for plan in plans.values() do
+    for (line_number, plan) in Iter[LinePlan](plans.values()).enum[U8]() do
       var start_point = Point(0, 0)
       var dist: U64 = 1
       for instr in plan.plan().values() do
@@ -192,7 +192,6 @@ class Grid
           dist = dist + 1
         end
       end
-      line_number = line_number + 1
     end
 
   // print all the intersection values along with the point they map to.