The following image shows 4 boxes containing different balls labelled by numbers between 1 and 9. 4 2 (8) (5 7 5 The boxes are used in a lottery to determine a winning combination of 4 numbers by drawing one ball from each box. To enter the lottery, participants write 4 numbers between 1 and 9 on their ticket in nondecreasing order (from smallest to largest). A ticket wins if all its numbers are drawn in the lottery. The order in which the numbers are drawn does not matter. For example, if the drawing is (2, 8, 2, 1), then a ticket with the numbers (1, 2, 2, 8) wins (the numbers are the same, albeit in a different order), but a ticket with the numbers (1, 2, 2, 9) loses. Construct a list of all valid tickets, i.e., all tickets that can potentially be drawn in the lottery, and store it in the variable possible_tickets. The tickets should be specified as tuples of 4 numbers in nondecreasing order, and every valid ticket should appear exactly one time in the list possible_tickets. (Note, however, that some numbers may occur more than once on a single ticket, as in the above example.)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
The following image shows 4 boxes containing different balls labelled by numbers between 1 and 9.
4
2
(8)
(5
7
5
The boxes are used in a lottery to determine a winning combination of 4 numbers by drawing one ball from each box. To enter the lottery, participants write 4
numbers between 1 and 9 on their ticket in nondecreasing order (from smallest to largest). A ticket wins if all its numbers are drawn in the lottery. The order in which
the numbers are drawn does not matter.
For example, if the drawing is (2, 8, 2, 1), then a ticket with the numbers (1, 2, 2, 8) wins (the numbers are the same, albeit in a different order), but a
ticket with the numbers (1, 2, 2, 9) loses.
Construct a list of all valid tickets, i.e., all tickets that can potentially be drawn in the lottery, and store it in the variable possible_tickets. The tickets should be
specified as tuples of 4 numbers in nondecreasing order, and every valid ticket should appear exactly one time in the list possible_tickets. (Note, however, that some
numbers may occur more than once on a single ticket, as in the above example.)
Transcribed Image Text:The following image shows 4 boxes containing different balls labelled by numbers between 1 and 9. 4 2 (8) (5 7 5 The boxes are used in a lottery to determine a winning combination of 4 numbers by drawing one ball from each box. To enter the lottery, participants write 4 numbers between 1 and 9 on their ticket in nondecreasing order (from smallest to largest). A ticket wins if all its numbers are drawn in the lottery. The order in which the numbers are drawn does not matter. For example, if the drawing is (2, 8, 2, 1), then a ticket with the numbers (1, 2, 2, 8) wins (the numbers are the same, albeit in a different order), but a ticket with the numbers (1, 2, 2, 9) loses. Construct a list of all valid tickets, i.e., all tickets that can potentially be drawn in the lottery, and store it in the variable possible_tickets. The tickets should be specified as tuples of 4 numbers in nondecreasing order, and every valid ticket should appear exactly one time in the list possible_tickets. (Note, however, that some numbers may occur more than once on a single ticket, as in the above example.)
Expert Solution
steps

Step by step

Solved in 1 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning