Skip to content

Instantly share code, notes, and snippets.

@tilpner
Created December 1, 2017 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilpner/5231d3b065cc2fdce97b6784c6eebdea to your computer and use it in GitHub Desktop.
Save tilpner/5231d3b065cc2fdce97b6784c6eebdea to your computer and use it in GitHub Desktop.
#lang racket
(define input (map (compose1 string->number string)
(string->list (read-line))))
(define (solve input [offset 1])
(for/sum ([a input]
[b (sequence-tail (in-cycle input) offset)]
#:when (= a b)) b))
(solve input)
(solve input (/ (length input) 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment