結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー aimy
提出日時 2017-09-03 14:18:25
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 339 bytes
コンパイル時間 9,474 ms
コンパイル使用メモリ 172,160 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-06 20:01:55
合計ジャッジ時間 6,632 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.Bool
import Data.List

main = getContents >>= putStrLn . bool "No" "Yes" . pazzle15 . map read . words

pazzle15 ns = null $ snd $ until (\(x,_) -> x==16) move (0, ds)
  where
    ds = filter (uncurry (/=)) $ zip ns [1..16]

move (x,ds) = case find ((==x) . fst) ds of
  Nothing -> (16, ds)
  Just (x,y) -> (y, delete (x,y) ds)
0