Day 21 lol
This commit is contained in:
parent
3e3a03e517
commit
3b52cc2dd2
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
||||||
|
#lang racket
|
||||||
|
|
||||||
|
(require "../lib.rkt")
|
||||||
|
|
||||||
|
(let ([bindings
|
||||||
|
(for/list ([yell (problem-input 21)])
|
||||||
|
(match yell
|
||||||
|
[(pregexp "(\\w+): (\\d+)" `(,_ ,monkey ,n))
|
||||||
|
(format "(define (~a) ~a)" monkey n)]
|
||||||
|
[(pregexp "(\\w+): (\\w+) (\\+|-|\\*|/) (\\w+)" `(,_ ,monkey ,monkey1 ,op ,monkey2))
|
||||||
|
(format "(define (~a) (~a (~a) (~a)))" monkey op monkey1 monkey2)]))])
|
||||||
|
(display-lines-to-file
|
||||||
|
`(,"#lang racket" ,@bindings "(root)")
|
||||||
|
"21-part1.rkt" #:exists 'replace))
|
||||||
|
|
||||||
|
(let ([bindings
|
||||||
|
(for/list ([yell (problem-input 21)])
|
||||||
|
(match yell
|
||||||
|
[(pregexp "humn: \\d+" `(,_))
|
||||||
|
"(define-symbolic humn integer?)"]
|
||||||
|
[(pregexp "root: (\\w+) (\\+|-|\\*|/) (\\w+)" `(,_ ,monkey1 ,op ,monkey2))
|
||||||
|
(format "(define (root) (assert (eq? (~a) (~a))))" monkey1 monkey2)]
|
||||||
|
[(pregexp "(\\w+): (\\w+) (\\+|-|\\*|/) humn" `(,_ ,monkey ,monkey1 ,op))
|
||||||
|
(format "(define (~a) (~a (~a) humn))" monkey op monkey1)]
|
||||||
|
[(pregexp "(\\w+): (\\d+)" `(,_ ,monkey ,n))
|
||||||
|
(format "(define (~a) ~a)" monkey n)]
|
||||||
|
[(pregexp "(\\w+): (\\w+) (\\+|-|\\*|/) (\\w+)" `(,_ ,monkey ,monkey1 ,op ,monkey2))
|
||||||
|
(format "(define (~a) (~a (~a) (~a)))" monkey op monkey1 monkey2)]))])
|
||||||
|
(display-lines-to-file
|
||||||
|
`(,"#lang rosette/safe" ,@bindings "(evaluate humn (solve (root)))")
|
||||||
|
"21-part2.rkt" #:exists 'replace))
|
Loading…
Reference in New Issue