# Help with word unscramble bot

#22

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?

#23

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?

#24

Yeah I’ll go with your way and give credit

#25

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?

#26

No but I know morse code (kinda)

#27

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!

#28

4th

Edit: should I mention I’m home schooled

#29

My oldest son is in 5th

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?

#30

A little bit? @ThinBuffalo

#31

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
Is
1x1, 1x2, 1x2x2, 1x2x2x2
Is
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
17907

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…

#32

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

#33

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

#34

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

#35

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

#36

That’d be difficult. Especially in Hopscotch.

#37

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

#38

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.

#39

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.

#40

@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…

#41

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.