Archived

This topic is now archived and is closed to further replies.

words in C#

This topic is 5004 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have a complicated question that I am stuck on in C#. I have been attempting to fix this but no good. So I’ll explain best I possibly can: I have a string say String one = “drmeaer” String two = “daydreamer” What I want to do is when you press a button called arrange then it will produce an output of: ???dreamer //notice that the ??? are for day. How would I do that? I really am stuck the strings maybe different as well each time. Does anybody have any solutions? Thank You, Rob

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
do you want the words to be chosen randomly

Share this post


Link to post
Share on other sites
string2 is subject to change so yeah string2 is completely random. string1 is where you guess random letters that are in the word. They are defintley in the word so you won''t get for daydream the word u or v or anyother word which is in daydreamer. All I really want to do is spell the word out if you have the letters else put a ? mark there.

Share this post


Link to post
Share on other sites
How do you know which letter to reveal if there are multiple matches? Why is the output ???dreamer and not d???reamer or da??re?mer?

Share this post


Link to post
Share on other sites
yes guys sorryt. I should have released yes you do get two d''s it will look like this

d??dreamer. Sorry that was my bad maths. So any soloutions then? Its really anyoing me now

Share this post


Link to post
Share on other sites

Initialize string three: ""
For a: each char in string two
Initialize flag: false
For b: each char in string one
If char a of string two == char b of string one
flag = true
If flag
append char a of string two to string three
else
append "?" to string three
Output string three


Conversion to C# is left as an exercise for the reader. There are also plenty of possible optimizations I''m sure.

Share this post


Link to post
Share on other sites