1. Roma Sokolov
  2. kamlostuff

Source

kamlostuff / labirinth.ml

let can_exit path =
  let rec check step_count rest =
    match rest with
      | (h::t) ->
          if step_count > 0 then
            (check (step_count - 1) t) or (check h t)
          else
            false
      | _ -> true
  in
    try
      check (List.hd path) (List.tl path)
    with Failure "hd" | Failure "tl" -> false