Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the first term of the count and say sequence.
DSA Go
sequence := [1]Attempts:
3 left
💡 Hint
Common Mistakes
Using integer 1 instead of string "1".
Starting with "0" instead of "1".
✗ Incorrect
The count and say sequence starts with the string "1" as the first term.
2fill in blank
mediumComplete the code to iterate through the sequence string by index.
DSA Go
for i := 0; i < len(sequence); [1] {
Attempts:
3 left
💡 Hint
Common Mistakes
Using i-- which causes infinite loop.
Incrementing by 2 skips characters.
✗ Incorrect
To iterate through each character, increment the index by 1 each loop.
3fill in blank
hardFix the error in the code to correctly count consecutive characters.
DSA Go
if sequence[i] != sequence[[1]] {
Attempts:
3 left
💡 Hint
Common Mistakes
Using i-1 compares with previous character incorrectly.
Using i compares the character with itself.
✗ Incorrect
We compare the current character with the next one at index i+1 to detect changes.
4fill in blank
hardFill both blanks to build the next term by appending count and character.
DSA Go
nextTerm += strconv.Itoa([1]) + string(sequence[[2]])
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong index variable like j or len(sequence).
Appending count as string without conversion.
✗ Incorrect
We append the count of characters and the character at index i to form the next term.
5fill in blank
hardFill all three blanks to update the sequence and reset count for next iteration.
DSA Go
sequence = [1] count = [2] i = [3]
Attempts:
3 left
💡 Hint
Common Mistakes
Not resetting count to 1.
Not updating sequence with nextTerm.
Incorrectly updating i.
✗ Incorrect
After building nextTerm, assign it to sequence, reset count to 1, and move i to next index.
