2025-01
This commit is contained in:
1
2025/.tool-versions
Normal file
1
2025/.tool-versions
Normal file
@@ -0,0 +1 @@
|
||||
ruby 3.4.7
|
||||
25
2025/01.rb
Normal file
25
2025/01.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
input = File.readlines('input/01')
|
||||
pos = 50
|
||||
p1 = 0
|
||||
p2 = 0
|
||||
|
||||
input.each do |line|
|
||||
dir = line[0]
|
||||
n = line[1..].to_i
|
||||
(1..n).each do
|
||||
if dir == 'R'
|
||||
pos = (pos - 1 + 100) % 100
|
||||
else
|
||||
pos = (pos + 1) % 100
|
||||
end
|
||||
if pos.zero?
|
||||
p2 += 1
|
||||
end
|
||||
end
|
||||
if pos.zero?
|
||||
p1 += 1
|
||||
end
|
||||
end
|
||||
|
||||
puts p1
|
||||
puts p2
|
||||
3
2025/README.md
Normal file
3
2025/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# 2025
|
||||
|
||||
Ruby 3.4.7
|
||||
4036
2025/input/01
Normal file
4036
2025/input/01
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user