필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

manipulating strings and cell arrays

조회 수: 2 (최근 30일)
James Connor
James Connor 2015년 11월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
I'm trying to create a simplified hangman game I'm just having trouble with this part of the code.
word_needed_to_be_guessed='sharper'
Dictionary=
'shape'
'shorten'
'sharper'
'sharpening'
'sit'
'operate'
'kind'
I want to write some sort of for loop that considers the position of the guessed letters and if they are in the Dictionary words. For example say my first guess is s (considering the correct word for the hangman is 'sharper') get rid of 'operate' and 'kind' because they s is correct only for the first letter of the dictionary words. Say my second guess was h. This would keep all the dictionary words because they have the letter h as their second letter. Now if my third guess was p it would get rid of shorten because its not correct for the 5th letter of the word. Now if my final guess was say a r it would get rid of the shape and sharpening because it is not true for the 7th position of the word. This would just leave Dictionary ='sharper' I hope this made sense and help would be appreciated.
  댓글 수: 1
Jan
Jan 2015년 11월 8일
편집: Jan 2015년 11월 8일
What have you tried so far? Is this a homework question? If so, how can we help you beside posting a solution?

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by