Taddeus Kroes %!s(int64=4) %!d(string=hai) anos
pai
achega
40db075f76
Modificáronse 1 ficheiros con 1 adicións e 4 borrados
  1. 1 4
      2021/25_cucumbers.py

+ 1 - 4
2021/25_cucumbers.py

@@ -5,15 +5,12 @@ def parse(content):
     return list(content.replace('\n', '')), content.find('\n')
     return list(content.replace('\n', '')), content.find('\n')
 
 
 def move(grid, w):
 def move(grid, w):
-    h = len(grid) // w
-
     def right(i):
     def right(i):
         y, x = divmod(i, w)
         y, x = divmod(i, w)
         return y * w + (x + 1) % w
         return y * w + (x + 1) % w
 
 
     def down(i):
     def down(i):
-        y, x = divmod(i, w)
-        return (y + 1) % h * w + x
+        return (i + w) % len(grid)
 
 
     def move_axis(match, forward):
     def move_axis(match, forward):
         can_move = [src for src, cell in enumerate(grid)
         can_move = [src for src, cell in enumerate(grid)