Skip to content

Instantly share code, notes, and snippets.

View alexander-yakushev's full-sized avatar
🪖
Defending against russian invasion

Oleksandr Yakushev alexander-yakushev

🪖
Defending against russian invasion
View GitHub Profile
@alexander-yakushev
alexander-yakushev / aoc2023-day1.clj
Last active December 1, 2023 13:53
Advent of Code 2023, day 1
;; Didn't know yet that there is a special syntax to make regexes overlapping. Got angry and wrote this.
(require '[clojure.string :as str])
(def digits (->> ["one" "two" "three" "four" "five" "six" "seven" "eight" "nine"]
(map-indexed (fn [i w] [w (str (inc i))]))
(into {})))
(def rx (re-pattern (str/join "|" (conj (keys digits) "[0-9]"))))
(def rx-rev (re-pattern (str/join "|" (conj (map str/reverse (keys digits)) "[0-9]"))))
@alexander-yakushev
alexander-yakushev / aoc2023-day4.clj
Created December 4, 2023 09:14
Advent of Code 2023, day 4
(ns day4
(:require [clojure.set :as set]
[clojure.java.io :as io]))
(def lines (vec (line-seq (io/reader "2023/day4.txt"))))
(defn parse []
(for [line lines]
(let [[winning guessed] (str/split line #"\|")
[game & winning] (map parse-long (re-seq #"\d+" winning))
@alexander-yakushev
alexander-yakushev / aoc2023-day5.clj
Created December 5, 2023 14:04
Advent of Code 2023, day 5
(ns day5
(:require [clojure.java.io :as io]))
(def lines (vec (line-seq (io/reader "2023/day5.txt"))))
(defn parse [task]
(let [seeds (mapv parse-long (re-seq #"\d+" (first lines)))
seeds (case task
1 seeds
2 (->> (partition 2 seeds)
@alexander-yakushev
alexander-yakushev / aoc2023-day6.clj
Created December 6, 2023 09:15
Advent of Code 2023, day 6
(ns day6
(:require [clojure.string :as str]))
(defn parse [task]
(->> (line-seq (io/reader "2023/day6.txt"))
(map #(map parse-long
(re-seq #"\d+" (case task
1 %
2 (str/replace % #" " "")))))))
@alexander-yakushev
alexander-yakushev / aoc2023-day7.clj
Last active December 7, 2023 08:04
Advent of Code 2023, day 7
(ns day7
(:require [clojure.string :as str]
[clojure.java.io :as io]))
(def lines (vec (line-seq (io/reader "day7.txt"))))
(defn parse [task]
(for [line lines]
(let [[hand bid] (str/split line #" " )]
[(mapv #(case %
@alexander-yakushev
alexander-yakushev / aoc2023-day12.clj
Created December 12, 2023 19:58
Advent of Code 2023, day 12
(ns day12
(:require [clojure.string :as str]
[clojure.java.io :as io]))
(def lines (line-seq (io/reader "2023/day12.txt")))
(defn parse [task]
(for [line lines]
(let [[field hints] (str/split line #" ")]
(case task
@alexander-yakushev
alexander-yakushev / latex-cheatsheet-template.tex
Last active March 8, 2024 20:50
Beautiful cheatsheet template for key bindings, compiled with XeLaTeX
%% Copyright 2020 Alexander Yakushev
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%