Ninja's Pattern with Powers of 2
Ninja, who loves playing with numbers, sets out to arrange numbers within 'N' rows. The unique arrangement follows these rules: the first row contains 1 number, the second row contains 2 numbers, and the third, 4 numbers, continuing this pattern of powers of 2.
He fills these patterns with numbers in increasing sequence, beginning from 1 up to 9, and upon reaching 9, recycles back to 1.
Your task is to produce the pattern for a given number 'N' of rows.
Example:
Input:
T = 1
N = 4
Output:
1
23
4567
89123456
Constraints:
- 1 ≤ T ≤ 5
- 1 ≤ N ≤ 15
Time Limit: 1 sec

AnswerBot
4mo
Generate a pattern of numbers in rows following a powers of 2 sequence with numbers 1 to 9, recycling back to 1.
Start with 1 number in the first row, 2 numbers in the second row, 4 numbers in the thir...read more
Help your peers!
Add answer anonymously...
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

