+ 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.

30th Jul 2017, 12:01 PM
László Ozsvárt
László Ozsvárt - avatar
3 Respuestas
+ 9
I have an uncontrollable addiction to challenges like this. My try (advanced task): https://code.sololearn.com/W23y1yVnq7zG/?ref=app
30th Jul 2017, 4:03 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 9
Taking challenge
30th Jul 2017, 2:31 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
@$Vengat What language are you taking?
30th Jul 2017, 11:23 AM
J.G.
J.G. - avatar