Day 1 part 1
This commit is contained in:
parent
f78dcce0a6
commit
b9932ddbfe
17
main.rkt
17
main.rkt
@ -1,5 +1,7 @@
|
|||||||
#lang racket
|
#lang racket
|
||||||
|
|
||||||
|
(require racket/port)
|
||||||
|
|
||||||
; You try to ask why they can't just use a weather machine ("not powerful enough")
|
; You try to ask why they can't just use a weather machine ("not powerful enough")
|
||||||
; and where they're even sending you ("the sky") and why your map looks mostly
|
; and where they're even sending you ("the sky") and why your map looks mostly
|
||||||
; blank ("you sure ask a lot of questions") and hang on did you just say the sky
|
; blank ("you sure ask a lot of questions") and hang on did you just say the sky
|
||||||
@ -31,10 +33,10 @@
|
|||||||
; Consider your entire calibration document. What is the sum of all of the
|
; Consider your entire calibration document. What is the sum of all of the
|
||||||
; calibration values?
|
; calibration values?
|
||||||
|
|
||||||
(define input '("1abc2"
|
; (define input '("1abc2"
|
||||||
"pqr3stu8vwx"
|
; "pqr3stu8vwx"
|
||||||
"a1b2c3d4e5f"
|
; "a1b2c3d4e5f"
|
||||||
"treb7uchet"))
|
; "treb7uchet"))
|
||||||
|
|
||||||
; From a char list returns the first digit it finds as a char, or nil
|
; From a char list returns the first digit it finds as a char, or nil
|
||||||
(define (get-first-digit list)
|
(define (get-first-digit list)
|
||||||
@ -65,8 +67,13 @@
|
|||||||
(define char-list (map string->list input))
|
(define char-list (map string->list input))
|
||||||
(define result (foldl + 0 (map list->digits char-list)))
|
(define result (foldl + 0 (map list->digits char-list)))
|
||||||
|
|
||||||
(print result)
|
(define file-contents
|
||||||
|
(port->string (open-input-file "input-01.txt") #:close? #t))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; (print result)
|
||||||
|
Loading…
Reference in New Issue
Block a user