This commit is contained in:
xenia 2019-12-01 02:15:53 -05:00
commit d872061ff3
3 changed files with 25 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.session
*.rkt~
input.*.txt
.envrc

17
1.rkt Normal file
View File

@ -0,0 +1,17 @@
#lang racket
(define input (file->list "input.1.txt"))
(define (mass->fuel mass)
(- (floor (/ mass 3)) 2))
; part 1
(displayln (foldr + 0 (map mass->fuel input)))
(define (mass->fuel* mass)
(let ([fuel (mass->fuel mass)])
(cond [(<= fuel 0) 0]
[else (+ fuel (mass->fuel* fuel))])))
; part 2
(displayln (foldr + 0 (map mass->fuel* input)))

4
get-input Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
session=$(cat .session)
curl -SsH "Cookie: session=$session" https://adventofcode.com/2019/day/$1/input > input.$1.txt