Header Ads Widget

Break Numbers | coding Ninjas solution

 Break Numbers

Given an integer n, break it into smaller numbers such that their summation is equal to n. Print all such combinations in different lines.

Note : [1, 2, 1] and [1,1, 2] are same, so print the particular sequence with increasing order. Order of different combinations doesn't matter.
Input format :
Integer n
Output format :
Print all possible combinations in different lines
Constraints :

1 <= n <= 100

Input :


Output :

1 1 1 1
1 1 2
1 3
2 2


def printarray(p,n):
    for i in range(n):

def pp(n):
    while True:
        while k>=0 and p[k]==1:
        if k<0:
        while rr>p[k]:

for  i in range(len(l)-1,-1,-1):
    for i in range(len(ll)-1,-1,-1):
        print(ll[i],end=" ")

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-