The online assessment contained two coding tasks.
-
Build a validation string from checksums
You are given:
-
a lowercase string
s
-
a validation string
validation_chars
-
an integer
k
Partition s into consecutive substrings of length k. You may assume s.length is a multiple of k. Assign each character a value using its zero-based alphabet index (a = 0, b = 1, ..., z = 25). For each length-k substring:
-
compute the checksum as the sum of its character values
-
compute
checksum % validation_chars.length
-
use that result as an index into
validation_chars
-
append the selected character to the output
Return the final validation string.
-
Debug feature enablement with dependencies
You are given an existing implementation that reads feature definitions from a text file. Each feature may specify:
-
allowed countries
-
a minimum OS version
-
a list of dependent features
The runtime input includes:
-
a user's country
-
a user's OS version
-
a set of pre-enabled features
-
a set of requested features
A requested feature can be enabled only if:
-
the user's country is allowed for that feature
-
the user's OS version satisfies the feature's minimum version requirement
-
all of its dependencies are enabled, either because they were already pre-enabled or because they can also be validly enabled
-
the dependency graph contains no cycles
The task is to debug and fix the code so that it correctly determines which requested features can be enabled and correctly rejects invalid requests, including cyclic dependencies.