Ctrl K

Paving a Garden Path

Easy
A garden path length cells long has to be paved. There are two kinds of tiles: a short one covers a single cell and a long one covers two neighbouring cells. You have as many tiles of each kind as you need. The whole path must be covered with no gaps and no overlaps. Two layouts are different if the sequences of tiles from the start of the path to its end differ: for example, "long, short" and "short, long" are two different layouts. Return the number of different layouts.
Example 1
length=1 → 1

A strip of length 1 can only be covered by a single short tile.

Example 2
length=4 → 5

Five layouts: 1+1+1+1, 2+1+1, 1+2+1, 1+1+2 and 2+2.

Example 3
length=6 → 13
Constraints
  • 1 ≤ length ≤ 45
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSum of the Two Before EasySum of the Last Three EasyEvery Bracketing Result MediumShared Pool Race to a Goal MediumThief and Guard Hard
loading Python…
Input
length=1
Expected
1

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