Finding Partitions of a number
So recently i got a question from my friend Sameera who had this requirement. Given a number N , he wanted to generate all possible combinations of n1,n2 where n1 + n2 = N For example if i give you 25 , you should output : 1,24 2,23 3,22 4,21 5,20 6,19 7,18 9,16 10,15 11,14 12,13 But he had an additional condition as well , these number pairs should not contain an addition which involves a carry . ( As a non native English speaker this is the first time i even heard that word :) ) So that means in the above example if i gave you 25 , you should only output: 1,24 2,23 3,22 4,21 5,20 10,15 11,14 12,13 Notice that i have left out 6,19 7,18 9,16 Because adding them involves transferring 1 digit from one place to another. ( Please excuse my language as i am not a mathematician or well versed in maths so im trying to explain this in layman idiot terms here ). Ok , so in add...