Skip to content

Instantly share code, notes, and snippets.

View Solaxun's full-sized avatar

Mark Woodworth Solaxun

View GitHub Profile
@Solaxun
Solaxun / makemore_part1.ipynb
Last active August 25, 2023 03:01
Makemore Part 1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Solaxun
Solaxun / neuralnet.ipynb
Created November 20, 2022 00:10
basic neural net implementation for digit recognition
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Solaxun
Solaxun / day21.py
Created December 24, 2021 20:13
day21.py
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:
@Solaxun
Solaxun / day1.clj
Created December 4, 2021 20:20
AoC 2021: Clojure Day 1
(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)))
@Solaxun
Solaxun / day2.clj
Created December 4, 2021 20:17
AoC 2021: Clojure Day 2
(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 % #" "))
@Solaxun
Solaxun / day3.clj
Created December 4, 2021 20:15
AoC 2021: Clojure Day 3
(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))
@Solaxun
Solaxun / day4.clj
Created December 4, 2021 20:14
AoC 2021: Clojure Day 4
(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 #(= "" %))))
@Solaxun
Solaxun / day4.py
Created December 4, 2021 20:14
AoC 2021: Python Day 4
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)]
@Solaxun
Solaxun / day3.py
Created December 4, 2021 20:13
AoC 2021: Python Day 3
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)
@Solaxun
Solaxun / day2.py
Created December 4, 2021 20:12
AoC 2021: Python Day 2
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