All problems
Strobogrammatic Number Count
Problem
Count the strobogrammatic numbers of length n, which read the same when rotated 180 degrees and have no leading zero unless the number is a single digit.
Recursively wrap an inner strobogrammatic string with each valid outer pair, then discard results with a leading zero when n is greater than 1. Assume n >= 1.
Hint
Even lengths always lose exactly the counts whose outermost pair is zero.
Test cases
case 1
in: [1]
expected: 3
case 2
in: [2]
expected: 4
case 3
in: [3]
expected: 12
case 4
in: [4]
expected: 20
case 5
in: [5]
expected: 60
Starter codePython
def strobogrammatic_count(n):
# Your code here
pass5 test cases · run your code against them in the editor