26 lines
737 B
Racket
26 lines
737 B
Racket
|
#lang racket
|
||
|
|
||
|
;; utilities for every challenge script
|
||
|
|
||
|
(require "aoc-lib.rkt")
|
||
|
(provide answer dbg)
|
||
|
|
||
|
;; in-expression debug print, uwu
|
||
|
(define (dbg x)
|
||
|
(pretty-write x)
|
||
|
x)
|
||
|
|
||
|
;; submit a solution to the server if not already submitted
|
||
|
(define (answer day part answer)
|
||
|
(printf "answer ~a.~a: ~s\n" day part answer)
|
||
|
(unless (aoc-complete? day part)
|
||
|
(printf "submit? [Y/n]: ")
|
||
|
(match (string-downcase (string-trim (read-line)))
|
||
|
[(or "" "y" "yes")
|
||
|
(printf "submitting...\n")
|
||
|
(define resp
|
||
|
(aoc-submit-answer (getenv "AOC_YEAR") (~a day) (getenv "AOC_SESSION") (~a part)
|
||
|
(~a answer)))
|
||
|
(printf "server responded: ~a\n" resp)]
|
||
|
[_ (printf "not submitting\n")])))
|