- Edited
So the exercise am gonna give now may be considered easy for some,but it was fun to solve for me.
so me and my friend were discussing cornering the lebanese lotto (assuring win by buying all possible tickets)so while calculating the number of possible choices was easy,writing all the actual possible combination was the hard part (we're talking about writing 5.2 million+ possible combination without a mistake or duplicate)so the challenge was making a program that will list all the ticket numbers possible.
so to the details,you have to pick 6 numbers from 1 to 42,picking the same number twice is not allowed (1-1-3-4-5-6 is invalid),the order is neglected (1-2-3-4-5-6 ; 6-5-4-3-2-1 ; 2-3-4-5-6-1 are considered the same),your program must not show any duplicates or invalid combinations (if the program shows both 1-2-3-4-5-6 and 6-5-4-3-2-1 it means that it failed).
the goal is: make a program that lists all the possible tickets verifying the rules above.
Note:i already solved it but i would like to see different approaches in solving it before posting my solution.
i used python,but feel free to use any language you like.
happy coding !
so me and my friend were discussing cornering the lebanese lotto (assuring win by buying all possible tickets)so while calculating the number of possible choices was easy,writing all the actual possible combination was the hard part (we're talking about writing 5.2 million+ possible combination without a mistake or duplicate)so the challenge was making a program that will list all the ticket numbers possible.
so to the details,you have to pick 6 numbers from 1 to 42,picking the same number twice is not allowed (1-1-3-4-5-6 is invalid),the order is neglected (1-2-3-4-5-6 ; 6-5-4-3-2-1 ; 2-3-4-5-6-1 are considered the same),your program must not show any duplicates or invalid combinations (if the program shows both 1-2-3-4-5-6 and 6-5-4-3-2-1 it means that it failed).
the goal is: make a program that lists all the possible tickets verifying the rules above.
Note:i already solved it but i would like to see different approaches in solving it before posting my solution.
i used python,but feel free to use any language you like.
happy coding !