Ctrl K

Top of a Digit Pyramid

Easy
The string digits consists of digits. A pyramid is built from it: each new row is one digit shorter, and each of its digits is the last digit of the sum of two neighboring digits in the row before (that is, the sum modulo 10). Rows are built until a row has exactly two digits. Return True if those two digits are equal, and False otherwise.
Example 1
digits="5146" → False

5146 → 650 (5+1, 1+4, 4+6=10 → 0) → 15. The digits 1 and 5 differ.

Example 2
digits="282" → True

282 → 00 (2+8=10 → 0, 8+2=10 → 0). Both digits are zero.

Constraints
  • 3 ≤ len(digits) ≤ 100
  • digits contains only digits
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsFold Digits Down to a Pair HardSum of Binary Strings EasyFold the Digits Down to One EasyCounting Off by Threes and Fives EasyAdding Long Numbers in Strings Easy
loading Python…
Input
digits="5146"
Expected
False

Run checks the first 3 tests in your browser. Submit checks all 128 tests on the server, hidden ones included.