language: Prolog (swi) (swipl 5.6.64)
date: 125 days 0 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
% Author:
% Date: 1/17/2012
word([m,a,n]).
word([w,o,m,a,n]).
word([h,e,l,l,o]).
 
correct(A,B):-word(X),oneletter(X,A,B).
 
oneletter([],[],[]).
oneletter([A|B],[C|D],[X|T]):-A\=C,X=A,oneletteroh(B,D,T).
oneletter([A|B],[C|D],[X|T]):-A==C,X=A,oneletter(B,D,T).
 
oneletteroh([],[],[]).
oneletteroh([A|B],[C|D],[X|T]):-A==C,X=A,oneletteroh(B,D,T).
 
twist([A|B],[C|D],[X|T]):-A\=C,X=A,twisttwo(B,D,T,C).
twist([A|B],[C|D],[X|T]):-A==C,X=A,twist(B,D,T).
 
twisttwo([],[],[]).
twisttwo([A|B],[C|D],[X|T],F):-A==C,X=A,twisttwo(B,D,T,F).
twisttwo([A|B],[C|D],[X|T],F):-A\=C,X=A,C==F,oneletteroh(B,D,T).
  • upload with new input
  • result: Success     time: 0.02s    memory: 6204 kB     returned value: 0