Tiling ribbon: Threshold file
Inputs
readings is a list of integers (numbers with no decimal part). It may be empty, and numbers may repeat unless task 1 says otherwise.
Your tasks
- Create a list
tilingCounts. Each number x inreadingsis the width of a one-row strip. Fill it exactly using pieces of width 1 or 3. Count the different orders of pieces that work. For width 4, the orders are [1,1,1,1], [1,3], and [3,1], so the count is 3. Width 0 has one way: use no pieces. Record one count per input width, in order. - Count the numbers in
tilingCountsthat are at leastk(greater than or equal tok). Store the count inatLeastK. - Complete
tilingRibbonThresholdFileso it returnsatLeastK. Return it, do not print it.
Example
If readings is [7, 11, 3, 7, 4] and k is 2, then tilingCounts is [9, 41, 2, 9, 3] and tilingRibbonThresholdFile returns 5.
Rules
- If
tilingCountsis empty, the count is 0. k(a whole number from 1 to 8) is the threshold in task 2: compare each number with it.
Test data
TEST DATA 1: readings is [9, 0, 1, 16, 9] and k is 2.
TEST DATA 2: readings is [5, 7, 5, 5] and k is 6.
Examples
Input: readings = [9,0,1,16,9] k = 2 Output: 3
tilingCounts is [19, 1, 1, 277, 19]. Here k is 2. The numbers at least 2 are [19, 277, 19]. There are 3, so return 3.
Input: readings = [5,7,5,5] k = 6 Output: 1
tilingCounts is [4, 9, 4, 4]. Here k is 6. The numbers at least 6 are [9]. There are 1, so return 1.
Input: readings = [] k = 5 Output: 0
tilingCounts is []. Here k is 5. The numbers at least 5 are []. There are 0, so return 0.
Input limits
- 0 <= input size <= 64.
- k is a whole number from 1 to 8. Answers fit in a signed 32-bit integer: -2,147,483,648 through 2,147,483,647.
- Input numbers are whole numbers from 0 through 20.
Efficiency goal
Big-O describes how the work or memory needed grows as the input gets larger.
Efficiency goal: time O(n + M); extra memory, including the helper list, O(n). n is the input length; M is the largest input number. These labels describe how work and memory grow with the input.
Practice focus
Build tilingCounts first, then return exactly what the tasks ask for. Follow the order, keep repeated values when the rule says so, and check the empty case.