r/dailyprogrammer • • Feb 17 '12

[2/17/2012] Challenge #9 [difficult]

The U.S government has commissioned you to catch the terrorists!

There is a mathematical pyramid with the following pattern:

1

11

21

1211

111221

312211

you must write a program to calculate up to the 40th line of this pyramid. If you don't, the terrorists win!

4 Upvotes

31 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Feb 18 '12

[removed] — view removed comment

1

u/tonygoold Feb 18 '12

For a problem as straightforward as this, I don't think it's surprising to have very similar answers. The only real difference is that I used iterators where you use operator[], and I'll freely admit using iterators in this case just makes my solution more verbose.

One nit to pick: You've declared void main() instead of int main(), which GCC flags as an error.