It turns out that you need every digit of a number to determine its parity, if it is written in an odd base.
Your programs should take input as a number between 2 and 36 inclusive, and a nonempty string consisting of the base digits 0-9a-z
(letters are lowercase) and a missing/unknown digit, which can be any other character (let's use ?
for this challenge).
Your program should produce consistent, distinct outputs for:
The number is even in the given base, no matter what the missing digits are.
The number is odd in the given base, no matter what the missing digits are.
Ambiguous: the parity of the number cannot be determined, because of missing digits, for example
(10, 123?)
or(15, ???2)
.Syntax error: The number contains digits not allowed in the base, for example a
2
in binary, or a letter in base 10.
Examples:
E = Even
O = Odd
A = Ambiguous
S = Syntax error
10, 123 -> O
15, ee -> E
2, 101 -> O
3, 101 -> E
2, 1?1 -> O
3, 1?1 -> A
25, ?2345 -> A
10, ?????? -> A
10, ??????502 -> E
9, ??????502 -> A
36, ppcg -> E
10, ppcg -> S
5, 5 -> S
4, ??????3 -> O
4, ??????5 -> S
4, ???5???0 --> S
\$\endgroup\$3, ?x? -> S
, to cover the order of evaluation (all existing tests would pass if we check for ambiguity by?
location and base parity and don't then go on to check the digits are within the base's domain). \$\endgroup\$2, ?
is it odd or A? \$\endgroup\$