Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (31 sloc) 874 Bytes
% Adjusting passwords
% http://ipsc.ksp.sk/2014/real/problems/a.html
% Picat 0.8 - http://picat-lang.org
import planner.
final((Str, Goal)) =>
Str = Goal.
action((Str, Goal), NewState, Action, Cost) ?=>
append(_, [Action | Str], Goal),
NewState = ([Action | Str], Goal),
Cost = 1.
action((_, Goal), NewState, Action, Cost) ?=>
NewState = ([], Goal),
Action = '*',
Cost = 1.
action(([_|Str], Goal), NewState, Action, Cost) ?=>
NewState = (Str, Goal),
Action = '<',
Cost = 1.
do_case(Goal, Was) =>
RGoal = reverse(Goal),
RWas = reverse(Was),
best_plan((RWas, RGoal), length(Goal) + 1, Plan, _Cost),
printf("%s*\n", Plan).
main =>
T = read_int(),
foreach(_Case_num in 1..T)
_ = read_line(),
Goal = read_line(),
Was = read_line(),
do_case(Goal, Was)
end.