+ 5
Coding Challenge :: Color the building
We have a building of N floors (let's say that they are numbered from 0 to n-1). We want to color each floor with the color red or blue. But since the building's owner prefers the color blue, he doesn't want to have two red floors next to each other. Basic task: Given an integer N up to 10, determine the number of the colorings that are good for the owner. Advanced task: List all these colorings. Example colorings (N = 5 in all cases): Blue, Blue, Blue, Blue, Blue -- it's a good coloring Red, Blue, Red, Blue, Red -- it's a good coloring, too Red, Red, Blue, Blue, Blue -- it's not good, since Floor 0 and Floor 1 are both red and they are next to each other.
3 Antworten
+ 9
I have an uncontrollable addiction to challenges like this. My try (advanced task):
https://code.sololearn.com/W23y1yVnq7zG/?ref=app
+ 9
Taking challenge
+ 5
@$Vengat What language are you taking?