Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let id = fun x -> x;;
- let check_item_against_item = fun pin1 pin2 ->
- true (*( List.fold_left2 ( fun prev i1 i2 -> i1 * i2 + prev ) 0 pin1 pin2 ) == 1*)
- ;;
- let rec check_list_against_item = fun pins pin -> match pins with
- | [ ] -> true
- | head :: tail -> check_item_against_item head pin && check_list_against_item tail pin
- ;;
- let rec check_set = fun pins -> match pins with
- | [ ] -> true
- | head :: tail -> check_list_against_item tail head && check_set tail tail
- ;;
- let rec make_list = fun n f -> match n with
- | 0 -> [ ]
- | _ -> [ f( ) ] @ make_list (n-1) f
- ;;
- let _ =
- let n = Scanf.scanf "%d " id in
- let m = Scanf.scanf "%d " id in
- let pins = make_list n (fun _ ->
- make_list m (fun _ ->
- Scanf.scanf "%c" ( function
- 'o' -> 1
- | _ -> 0
- )
- )
- ) in
- check_set pins
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement