diff options
author | Matias Linares <matias@deprecated.org> | 2023-12-03 15:11:37 -0300 |
---|---|---|
committer | Matias Linares <matias@deprecated.org> | 2023-12-03 15:11:37 -0300 |
commit | d073dcaa66567e58d6f9a36b15c9e54b91ed8c54 (patch) | |
tree | b26480988df75847eba75892bdf33089ec08bcd7 /2022/day5.rb | |
parent | 129ac460f73972097700ad2def6b4c36d6ebe6e1 (diff) | |
download | advent-of-code-d073dcaa66567e58d6f9a36b15c9e54b91ed8c54.tar.gz |
Add 2022 and 2023
Diffstat (limited to '2022/day5.rb')
-rw-r--r-- | 2022/day5.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/2022/day5.rb b/2022/day5.rb new file mode 100644 index 0000000..6d6f849 --- /dev/null +++ b/2022/day5.rb @@ -0,0 +1,43 @@ +TEST_S = <<EOF + [D] +[N] [C] +[Z] [M] [P] + 1 2 3 + +move 1 from 2 to 1 +move 3 from 1 to 3 +move 2 from 2 to 1 +move 1 from 1 to 2 +EOF + +class Stacks + +end + +class Instructions + attr_reader :indexes + + def initialize(header) + indexes = {} + indexes.default = [] + header.readlines do |line| + line.scan(/\w/).each do |c| + indexes[line.index(c)] << c + end + end + + self.indexes = {} + + indexes.each_key.each_with_index do |i, index| + self.indexes[i] = indexes[index] + end + end +end + +def parse_input(filename) + File.open(filename) do |file| + contents = file.read + header, body = contents.split(/^$/) + end + +end |