Red and green towers - MATLAB Cody - MATLAB Central

Problem 43179. Red and green towers

Difficulty:Rate

Frankie has a large number of wooden cubes, painted in red and green. He is building little towers with his cubes, by stacking them on top of each other.

He got bored after a while, so he introduced a rule: two red cubes may not be touching (see image).

Given n (the maximum number of cubes in a tower), determine the number m of different towers that Frankie can build.

Example: for n = 2, he can make 5 towers, so m=5:

  1. [Red];
  2. [Green];
  3. [Red, Green];
  4. [Green, Red];
  5. [Green, Green].

You may assume that the input is an integer greater than zero.

Solution Stats

86.11% Correct | 13.89% Incorrect
Last Solution submitted on Jun 06, 2024

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
2
4
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers23

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page