mirror of
https://github.com/onyx-and-iris/aoc2025.git
synced 2025-12-07 22:57:50 +00:00
first commit
This commit is contained in:
commit
f073b70176
63
.gitignore
vendored
Normal file
63
.gitignore
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# Generated by ignr: github.com/onyx-and-iris/ignr
|
||||||
|
|
||||||
|
## Ruby ##
|
||||||
|
*.gem
|
||||||
|
*.rbc
|
||||||
|
/.config
|
||||||
|
/coverage/
|
||||||
|
/InstalledFiles
|
||||||
|
/pkg/
|
||||||
|
/spec/reports/
|
||||||
|
/spec/examples.txt
|
||||||
|
/test/tmp/
|
||||||
|
/test/version_tmp/
|
||||||
|
/tmp/
|
||||||
|
|
||||||
|
# Used by dotenv library to load environment variables.
|
||||||
|
# .env
|
||||||
|
|
||||||
|
# Ignore Byebug command history file.
|
||||||
|
.byebug_history
|
||||||
|
|
||||||
|
## Specific to RubyMotion:
|
||||||
|
.dat*
|
||||||
|
.repl_history
|
||||||
|
build/
|
||||||
|
*.bridgesupport
|
||||||
|
build-iPhoneOS/
|
||||||
|
build-iPhoneSimulator/
|
||||||
|
|
||||||
|
## Specific to RubyMotion (use of CocoaPods):
|
||||||
|
#
|
||||||
|
# We recommend against adding the Pods directory to your .gitignore. However
|
||||||
|
# you should judge for yourself, the pros and cons are mentioned at:
|
||||||
|
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||||
|
#
|
||||||
|
# vendor/Pods/
|
||||||
|
|
||||||
|
## Documentation cache and generated files:
|
||||||
|
/.yardoc/
|
||||||
|
/_yardoc/
|
||||||
|
/doc/
|
||||||
|
/rdoc/
|
||||||
|
|
||||||
|
## Environment normalization:
|
||||||
|
/.bundle/
|
||||||
|
/vendor/bundle
|
||||||
|
/lib/bundler/man/
|
||||||
|
|
||||||
|
# for a library or gem, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# Gemfile.lock
|
||||||
|
# .ruby-version
|
||||||
|
# .ruby-gemset
|
||||||
|
|
||||||
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||||
|
.rvmrc
|
||||||
|
|
||||||
|
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
||||||
|
# .rubocop-https?--*
|
||||||
|
|
||||||
|
# End of ignr
|
||||||
|
|
||||||
|
*.txt
|
||||||
5
Gemfile
Normal file
5
Gemfile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
gem "standard", "~> 1.31"
|
||||||
27
day_01/1.rb
Executable file
27
day_01/1.rb
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
class Main
|
||||||
|
def run
|
||||||
|
current = 50
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
$stdin.each_line do |line|
|
||||||
|
direction, magnitude = line[0], line[1..].to_i
|
||||||
|
|
||||||
|
case direction
|
||||||
|
when "R"
|
||||||
|
current = (current + magnitude) % 100
|
||||||
|
when "L"
|
||||||
|
current = (current -= magnitude) % 100
|
||||||
|
end
|
||||||
|
|
||||||
|
if current == 0
|
||||||
|
count += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
puts count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Main.new.run
|
||||||
32
day_01/2.rb
Executable file
32
day_01/2.rb
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
class Main
|
||||||
|
def run
|
||||||
|
current = 50
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
$stdin.each_line do |line|
|
||||||
|
direction, magnitude = line[0], line[1..].to_i
|
||||||
|
|
||||||
|
loop do
|
||||||
|
case direction
|
||||||
|
when "R"
|
||||||
|
current = (current + 1) % 100
|
||||||
|
when "L"
|
||||||
|
current = (current - 1) % 100
|
||||||
|
end
|
||||||
|
|
||||||
|
if current == 0
|
||||||
|
count += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
magnitude -= 1
|
||||||
|
break if magnitude == 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
puts count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Main.new.run
|
||||||
Loading…
x
Reference in New Issue
Block a user