blob: 448a10efceff79e780b92e3b2daccd13c76d01ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#lang racket
(define line
(call-with-input-file "input"
(λ (fp) (read-line fp))))
(define strs (string-split line ","))
(define (calc-hash str)
(define len (string-length str))
(let loop ((i 0) (cur 0))
(if (< i len)
(let ()
(define c (string-ref str i))
(define ascii (char->integer c))
(loop (+ i 1) (modulo (* 17 (+ cur ascii)) 256)))
cur)))
(apply + (map calc-hash strs))
|