Hang in there. I wrote it in 15 lines of code, because I want to practice the actual programming logic, not "code-golfing" to solve it with an extra bit of mathematical knowledge gained from thinking through any possible shortcuts. I use these kattas to become a more logical, practiced programmer. If some want to use it for code-golf with a simple math formula, that's cool. But remember, every minute of practice you put yourself through makes you a better programmer.
I spent time to make a recursive function, try to rebuild the triangle and try many solutions. Then, suddenly I think:"wtf am i doing?", and then i wrote the solution in 6 lines :v but when i looked at the best solution, i wanted to give up progamming immediately
Hang in there. I wrote it in 15 lines of code, because I want to practice the actual programming logic, not "code-golfing" to solve it with an extra bit of mathematical knowledge gained from thinking through any possible shortcuts. I use these kattas to become a more logical, practiced programmer. If some want to use it for code-golf with a simple math formula, that's cool. But remember, every minute of practice you put yourself through makes you a better programmer.
In most languages you probably couldn't even capture the output if it was printed other than PHP with
ob_start
andob_get_clean
.I think there is no kata where you have to print something.
please edit this to say "return the sum", it is unclear whether you need to return or print it.
I spent time to make a recursive function, try to rebuild the triangle and try many solutions. Then, suddenly I think:"wtf am i doing?", and then i wrote the solution in 6 lines :v but when i looked at the best solution, i wanted to give up progamming immediately
Not a suggestion. Posting solutions is a violation of the CW's CoC.
hmmm
This comment is hidden because it contains spoiler information about the solution