#lang racket (define input (with-input-from-file "input" (λ () (let loop ((cards '())) (define line (read-line)) (if (or (eof-object? line) (= 0 (string-length line))) (reverse cards) (let () (define splited-line (string-split line)) (define hand (car splited-line)) (define bid (string->number (cadr splited-line))) (loop (cons (list hand bid) cards)))))))) (define (card-number char) (cond ((eq? char #\A) 12) ((eq? char #\K) 11) ((eq? char #\Q) 10) ((eq? char #\J) 9) ((eq? char #\T) 8) (else (- (string->number (make-string 1 char)) 2)))) (define (hand-type hand) (define vec (make-vector 13 0)) (let loop ((i 0)) (if (>= i 5) (vector->list (vector-sort vec >)) (let () (define index (card-number (string-ref hand i))) (vector-set! vec index (+ 1 (vector-ref vec index))) (loop (+ i 1)))))) (define (hand-typelist hand1))) (define h2 (map card-number (string->list hand2))) (hand-type