Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to compute the remainder of 17 divided by 5.
DSA Go
result := 17 [1] 5 fmt.Println(result)
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' instead of modulo operator.
Using '*' which multiplies instead of modulo.
✗ Incorrect
The '%' operator gives the remainder of division, so 17 % 5 equals 2.
2fill in blank
mediumComplete the code to check if a number n is divisible by 3 using modular arithmetic.
DSA Go
if n [1] 3 == 0 { fmt.Println("Divisible by 3") }
Attempts:
3 left
💡 Hint
Common Mistakes
Using '/' which gives quotient, not remainder.
Using '+' or '-' which do not check divisibility.
✗ Incorrect
Using '%' checks the remainder. If n % 3 == 0, n is divisible by 3.
3fill in blank
hardFix the error in the code to correctly compute (a + b) modulo m.
DSA Go
result := (a [1] b) % m
fmt.Println(result)Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which multiplies instead of adds.
Using '/' which divides and causes error.
✗ Incorrect
To add a and b before modulo, use '+'. Multiplying or dividing is incorrect here.
4fill in blank
hardFill both blanks to create a map of numbers to their squares modulo 10 for numbers 1 to 5.
DSA Go
squares := map[int]int{}
for i := 1; i [1] 5; i++ {
squares[i] = (i [2] i) % 10
}
fmt.Println(squares)Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' excludes 5 from the loop.
Using '+' instead of '*' for squaring.
✗ Incorrect
Use '<=' to include 5 in the loop and '*' to multiply i by itself.
5fill in blank
hardFill all three blanks to create a map of uppercase letters to their ASCII codes modulo 26 for letters A to E.
DSA Go
codes := map[rune]int{}
for ch := 'A'; ch [1] 'E'; ch++ {
codes[ch] = (int(ch) [2] int('A')) [3] 26
}
fmt.Println(codes)Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' excludes 'E' from loop.
Using '+' instead of '-' for normalization.
Using '/' instead of '%' for modulo.
✗ Incorrect
Use '<=' to include 'E', subtract 'A' to get zero-based index, then modulo 26.
