Browse Source

Use var not pointers

master
Chris Smith 5 years ago
parent
commit
5c5b892740
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      day07.nim

+ 3
- 3
day07.nim View File

10
     var falses: array[27, bool]
10
     var falses: array[27, bool]
11
     status.find(falses)
11
     status.find(falses)
12
 
12
 
13
-func execute(status: ptr array[26, array[27, bool]], action: int) =
13
+func execute(status: var array[26, array[27, bool]], action: int) =
14
     status[action][0] = true
14
     status[action][0] = true
15
     for i in 0..25:
15
     for i in 0..25:
16
         status[i][action + 1] = false
16
         status[i][action + 1] = false
20
     status.deepCopy(dependencies)
20
     status.deepCopy(dependencies)
21
     for i in 0..25:
21
     for i in 0..25:
22
         var task = status.next_task
22
         var task = status.next_task
23
-        status.addr.execute(task)
23
+        status.execute(task)
24
         result &= chr(task + 65)
24
         result &= chr(task + 65)
25
 
25
 
26
 func part2(dependencies: array[26, array[27, bool]]): int =
26
 func part2(dependencies: array[26, array[27, bool]]): int =
43
                 if task_times[i] <= time:
43
                 if task_times[i] <= time:
44
                     task_times[i] = 0
44
                     task_times[i] = 0
45
                     completed &= chr(i + 65)
45
                     completed &= chr(i + 65)
46
-                    status.addr.execute(i)
46
+                    status.execute(i)
47
                 else:
47
                 else:
48
                     step = min(step, task_times[i] - time)
48
                     step = min(step, task_times[i] - time)
49
 
49