-(* 0: 7
+(* 0: 7 4
1: 29 6
2: 120 10
3: > 327 >9
- 4: ???
+ 4: > 657 >9
+ 5: > 526 >8
+ 6: > 529 >8
+ 7:
*)
type t = M | I | C
function
[],w -> w
| x::lhs,x'::w when x = x' -> aux (lhs,w)
- | _,_ -> raise NoMatch
- in
- rhs @@ apply_rules (aux (lhs,w),new_dir dir lhs)
+ | _,_ -> raise NoMatch in
+ let w' = aux (lhs,w) in
+ if List.length rhs < List.length lhs then rhs @@ [w']
+ else rhs @@ apply_rules (aux (lhs,w),new_dir dir lhs)
and apply_rules (w,_ as w_and_dir) =
if w = [] then [[]]
else
(List.map
(function w ->
List.map (fun x -> x@w)
- (if List.length (List.filter (fun w -> w = M) w) >= 3 then
- [[I];[C];[]]
+ (if List.length (List.filter (fun w -> w = M) w) >= 7 then
+ [[I];[C]]
else
- [[I];[C];[M];[]])
+ [[I];[C];[M]])
) l))
;;
print_endline ("/////");
;;
-let rec iter n l =
+let rec iter n nodes old_arcs =
print_endline ("STEP " ^ string_of_int n);
- let pkg = classify (normalize l) in
+ let arcs = old_arcs @ normalize nodes in
+ let pkg = classify arcs in
if n > 0 then
- iter (n - 1) (step l)
+ iter (n - 1) (step nodes) arcs
else
analyze pkg
in
- iter 15 [[]]
+ iter 8 [[]] []
;;