mirror of
https://github.com/onyx-and-iris/aoc2025.git
synced 2025-12-08 19:57:48 +00:00
remove loop
This commit is contained in:
parent
f073b70176
commit
91c0cfa768
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Main
|
class Main
|
||||||
def run
|
def run
|
||||||
@ -8,12 +9,12 @@ class Main
|
|||||||
$stdin.each_line do |line|
|
$stdin.each_line do |line|
|
||||||
direction, magnitude = line[0], line[1..].to_i
|
direction, magnitude = line[0], line[1..].to_i
|
||||||
|
|
||||||
loop do
|
while magnitude > 0
|
||||||
case direction
|
case direction
|
||||||
when "R"
|
when "R"
|
||||||
current = (current + 1) % 100
|
current = (current + 1) % 100
|
||||||
when "L"
|
when "L"
|
||||||
current = (current - 1) % 100
|
current = (current - 1 + 100) % 100
|
||||||
end
|
end
|
||||||
|
|
||||||
if current == 0
|
if current == 0
|
||||||
@ -21,7 +22,6 @@ class Main
|
|||||||
end
|
end
|
||||||
|
|
||||||
magnitude -= 1
|
magnitude -= 1
|
||||||
break if magnitude == 0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user