View makemore_part1.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View neuralnet.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View day21.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mod1(num,m): return num % m or m | |
cache = {} | |
def play_round(player,pos1,score1,pos2,score2): | |
if (pos1,score1,pos2,score2) in cache: | |
return cache[(pos1,score1,pos2,score2)] | |
# swap 0/1 below to get the other player wins | |
if score1 >= 21: | |
return 1 | |
if score2 >= 21: |
View day1.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns aoc-clj-2021.day1 | |
(:require [clojure.string :as str] | |
[clojure.set :as set] | |
[clojure.java.io :as io])) | |
(def data | |
(->> (io/resource "day1.txt") | |
slurp | |
str/split-lines | |
(map parse-long))) |
View day2.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns aoc-clj-2021.day2 | |
(:require [clojure.string :as str] | |
[clojure.set :as set] | |
[clojure.java.io :as io])) | |
(def data | |
(->> (io/resource "day2.txt") | |
slurp | |
str/split-lines | |
(map #(str/split % #" ")) |
View day3.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns aoc-clj-2021.day3 | |
(:require [clojure.string :as str] | |
[clojure.set :as set] | |
[clojure.java.io :as io])) | |
(def data | |
(->> (io/resource "day3.txt") | |
slurp | |
str/split-lines)) |
View day4.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns aoc-clj-2021.day4 | |
(:require [clojure.string :as str] | |
[clojure.set :as set] | |
[clojure.java.io :as io])) | |
(def data | |
(->> (io/resource "day4.txt") | |
slurp | |
str/split-lines | |
(remove #(= "" %)))) |
View day4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
data = open('day4.txt').read().split('\n\n') | |
hand, *boards = data | |
boards = " ".join(boards) | |
hands = [int(n) for n in hand.split(',')] | |
nums = [int(n) for n in re.findall("(\d+)",boards)] | |
fives = [nums[i:i+5] for i in range(0,len(nums),5)] | |
boards = [fives[i:i+5] for i in range(0,len(fives),5)] |
View day3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
data = open('day3.txt').read().splitlines() | |
def common_bits(bits,most=True): | |
data = list(zip(*bits)) | |
mc = [Counter(d).most_common() for d in data] | |
mc = [d[0] if most else d[-1] for d in mc] | |
mc = [d[0] for d in mc] | |
return int("".join(mc),2) |
View day2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = open('day2.txt').read().splitlines() | |
depth, horizontal = 0,0 | |
for line in data: | |
dir,amt = line.split() | |
amt = int(amt) | |
if dir == 'forward': | |
horizontal += amt | |
elif dir == 'down': | |
depth += amt |
NewerOlder