Word Rank [Code Coach]
For those who have solved this problem, what was your approach to the problem? I’m not looking for the solution in code but rather just the thought process behind approaching and solving the problem. This so far has been the only challenge I haven’t been able to finish in Python. I’ve tried a few different approaches but they either didn’t work because I wasn’t successful in it or it was a flawed solution that only worked with single cases. First I tried to just letter swap until I generated every possible word then index it. This became a ridiculous feet when you got to large words like SOLOLEARN. Second I tried to index each letter to make it similar to binary treating something like "ABAB" as 0101 and comparing it to it’s alphabetical counterpart "AABB" as 0011. This in theory worked for two letters since subtracting them would give me 0100 aka 2. But going more complex I couldn’t wrap my head around it. Third I tried looking at what my expected output should be my examining HELLO, I wrote down each outcome in a notepad: -HELLO Sort alphabetically 1.EHLLO 2.EHLOL 3.EHOLL 4.ELHLO 5.ELHOL 6.ELLOH 7.ELLHO 8.ELOLH 9.ELLHO 10.EOLLH 11.EOLHL 12.EOHLL 13.HELLO By looking at it I thought I could do something like: for each character in the word: for the number of remaining characters: create every word from the possible remaining letters. add that new word to an array index the solution and return it. On paper it looked fine but I realized that I’m just getting rid of the first character and then running into the same problem of generating every possibility of that word. Which I haven’t been able to wrap my head around just yet. For those who might ask for my code for reference, I scrapped each attempt after they didn’t work so I don’t have any versions saved of my old attempts. Apologizes ahead of time.