House of cards
Description:
You want to build a standard house of cards, but you don't know how many cards you will need. Write a program which will count the minimal number of cards according to the number of floors you want to have. For example, if you want a one floor house, you will need 7 of them (two pairs of two cards on the base floor, one horizontal card and one pair to get the first floor). Here you can see which kind of house of cards I mean:
One floor:
/\
—
/\/\
Four floors:
/\
—
/\/\
— —
/\/\/\
— — —
/\/\/\/\
— — — —
/\/\/\/\/\
(See also http://www.wikihow.com/Build-a-Tower-of-Cards to see what it looks like in real life).
Note about floors:
This kata uses the British numbering system for building floors. If you want your house of cards to have a first floor, it needs a ground floor and then a first floor above that.
Details (Ruby & JavaScript & Python & R)
The input must be an integer greater than 0, for other input raise an error.
Details (Haskell)
The input must be an integer greater than 0, for other input return Nothing
.
Details (COBOL)
The input will be an integer. If it is inferior or equal to 0, return -1
.
Similar Kata:
Stats:
Created | Oct 12, 2014 |
Published | Oct 12, 2014 |
Warriors Trained | 1834 |
Total Skips | 128 |
Total Code Submissions | 8376 |
Total Times Completed | 1041 |
Ruby Completions | 183 |
JavaScript Completions | 417 |
Haskell Completions | 109 |
Python Completions | 345 |
R Completions | 38 |
COBOL Completions | 8 |
Total Stars | 26 |
% of votes with a positive feedback rating | 86% of 167 |
Total "Very Satisfied" Votes | 128 |
Total "Somewhat Satisfied" Votes | 31 |
Total "Not Satisfied" Votes | 8 |