Bird
0
0
LLDsystem_design~10 mins

Player turn management in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the current player index.

LLD
current_player_index = [1]
Drag options to blanks, or click blank then click option'
A0
B-1
C1
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Starting the index at 1 instead of 0.
Using None which is not an integer index.
2fill in blank
medium

Complete the code to move to the next player in a circular manner.

LLD
current_player_index = (current_player_index [1] 1) % total_players
Drag options to blanks, or click blank then click option'
A-
B//
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction which moves backward.
Using multiplication or floor division which do not cycle properly.
3fill in blank
hard

Fix the error in the code to correctly check if it is the last player's turn.

LLD
if current_player_index == [1] - 1:
    print("Last player's turn")
Drag options to blanks, or click blank then click option'
Acurrent_player_index
Btotal_players
C1
Dplayers_count
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing to current_player_index - 1 which is always false.
Using 1 which is just the second player index.
4fill in blank
hard

Fill both blanks to create a function that returns the next player index given the current index and total players.

LLD
def get_next_player(current_index, total_players):
    return (current_index [1] 1) [2] total_players
Drag options to blanks, or click blank then click option'
A+
B-
C%
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction which moves backward.
Using floor division which does not cycle properly.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each player to their turn number starting from 1.

LLD
turns = {player: index [1] 1 for index, player in enumerate(players) if index [2] total_players - 1 and player != [3]
Drag options to blanks, or click blank then click option'
A+
B<
CNone
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition for turn numbers.
Using greater than or equal instead of less than.
Checking player against a wrong value instead of None.