Help with word unscramble bot



Then you don’t have a single solution. ABT could spell either tab or bat so you’d have to add a randomized element or the code would always pick one or the other.

Is that part of what your code should do?


Since I don’t understand what you’re intending with all the conditional blocks, I can’t really help you fix it (but if you explain it, it’ll try)

That said, I think I can suggest a simpler method if you’re interested?


Yeah I’ll go with your way and give credit


To start with, are you familiar with binary? That is, how 10011 translates to 19 (1+2+0+0+16)?

Do you see how this concept could be used to translate a series of letters (i.e., values 1 to 26) into a single unique integer?


No but I know morse code (kinda)


Ok, no problem. I can explain. May I ask what grade you’re in (so I don’t explain too simply or skip too much)? If you prefer not to say, that’s fine!



Edit: should I mention I’m home schooled


My oldest son is in 5th :smile:

In binary, each digit from right to left doubles in value. 1,2,4,8,16,32… if the binary number has a 1 in the position of a number you add it to the total, if not you skip it.

111 is 4 + 2 + 1
101 is 4 + 0 + 1
10011 is 16 + 0 + 0 + 2 + 1

Does that make sense?


A little bit? @ThinBuffalo


Sorry, trying to figure out how to explain this…

There’s 2 options of each digit in binary (0 or 1) which contribute to summation which equals the decimal number.

Each digit is subsequently “worth more”. 1, 2, 4, 8, etc. So the value that’s summed is (0 or 1) x 2 ^ (digit’s place (right to left))

1x2^0, 1x2^1, 1x2^2, 1x2^3
1x1, 1x2, 1x2x2, 1x2x2x2
1, 2, 4, 8

We can use the same idea but instead of 2 options, there’s 27 options (1 for each letter of the alphabet, plus 1 for a “blank”)

The pattern explained above is more generally expressed as


Where by we can get a unique value for each word.
B is 27
a is the “value” (1-26) for each letter

FOX would be (switching to left to right)
6x27^0 + 15x27^1 + 24x27^2
6x1 + 15x27 + 24x27x27
6 + 405 + 17496

So for n letters, you can test n! (n factorial) combinations to see if any equal a “word value”. Fox has 3 letters, so we test 3! (1x2x3) or 6 combinations of any 3 given letters to see if any equal 17907

This make any sense? I expect it’s a lot to absorb all at once. I’m sorry, it makes for a much simpler way to determine what word a set of letters make but it’s conceptually difficult.

I’ll make an example project to show you…


Or you can feel to say forget this :sweat_smile:, and I’ll still try to help you sort out the code you have if you’ll explain how it should work…


No offense but I think it’ll just be easier to have my uncle teach me. I’ll still give you credit for the idea tho

Edit/ actually lemme just try normal code first idk


No offense taken. It’s hard to explain new/difficult concepts over a forum. And you chose a project that isn’t particularly easy :wink:


Well it seemed easy.

Btw this was the original idea and maybe we can work off this:

When you hit the find word button it randomly swaps the letters until it finds a word or fails to find one. @ThinBuffalo


That’d be difficult. Especially in Hopscotch.


Me and @ThinBuffalo are teaming with up to figure out how we could do it. It’s not that hard probably


That is weird, and I think that the code contains a lot of different loops and stuff like that, so can you post a link to the project so I can try fixing it?

I saw that you posted a link now, I will try to fix the project.


It’s pretty hard.

You’d need to code all the letters, and without strings it gets way more complex.

If you do it it’d be really impressive.


@Mr.rex or @William04GamerA Have you made any progress?

I’ve been tinkering with a project to do this but putting together the concepts into a complete project (with a scalable architecture so increasing the number of letters is a simple value change) is more challenging than I anticipated.

Coding strings & words as values wasn’t too hard (if one follows what I explained above). However, iterating through all of the letter permutations isn’t as easy as I thought it would be. I’m currently implementing a Hopscotch version of Heap’s algorithm. Will hopefully be done soon…


I have been trying modifying the current version of the code, but there’s unfortunately no progress there and I have not had that much time to look at the project. I have only tried decoding it in like half an hour, but I think that your solution seems like a good idea.