Jump to content

Wordle comparison: Difference between revisions

m
J: some explanation
m (J: some explanation)
Line 175:
assert 0 2 1 2 0-: 'robin' wrdcmp 'sonic'
assert 2 2 2 2 2-: 'robin' wrdcmp 'robin'</lang>
 
Explanation:
 
<tt><nowiki><I.x=y</nowiki></tt> is a box containing the list of exact match indices, and <tt><nowiki>(<@I.y=/~x#~y~:x)</nowiki></tt> is a list of boxes (for each character) of the indices of non-exact matches. Meanwhile <tt><nowiki>({.~1<.#)</nowiki></tt> means "at most one" and operates on lists (so it's empty for an empty list and the first element for a non-empty list).
 
In other words, we build a list of candidate matches for each character and then, for each character, exclude any already picked index and if there's a remaining candidate, we pick that index.
 
(exact match indices will override inexact match indices, which makes the inexact match index calculation simpler -- we don't have to use a separate type for exact match indices.)
 
Task example:
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.