coastaltiger39 said:I need some help here!
I'm trying to compare two words to see how many matching letters they share.
Here’s what I mean:
apple, egg = 2 (e, p)
apple, butter = 2 (p, e)
potato, bread = 3 (p, t, o)
Basically, you build a boolean matrix for tracking usage, sized to the number of letters in the first word.
Then you run a loop through every letter of the second word.
Inside that, you run another loop through all the letters of the first word.
If the current letter from the second word matches one from the first, and that spot in the first word hasn't been "used" yet...
Mark that position in the first word as used.
Add the matching letter to a list.
Break out of the inner loop.
Once the outer loop finishes, just count up how many—and which ones—were found.
--
This logic should mirror the task requirements and match those example solutions.