Day 1 part 1

main
Araozu 2023-12-02 19:32:58 -05:00
parent f78dcce0a6
commit b9932ddbfe
1 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,7 @@
#lang racket
(require racket/port)
; 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
; 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
; calibration values?
(define input '("1abc2"
"pqr3stu8vwx"
"a1b2c3d4e5f"
"treb7uchet"))
; (define input '("1abc2"
; "pqr3stu8vwx"
; "a1b2c3d4e5f"
; "treb7uchet"))
; From a char list returns the first digit it finds as a char, or nil
(define (get-first-digit list)
@ -65,8 +67,13 @@
(define char-list (map string->list input))
(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)