+ 10
[CHALLENGE] Write a program which will print out a Pascal triangle
I've found this interesting challenge online, so I want to share it with you :) . In Pascal's triangle, each number is the sum of the two numbers directly above it. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 You can read about the Pascal triangle on Wikipedia: https://en.m.wikipedia.org/wiki/Pascal's_triangle Good luck all :)
10 Respuestas
+ 5
Found a new challenge, Make it a assignment.
https://www.sololearn.com/discuss/1082512/?ref=app
+ 5
Mine:
https://code.sololearn.com/cOn4XSTlg8Db/#py
I think this challenge would be easily accepted in lesson factory :)
+ 4
Here's a solution in Haskell:
import Control.Monad
import Data.List
main = mapM_ print $ take 10 xss where
xss = iterate f []
sum = ap (zipWith (+)) tail
f xs = (1 : sum xs) ++ [1]
https://tio.run/##LYy7CoNAFET7/YopUiiCxDZglZSxthAJF7LixX2xe0MkP7/ZSKabM4@V0qaNyZlt8FFw9U6iN@3gHT3VH95IqL1zEqUssUMPS2F4IER2ghOENo3ujD0lvFcdtULRz/Vg0ZFEY8E0Hzi9bMEUUH04jCwrqqauywebI1/KsBSqDpeju6caTYOpm3P@Ag
+ 3
https://code.sololearn.com/c61wEND4rz5C/?ref=app
+ 2
https://code.sololearn.com/c0q5FK2hn4rV/?ref=app
+ 2
solution with 2d array
https://code.sololearn.com/c5IyGP7ykmRV/?ref=app
+ 2
Cool idea!
+ 1