Skip to content

Instantly share code, notes, and snippets.

@elderica
Created December 7, 2023 12:47
Show Gist options
  • Save elderica/6f9ccd7ab1b6b1ed9baba431c872a493 to your computer and use it in GitHub Desktop.
Save elderica/6f9ccd7ab1b6b1ed9baba431c872a493 to your computer and use it in GitHub Desktop.
ズンドコ問題
#lang racket
(define (take-upto length lst)
(cond
[(<= length 0) null]
[(null? lst) null]
[else (cons (first lst)
(take-upto (sub1 length) (rest lst)))]))
(define (zundoko)
(define (rec history)
(if (equal? history (list 1 0 0 0 0)) ; ドコ ズン ズン ズン ズン
(displayln "キ・ヨ・シ!")
(let ([i (random 2)])
(display (vector-ref (vector "ズン" "ドコ") i))
(rec (take-upto 5 (cons i history))))))
(rec null))
(zundoko)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment