Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
744 views
in Online Assessments by Expert (46,090 points) | 744 views

1 Answer

0 like 0 dislike
***Wordle***
Inspired from the viral word game Wordle, you have to design the backend for a new
game subject to the following rules:
Rules
1. There is a dictionary of words (consisting only of English alphabets) with a total
of X words in the beginning. New words in the dictionary can be added later.
2. Each word in the dictionary is associated with a difficulty level Y, which means
that a player will get Y number of turns to guess the word of the day.
Example of a valid dictionary:
FLY 5
PLAY 5
APPLE 4
ROGUE 6
FLOOD 5
FLIPKART 7
MAPLE 5
3. Whenever a new round of Wordle is started, a new word is randomly selected
from the dictionary and is called ‘Word of the day’.
4. Players can come and register on the Wordle game app. Players can participate
once in each round of the Wordle game.
5. When the player guesses a word, he gets some hints about the letters which are
there in the ‘Word of the day’:
a. C = Correct letter and correct position
b. P = Correct letter and incorrect position (Partially correct)
c. I = Incorrect letter
Eg. Word of the day = APPLE
Player’s guess = MAPLE
Hints given = I P C C C
6. Players can only guess the words which are present in the dictionary and which
have the same number of letters as the Word of the day.
7. After a player makes the guess, the entire list of hints for this round for the player
should be printed.
8. If a player gets the Word of the day correctly, she cannot make further guesses.
9. If a player gets the word correct in a round, she gets a score in that round which
is calculated by:
Score = (Difficulty level of the Word of the day) / (Actual number of
attempts)
If she is unable to get the word correct after Y turns, a score of 0 is given.
10.An all-time score is also maintained for each player, which is a sum of the scores
of the player in individual rounds.
11. At any time, a scorecard can be displayed, which displays the score of all the
players ranked in descending order, apart from 0 scores.
Bonus
1. Implement a hard mode in the game. If this mode is enabled, then the player
must use all the previously revealed hints.
a. Any letters which were correct must be correct in further guesses
b. Any letters which were incorrect must not be present in further guesses
c. Any letters which were partially correct must at least be partially correct in
further guesses.
2. New words do not reflect in the dictionary until a new round is started.
Commands/Requirements
1. REGISTER player
2. ADD_WORD_TO_DICTIONARY word difficulty
3. START_NEW_WORDLE
4. GUESS player word
5. SCORECARD CUR_ROUND / ALL_TIME
Sample Test Cases
// Add a few words in the dictionary
ADD_WORD_TO_DICTIONARY FLY 5
ADD_WORD_TO_DICTIONARY PLAY 5
ADD_WORD_TO_DICTIONARY APPLE 4
ADD_WORD_TO_DICTIONARY ROGUE 6
ADD_WORD_TO_DICTIONARY FLOOD 5
ADD_WORD_TO_DICTIONARY FLIPKART 7
// Register new players
REGISTER Hermione
REGISTER Ron
// Start a new game
START_NEW_WORDLE
// Random word is selected
// Hidden from player = Word -> APPLE
// Below information is revealed to the player
Number of letters = 5
Number of attempts = 4
// Play the game
GUESS Hermione BLOOD
Incorrect word
GUESS Hermione FLOOD
I P I I I
GUESS Hermione APPLE
I P I I I
C C C C C
GUESS Hermione ROGUE
Already played this round.
GUESS Ron FLOOD
I P I I I
GUESS Ron FLOOD
I P I I I
I P I I I
GUESS Ron FLOOD
I P I I I
I P I I I
I P I I I
GUESS Ron FLOOD
I P I I I
I P I I I
I P I I I
I P I I I
GUESS Ron FLOOD
Out of chances
SCORECARD CUR_ROUND
1 - Hermione - Score = 2
START_NEW_WORDLE
// New random word is selected
SCORECARD CUR_ROUND
—--
SCORECARD ALL_TIME
1 - Hermione - Score = 2
Things to take care of
1. Do not use any database or NoSQL store, use in-memory store for now.
2. Do not create any UI for the application.
3. Input can be taken from a terminal, hardcoded in the driver program, from a file
or through unit tests.
4. Write a driver class for demo purposes. Which will execute all the commands at
one place in the code and test cases.
5. Please prioritize code compilation, execution and completion.
6. Please do not access the internet for anything EXCEPT syntax.
7. You are free to use the language of your choice.
8. All work should be your own. If found otherwise, you may be disqualified.
Expectations
1. Code should be demoable (very important)
2. Complete coding within the duration of 90 minutes.
3. Prefer Design over optimization. Better design would be considered better.
4. Code should be modular, with an Object Oriented design. Maintain good
separation of concerns.
5. Code should be extensible. It should be easy to add/remove functionality without
rewriting the entire codebase.
6. Code should handle edge cases properly and fail gracefully.
7. Code should be readable. Follow good coding practices:
7.1. Use intuitive variable names, function names, class names etc.
7.2. Indent code properly.

 

For those appearing for the first time in a MC round.
You will be joining a common meet where the problem statement will be explained to all the candidates appearing for MC round. It will be around 30 mins.

 

An individual meet invite will be sent to you where you will join and present your screen while coding. It will be recorded. You will get 90 mins for coding. At the end you will be uploading your zipped code to a google form.

 

After this a panel will join your meet to evaluate your code.

by Expert (46,090 points)