Submission #158861


Source Code Expand

Copy
let id x = x

let (|>) x f = f x

let repeat f =
  let rec loop acc = function
    | 0 -> List.rev acc
    | n -> loop (f () :: acc) (n - 1) in
  loop []

let input =
  repeat
    (fun () -> Scanf.scanf "%d %d %d %d\n"
      (fun a b c d -> [a; b; c; d])) 4

let rec yoko_check = function
  | x::[] -> `End
  | x::y::xs ->
    if x = y
    then `Continue
    else yoko_check (y::xs)

let rec tate_check = function
  | (a::la)::(b::lb)::(c::lc)::(d::ld)::[] ->
    if a = b or b = c or c = d
    then `Continue
    else tate_check [la; lb; lc; ld]
  | []::[]::[]::[]::[] -> `End

let main () =
  let yoko = List.map yoko_check input
             |> List.filter (function
               | `Continue -> true
               | `End -> false)
             |> (fun x -> if x = []
                          then `End
                          else `Continue) in
  let tate = tate_check input in
  if yoko = `Continue or tate = `Continue
  then Printf.printf "CONTINUE\n"
  else Printf.printf "GAMEOVER\n"

let () = main ()

Submission Info

Submission Time
Task A - DEAD END
User no_maddo
Language OCaml (3.12.1)
Score 100
Code Size 1058 Byte
Status
Exec Time 31 ms
Memory 1212 KB

Compile Error

File "./Main.ml", line 16, characters 21-128:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
File "./Main.ml", line 23, characters 21-198:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]

Test Cases

Set Name Score / Max Score Test Cases
All 100 / 100 hand_1.txt, hand_2.txt, random_1.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_2.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_3.txt, random_30.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt
Case Name Status Exec Time Memory
hand_1.txt 31 ms 1212 KB
hand_2.txt 29 ms 1148 KB
random_1.txt 27 ms 1108 KB
random_10.txt 26 ms 1148 KB
random_11.txt 27 ms 1148 KB
random_12.txt 28 ms 1148 KB
random_13.txt 27 ms 1144 KB
random_14.txt 27 ms 1148 KB
random_15.txt 26 ms 1176 KB
random_16.txt 26 ms 1148 KB
random_17.txt 27 ms 1148 KB
random_18.txt 27 ms 1148 KB
random_19.txt 27 ms 1148 KB
random_2.txt 27 ms 1192 KB
random_20.txt 28 ms 1132 KB
random_21.txt 27 ms 1176 KB
random_22.txt 26 ms 1148 KB
random_23.txt 27 ms 1148 KB
random_24.txt 27 ms 1168 KB
random_25.txt 29 ms 1144 KB
random_26.txt 27 ms 1188 KB
random_27.txt 28 ms 1148 KB
random_28.txt 28 ms 1172 KB
random_29.txt 26 ms 1148 KB
random_3.txt 26 ms 1148 KB
random_30.txt 26 ms 1144 KB
random_4.txt 26 ms 1148 KB
random_5.txt 26 ms 1112 KB
random_6.txt 27 ms 1148 KB
random_7.txt 26 ms 1176 KB
random_8.txt 27 ms 1148 KB
random_9.txt 28 ms 1148 KB
sample_1.txt 27 ms 1148 KB
sample_2.txt 28 ms 1144 KB
sample_3.txt 27 ms 1144 KB