Embercode
✕
Dynamic ProgrammingQuick quiz

Digit DP

7 questions. Covers Digit DP in Python: counting numbers with a property.

Questions 1 to 5 of 7

  1. 1. Why does the digit DP never store the answer for a state where the tight flag is true?
  2. 2. What does the started flag record?
  3. 3. What does this program print? ``python digits = [int(c) for c in str(121)] print(digits) ``
  4. 4. What does this program print? ``python def good(x): s = str(x) for i in range(1, len(s)): if s[i] == s[i - 1]: return False return True count = 0 for x in range(1, 122): if good(x): count += 1 print(count) ``
  5. 5. For the neighbour rule, a list cache is indexed by position, by prev + 1 (11 values, since prev runs from -1 to 9), and by the started flag (2 values), as Exercise 5 suggests. For N = 3000, which has 4 digits, how many slots does the cache have in total?

    Type a number.

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.