Paste: liars liars! puzzle in facebook
Author: | Alfredo Beaumont |
Mode: | factor |
Date: | Sun, 12 Dec 2010 20:47:37 |
Plain Text |
USING: io io.files io.encodings.utf8 kernel command-line ascii sequences
splitting assocs sets math math.parser formatting locals ;
H{ } clone
(command-line) second utf8 [
readln string>number [
readln " " split [ empty? not ] filter first2 string>number [
readln 2over swap push-at
] times drop
] times
] with-file-reader
[let V{ } clone :> liars! V{ } clone :> nonliars!
[
2dup [ liars member? ] dip nonliars intersect empty? not or [
nonliars append nonliars! liars swap suffix liars!
] [
liars append liars! nonliars swap suffix nonliars!
] if
] assoc-each liars nonliars [ members length ] bi@ 2dup > [
swap
] unless "%d %d\n" printf
]
New Annotation