|
I've just completed the Word Scramble game, everything seemed to run smoothly however the rootWord (if you don't remember, the word users spell from) does not change from aardvark, which is the first word in the start.tx. I've had a look over the code a number of times, first looking at it logically then repeating the exercise. The code seems right and the start.tx file hasn't been corrupted, but I don't appear to have found a solution. Is anyone able to spot any errors in the code that are causing this issue?
|
|
Hi There, So it's always showing 'aardvark', the first word in start.txt. First thought I had, was that your randomElement statement wasn't working correctly. That looked ok to me. Your line to separate the word list into an array looks correct to me, too. I'd add a print statement after that line, to print out the length of allWords. My guess is allWords just contains the one word, aardvark! If that's the case, and start.txt does indeed contain all the words, does the file actually not contain newlines but contains special characters instead? You can tell by opening up the file in vi, going to escape mode, and typing :set list. |
|
You have a parenthesis in this line just after the n:
Notice after the n there should be nothing:
|
SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.