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 bs4 import BeautifulSoup | |
import requests | |
import feedparser | |
import urllib | |
import datetime | |
base_url = "https://nrk.no" | |
cache_refresh_time_delta = datetime.timedelta(hours=4) | |
identifier = "nrk" |
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
#lang racket | |
(require threading) | |
(define (get-input) | |
(file->lines "day14.txt")) | |
(struct raindeer (spd tm rst nm) #:transparent) | |
(define (parse-line str) | |
(define vals (map string->number (regexp-match* #px"\\d+" str))) |
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
#lang racket | |
(require threading) | |
(define (get-input) | |
(file->lines "day13.txt")) | |
(struct line (p1 p2 val) #:transparent) | |
(define (parse-line str) | |
(define tokens (string-split (string-replace str "." "") " ")) |
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
#lang racket | |
(require json) | |
(require threading) | |
(define (get-input) | |
(file->string "day12.txt")) | |
(define (input->hash) | |
(with-input-from-file "day12.txt" | |
(lambda () (read-json)))) |
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
#lang racket | |
(require threading) | |
(define input "cqjxjnds") | |
(define (has-increasing? str) | |
(define (inc-rec lst) | |
(cond | |
[(> 3 (length lst)) #f] | |
[(and (= 1 (- (third lst) (second lst))) |
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
#lang racket | |
(require threading) | |
(define input "1321131112") | |
(define (parse str) | |
(~>> str | |
(string->list) | |
(map char->integer) | |
(map (curry + -48)))) |
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
#lang racket | |
(require threading) | |
(define (get-input) | |
(file->lines "day9.txt")) | |
(struct edge (from to dist) #:transparent) | |
(struct step (from to) #:transparent) | |
(define (parse-line str) |
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
#lang racket | |
(require threading) | |
(define (get-input) | |
(file->lines "day8.txt")) | |
(define (str-len str) | |
(if (= 0 (string-length str)) | |
0 | |
(string-length (read (open-input-string str))))) |
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
#lang racket | |
(require threading) | |
(define (get-input) | |
(file->lines "day7.txt")) | |
(struct part (cmd a b to) #:transparent) | |
(define (string->param str) | |
(if str |
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
#lang typed/racket | |
(require threading) | |
(: get-input (-> (Listof String))) | |
(define (get-input) | |
(file->lines "day6.txt")) | |
(struct pt ([x : Integer] [y : Integer]) #:transparent) | |
(struct ins ([cmd : Symbol] [from : pt] [to : pt]) #:transparent) | |
(define-type Grid (Immutable-HashTable pt Integer)) |