Compare commits

...

2 Commits

Author SHA1 Message Date
65934bcaa0 add frozen_string_literal 2025-12-01 18:27:40 +00:00
91c0cfa768 remove loop 2025-12-01 18:27:25 +00:00
3 changed files with 57 additions and 3 deletions

53
Gemfile.lock Normal file
View File

@ -0,0 +1,53 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
json (2.8.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
parallel (1.26.3)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
racc (1.8.1)
rainbow (3.1.1)
regexp_parser (2.9.2)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.36.1)
parser (>= 3.3.1.0)
rubocop-performance (1.22.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
standard (1.42.1)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.68.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.5)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.5.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.22.0)
unicode-display_width (2.6.0)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
standard (~> 1.31)
BUNDLED WITH
2.5.22

View File

@ -1,4 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true
class Main class Main
def run def run

View File

@ -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