- Written in Elixir
- Assume this is part of a bigger project rather than a code kata when it comes to design & code quality
- Provides a HTTP Rest or GraphQL API
- Outputs JSON
- No auth necessary
- Should not rely on a database
- Does not require state persistence between restarts
The API should provide the following functionality:
Ability to accept an arbitrary number of digits which should be appended to any previously received digits to form a long number.
Ability to clear the previously received list of digits
Calculates a checksum given the current state and returns it
BONUS - For bonus points return a timeout response if checksum can't be calculated in less than 15ms
- Add up the digits in odd positions and multiply by 3
- Add up the digits in even positions
- Add up the results of 1 and 2
- Divide by 10 and take the remainder.
- If the remainder is 0 final result is 0 otherwise subtract it from 10 for final result
5 4 8 9 8 5 0 3 5 4
- 5 + 8 + 8 + 0 + 5 = 26 * 3 = 78
- 4 + 9 + 5 + 3 + 4 = 25
- 78 + 25 = 103
- 103 / 10 = 10.3 = 3
- 10 - 3 = 7