Guest User

Untitled

a guest
Aug 27th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.51 KB | None | 0 0
  1. let _ =
  2.   let sb = Scanf.Scanning.stdib in
  3.   let n = Scanf.bscanf sb "%d " (fun s -> s) in
  4.   let w = ref 1 in
  5.   let h = ref 1 in
  6.     for i = 1 to n do
  7.       let s = Scanf.bscanf sb "%s " (fun s -> s) in
  8.     match s with
  9.       | "UL" ->
  10.           incr h
  11.       | "UR" ->
  12.           incr w
  13.       | "DL" ->
  14.           incr w
  15.       | "DR" ->
  16.           incr h
  17.       | "ULDR" ->
  18.           incr h;
  19.           incr w;
  20.       | _ -> assert false
  21.     done;
  22.     let res = Int64.mul (Int64.of_int !h) (Int64.of_int !w) in
  23.       Printf.printf "%Ld\n" res
Add Comment
Please, Sign In to add comment