Implement a function pattern, which returns the following pattern for up to n number of rows. If n < 1 then it should return " " i.e. empty stri...
For further actions, you may consider blocking this person and/or reporting abuse
Haskell
I'm writing this on my phone, so there are probably errors, I'll check it when I have access to a compiler.
Edit: fixed issues after running it through a compiler.
I do a lot of these challgnes on my phone. I use rextester.com/l/haskell_online_com... to test my Haskell code a lot.
Thanks for the tip!
Elixir
I based my solution on the examples, rather than the explanation.
Python solution 🐍
No new-line at the end.
C++
Java, with the assumption that the function is actually taking an integer, not a float.
Here is a recursive approach using Python
One liner for the above
Python one-liner
Python
def pattern(num):
for i in range(num,0,-1):
print(''.join([str(x) for x in range(num,(num-i),-1)]))
Ruby