digits. Each row above is one cell shorter: the cell sitting on two neighbours gets the last digit of their sum, that is (a + b) % 10.
Rows keep being built until a single cell is left. Return the digit at the top of the pyramid.digits=[3, 8, 6] → 5
The second row is (3 + 8) % 10 = 1 and (8 + 6) % 10 = 4. The top is (1 + 4) % 10 = 5.
digits=[9, 9, 9, 9] → 2
The rows go [8, 8, 8], then [6, 6], then [2], so the top is 2.
digits=[7] → 7
A single digit is already the top.
digits=[3, 8, 6]
5
Run checks the first 3 tests in your browser. Submit checks all 95 tests on the server, hidden ones included.