Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Need help with making a script that checks if a number has multiple of the same number in it.
- 3X0M7T
-
Scratcher
7 posts
Need help with making a script that checks if a number has multiple of the same number in it.
I am making a game where you guess a randomly generated number. I need help with developing a script that checks if a number is repeated as a hint for the players. Game is https://scratch.mit.edu/projects/758972768/ for more context!
- deck26
-
Scratcher
1000+ posts
Need help with making a script that checks if a number has multiple of the same number in it.
Make a copy of the variable in a list - one item per digit. Now set a variable to the first item and delete it. Check if the list still contains the variable - if it does you have a repeated digit. If it doesn't repeat until you've checked the second last digit as a possible repeater.
- 3X0M7T
-
Scratcher
7 posts
Need help with making a script that checks if a number has multiple of the same number in it.
i'm not understanding 

- deck26
-
Scratcher
1000+ posts
Need help with making a script that checks if a number has multiple of the same number in it.
If you have 6234257 you expand that into a list containing 6, 2, 3 etc as separate items. Copy the first item (6) into a variable and delete item 1 of the list. Now if the list still contains that value you know there was a repeat. If not check the new first item in the list in the same way. Repeat until you find a match or run out of things to check.
- Oumuamua
-
Scratcher
1000+ posts
Need help with making a script that checks if a number has multiple of the same number in it.
Use this to split your number into a list one digit per item


- Discussion Forums
- » Help with Scripts
-
» Need help with making a script that checks if a number has multiple of the same number in it.



