This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 textual-ports) (srfi srfi-1) (srfi srfi-26) | |
(ice-9 format) (ice-9 match) (ice-9 pretty-print) | |
(srfi srfi-8) (ice-9 arrays)) | |
(define (%map-input-char c) | |
(match c | |
[#\. 0] | |
[#\O 1] | |
[#\# -1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (ice-9 textual-ports) | |
(ice-9 format) (srfi srfi-26) (ice-9 match) | |
(srfi srfi-43)) | |
(define (read-input) | |
(string-split (get-line (current-input-port)) #\,)) | |
(define (hash str) | |
(string-fold | |
(λ (chr prev) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 textual-ports) (srfi srfi-1) (srfi srfi-26) (ice-9 match) | |
(ice-9 format) (ice-9 pretty-print) (srfi srfi-8)) | |
(define (read-lines) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons line (read-lines))))) | |
(define (%read-input lines) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 textual-ports) (srfi srfi-1) (srfi srfi-26) | |
(ice-9 format) (ice-9 match) (ice-9 pretty-print)) | |
(define (%read-input) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons (list->vector (string->list line)) | |
(%read-input))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 textual-ports) (srfi srfi-1) (srfi srfi-26) (ice-9 match) | |
(ice-9 format) (ice-9 pretty-print) (srfi srfi-8)) | |
(define (read-input) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons (string->list line) | |
(read-input))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 textual-ports) (srfi srfi-1) (srfi srfi-26) (ice-9 format)) | |
(define (read-input) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons (map string->number (string-split line #\space)) | |
(read-input))))) | |
(define (list-of-differences lst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (ice-9 textual-ports) (ice-9 peg) | |
(ice-9 format) (ice-9 match) (ice-9 pretty-print)) | |
(define-peg-string-patterns | |
"path <- ('L'/'R')+ NL | |
node <-- name EQ LPAREN name COMMA name RPAREN NL | |
name <-- ([A-Z0-9])+ | |
EQ < ' = ' | |
LPAREN < '(' | |
RPAREN < ')' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 textual-ports) (srfi srfi-1) (ice-9 match) (ice-9 format)) | |
(define (hand-str str) | |
(string-map | |
(λ (chr) | |
(integer->char (+ (char->integer #\a) | |
(string-index "23456789TJQKA" chr)))) | |
str)) | |
(define (process-line line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (ice-9 textual-ports) (ice-9 format) (ice-9 pretty-print)) | |
(define (read-input) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons (map string->number (string-tokenize line char-set:digit)) | |
(read-input))))) | |
(define (count-wins race-pair) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (ice-9 textual-ports) (ice-9 peg) | |
(ice-9 format) (ice-9 match)) | |
(define-peg-string-patterns | |
"seeds <-- SEEDS (number SPC?)+ NL NL | |
type-map <-- type TO type MAP NL range+ NL? | |
range <-- number SPC number SPC number NL | |
type <-- [a-z]+ | |
number <-- [0-9]+ | |
TO < '-to-' |
NewerOlder