Wordle comparison: Difference between revisions
Content added Content deleted
(→{{header|Picat}}: Moving 2nd presentation to wordle predicate) |
|||
Line 732: | Line 732: | ||
["ROSETTA", "OSSETAR"]], |
["ROSETTA", "OSSETAR"]], |
||
foreach([Answer,Guess] in Pairs) |
foreach([Answer,Guess] in Pairs) |
||
Res = wordle(Answer,Guess), |
[Pres,Res] = wordle(Answer,Guess), |
||
Len = Res.len, |
Len = Res.len, |
||
⚫ | |||
Show = new_list(Len), |
|||
foreach(I in 1..Len) |
|||
if Res[I] == green then |
|||
⚫ | |||
elseif Res[I] == yellow then |
|||
⚫ | |||
else |
|||
Show[I] := [to_lowercase(Guess[I])] ++ " " |
|||
end |
|||
end, |
|||
⚫ | |||
end, |
end, |
||
nl. |
nl. |
||
wordle(Answer,Guess) = Result => |
wordle(Answer,Guess) = [Presentation,Result => |
||
N = Guess.len, |
N = Guess.len, |
||
⚫ | |||
if N != Answer.len then |
if N != Answer.len then |
||
print("The words must be of the same length.") |
print("The words must be of the same length.") |
||
else |
else |
||
⚫ | |||
Result = new_list(N,grey), % grey by default |
Result = new_list(N,grey), % grey by default |
||
Presentation = copy_term(Guess).map(to_lowercase), |
|||
foreach(I in 1..N, Guess[I] == Answer2[I]) |
foreach(I in 1..N, Guess[I] == Answer2[I]) |
||
Answer2[I] := "", |
Answer2[I] := "", |
||
Result[I] := green |
Result[I] := green, |
||
⚫ | |||
end, |
end, |
||
foreach(I in 1..N, Ix = find_first_of(Answer2,Guess[I]), Ix > 0) |
foreach(I in 1..N, Ix = find_first_of(Answer2,Guess[I]), Ix > 0) |
||
Answer2[Ix] := "", |
Answer2[Ix] := "", |
||
Result[I] := yellow |
Result[I] := yellow, |
||
⚫ | |||
end |
end |
||
end.</lang> |
end.</lang> |
||
Line 773: | Line 766: | ||
ROBBY v OBBYR => [o*,b*,B ,y*,r*] [yellow,yellow,green,yellow,yellow] |
ROBBY v OBBYR => [o*,b*,B ,y*,r*] [yellow,yellow,green,yellow,yellow] |
||
ROSETTA v OSSETAR => [o*,s ,S ,E ,t*,a*,r*] [yellow,grey,green,green,yellow,yellow,yellow]</pre> |
ROSETTA v OSSETAR => [o*,s ,S ,E ,t*,a*,r*] [yellow,grey,green,green,yellow,yellow,yellow]</pre> |
||
=={{header|Python}}== |
=={{header|Python}}== |