Skip to content

Instantly share code, notes, and snippets.

View dropkickfish's full-sized avatar

Andy Thackray dropkickfish

View GitHub Profile
@dropkickfish
dropkickfish / 3.rb
Created December 3, 2020 18:44
Advent of Code 2020 - Day 3
matrix = []
$totaltrees = []
x, y, $trees, slope = 0, 0, 0, -1
File.foreach('3.txt') { |line| matrix << line.strip.split('') and slope += 1 }
possibilities = [[1,1],
[3,1],
[5,1],
[7,1],
@dropkickfish
dropkickfish / 2-2.rb
Created December 2, 2020 18:29
Advent of Code 2020 - Day 2 (2)
array = []
valid = 0
def min(len)
len.split('-')[0].to_i - 1
end
def max(len)
len.split('-')[1].to_i - 1
end
@dropkickfish
dropkickfish / 2-1.rb
Created December 2, 2020 12:29
Advent of Code 2020 - Day 2 (1)
array = []
valid = 0
def min(len)
len.split("-")[0].to_i
end
def max(len)
len.split("-")[1].to_i
end
@dropkickfish
dropkickfish / day1.rb
Created December 1, 2020 22:53
Advent of Code 2020 Day 1
array = []
File.foreach("input1.txt") { |line| array << line.to_i }
pairs = array.combination(ARGV[0].to_i)
pairs.each do |pair|
if pair.sum == 2020
puts pair[0..-1].reduce(:*)
end
end
@dropkickfish
dropkickfish / TalkingClock.java
Last active November 16, 2017 22:58
This was daily challenge [2017-06-27] Challenge #321 [Easy] Talking Clock from /r/dailyprogrammer. I attempted this after about a day of self study and not really having a large understanding of Java or any other language. I used mostly only functions I knew and only used code I had googled if I could understand it. For the next step here I woul…
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
public class TalkingClock {
public static void main(String[] args) {