cancel
Showing results for
Did you mean:

## Challenge 1 - Triangle Font   Moderator

Hi all ! I want to introduce my first challenge – Triangle Font.

I initially solved it in python as I am a bit more confident in that language then I attempted to solve it in q.

Problem 1 – Triangle Font

You are given a positive integer X. Print a numerical triangle of height X - 1 like the one below:

1

22

333

4444

55555

…..

Python Solution:

``````for i in range(1,int(input())):
print((pow(10, i)//9)*i)``````

This is where I’ve got to in q:

``````1 "Type a number: ";    //Prompt for user input
input: read0 0;     //Save user input as variable
i: 1;               //Assign variable i as 1
output:{[input]     //Function with input as parameter
each[(floor((10 xexp i)%9)*i);input]   //floor = to round down, 10 xexp i = 10 to the power of i, divide by 9, multiplied by i
i: i+1;         //Increment i by 1
}
`````` I am trying to imitate the iterating of the for loop by using “each” while also incrementing i.

This is how I visualised my approach, but it is throwing a type error.

Hoping I can get some suggestions on how else I could approach this problem, and any advice would be greatly appreciated.