C
C#•13mo ago
julia

Help a noobie out with a simple hangman

Hi! New to coding and I need some help to solve this problem. Shall I save the words to a list? Any help appreciated. Thanks!
No description
17 Replies
Joschi
Joschi•13mo ago
What did you already do? Do you have a plan or idea how to solve this problem?
julia
juliaOP•13mo ago
This is what I've done so far. Don't have a plan (yet 🥲 )
No description
julia
juliaOP•13mo ago
I figure depending what word Im guessing there is a different outcome
Joschi
Joschi•13mo ago
Maybe you could try splitting that game into multiple simple steps and plan accordingly. Don't worry about how to implement those yet. As an example 1. Define the word to guess 2. Define the alphabet permutation to use 3. ??? You already got the first two steps.
julia
juliaOP•13mo ago
Thanks! I figure I could do a for loop that increments over the attempts, with a maximum of 10 attempts
julia
juliaOP•13mo ago
No description
Joschi
Joschi•13mo ago
That sounds like a good start. The question now would be. What will happen if the letter is in your word and what if it isn't. Then you basically got it.
julia
juliaOP•13mo ago
Thanks, I think I got it! Almost 😄
No description
Joschi
Joschi•13mo ago
Looks great. A string is just a collection of chars. So you can itterate over a string like any other collection. You are already doing that. What you need is a way to check if something is a member of a collection.
julia
juliaOP•13mo ago
Thanks alot!
julia
juliaOP•13mo ago
This is my final result
No description
Joschi
Joschi•13mo ago
Looks like it should work, did you test it? Good job! A few technical points you could maybe improve if you are interested. Your assignment said, that the guessedWord should not be longer than 16 letters. You could check for that. Connected to that. Your ReadLines show warnings. Maybe you could look at those and adress them. Besides this assignment. Maybe you could try generating the permutation of the alphabet yourself instead of having that as an input? I can also think of a more advanced solution to this problem, in which you wouldn't need to iterate over the string. Do you know what a HashSet is? If not don't worry about it for now!
julia
juliaOP•13mo ago
Yes, I did test it and it worked. Thank you for your input, I will look it up later 😄 I do not know what a hashset is I'm on another assignment now and it's far more worse
julia
juliaOP•13mo ago
No description
Joschi
Joschi•13mo ago
Just break it down into simple small steps again and then try to implement them. You got the last one without me having to tell you anything.
ZacharyPatten
ZacharyPatten•13mo ago
Hey I don't have time to read the full context and status of this thread, but I just want to mention that I have an example of a console Hangman game on GitHub if seeing my example may help. If you would like a link to it just ask.
julia
juliaOP•13mo ago
Thank you very much! I got some good help from Joschi. Very kind of you though 😄
Want results from more Discord servers?
Add your server