Discuss Scratch

Ironrockisfire
Scratcher
3 posts

Need help with a project

How would I make a line of code that checks if a list matches the same variable as another list? Like if I have a list of letters and I want it to output something if the letters match up with another list of letters even if in a different order?

Last edited by Ironrockisfire (Yesterday 21:11:57)

ClarkeGhost
Scratcher
100+ posts

Need help with a project

You can use a loop to check if the second list contains the items from the first list:

repeat (length of [List A v])
if <[List B v] contains (item (i) of [List A v])> then
change [i v] by (1)
else
say [No match!]
stop [this script v]
end
end
say [Found a match!]

If it finishes the loop without stopping, then they match.
Ironrockisfire
Scratcher
3 posts

Need help with a project

OK

Last edited by Ironrockisfire (Yesterday 23:19:02)

Ironrockisfire
Scratcher
3 posts

Need help with a project

ClarkeGhost wrote:

You can use a loop to check if the second list contains the items from the first list:

repeat (length of [List A v])
if <[List B v] contains (item (i) of [List A v])> then
change [i v] by (1)
else
say [No match!]
stop [this script v]
end
end
say [Found a match!]

If it finishes the loop without stopping, then they match.

@ClarkeGhost Ok, that works thank you

Powered by DjangoBB