I also use Ruby (if I have time try to replicate in Python for learning) and found part 1 ok.
input = File.read('day10.txt').split("\n").map(&:to_i).sort!.insert(0, 0) input.push(input[-1]+3) puts "Part 1:" puts (0...(input.length-1)).each .map { |a| input[a+1]-input[a] } .group_by { |n| n } .map { |e, v| v.length } .reduce(:*)
But Part 2 stumped me. I got the general gist of the problem, but couldn't get started on a solution.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I also use Ruby (if I have time try to replicate in Python for learning) and found part 1 ok.
But Part 2 stumped me. I got the general gist of the problem, but couldn't get started on a solution.