Given integer inputs seed, how_many, and max_num, generate a list of how_many unique random integers from 0 to max_num (inclusive). Complete function unique_random_ints(how_many, max_num): Generate a list of how_many random integers from 0 to max_num (inclusive). When a random number exists in the list, a new random number must be generated; use a global variable, retries, to count the number of times an existing number is generated. Return the list. Complete __main__: Initialize the random module with the seed value. Call unique_random_ints() to get a list of random integers. Output the list of random integers and the value of retries, according to the output format shown in the example below. Ex: If the input is: 2 5 7 the output is 0 1 5 2 4 retries=1

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 16SA
icon
Related questions
Question

Given integer inputs seed, how_many, and max_num, generate a list of how_many unique random integers from 0 to max_num (inclusive).

  1. Complete function unique_random_ints(how_many, max_num):
    1. Generate a list of how_many random integers from 0 to max_num (inclusive).
    2. When a random number exists in the list, a new random number must be generated; use a global variable, retries, to count the number of times an existing number is generated.
    3. Return the list.
  2. Complete __main__:
    1. Initialize the random module with the seed value.
    2. Call unique_random_ints() to get a list of random integers.
    3. Output the list of random integers and the value of retries, according to the output format shown in the example below.

Ex: If the input is:

2 5 7

the output is

0 1 5 2 4 retries=1

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Binary Search Algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L