123456789101112131415161718192021222324252627282930313233343536373839404142 |
- (import
- (except (rnrs base) let-values map)
- (only (guile)
- lambda* λ
- string-split
- string-count
- string-every
- string-append
- list->string)
- (fileio)
- ;; (srfi srfi-1)
- ;; (srfi srfi-8)
- ;; (srfi srfi-11)
- (ice-9 pretty-print)
- (ice-9 match))
- (define lines (get-lines-from-file "input"))
- (define input (car lines))
- (define unique-chars?
- (λ (str)
- (string-every (λ (c) (= (string-count str c) 1))
- str)))
- (define buffer-len 4)
- (let iter ([pos 0] [input° input])
- (cond
- [(string-null? input°)
- 'done]
- [else
- (let ([part (substring input° 0 buffer-len)])
- (cond
- [(unique-chars? part)
- (pretty-print part)
- (pretty-print input°)
- (+ pos buffer-len)]
- [else
- (iter (+ pos 1)
- (substring input° 1))]))]))
|