Need some change to python script for random number which does not match

  • Status: Closed
  • Prize: $50
  • Entries Received: 12
  • Winner: ShadowBlade88

Contest Brief

Hi , I need some change in the pyhon script . The script is below.

[login to view URL]

import random
number=[login to view URL](0, 15)
x=0
count=0
for y in range(10):
x=0
count=0
while x!=1:
num1=[login to view URL](0, 15) /// change here should be 0-15 integer
num2=[login to view URL](0, 15) /// fixed code integer
count=count+1
if(num1==num2):
x=1
if(count>0):
print(y+1," : ",count)

num1 and num2 are two number between 0-15. You need to genrate num1 in such a way that value of count should be greater than 200 for ten [login to view URL] can be changed.

Recommended Skills

Employer Feedback

“What a amazing work from Thorben . He completed a difficult script in short period of time. All requirement are met and I highly recommended the expert.”

Profile image as800201, Canada.

Top entries from this contest

View More Entries

Public Clarification Board

  • as800201
    Contest Holder
    • 4 days ago

    Thorben W. is the winner

    • 4 days ago
  • as800201
    Contest Holder
    • 4 days ago

    At this Point Two expert are at the top and very near to completion.
    1. Thorben W.
    2. Ruler555

    • 4 days ago
  • as800201
    Contest Holder
    • 5 days ago

    Thorben W. - > Yes , I completely agree with your ideas. The code need to be change at somewhere but not manipulated. You almost complete the task , if the statement were swapped. Now for your code , if you remove the count statement in getrandom function then it never match , and it works perfectly . It became truly random and it never ends. But it was quite near.

    • 5 days ago
  • as800201
    Contest Holder
    • 5 days ago

    the seed in randrange in num2 is system generated , by adding seeds to variable before it will affect the seed of num2 - num2 should be generated independently with the default seed ( whichever it may be ).

    • 5 days ago
    1. ShadowBlade88
      ShadowBlade88
      • 5 days ago

      Hey, if you want the count to be greater than 200 on average some part of the generation has to be manipulated. If you were to generate two perfectly random int values between 0 and 15 that would give you 16 different values you could get. Since both values are in the same range the first value generated is irrelevant and the probability P for the second value to be equal to the first is 1 in 16. Now by that logic it is nowhere near possible to get a consistent count greater than 200. Feel free to get in contact with me if you disagree with anything or want to discuss this further.

      • 5 days ago
  • as800201
    Contest Holder
    • 5 days ago

    Some of you are using the seed of num1 , make sure you swap the line of num1 and num2 , as num2 is fixed independent random value , and seed value interfere the randomness. see below.

    num2=random.randrange(0,15)
    num1=return_num1()

    • 5 days ago
  • as800201
    Contest Holder
    • 5 days ago

    def return_num1:

    work by this : it may help

    • 5 days ago
  • as800201
    Contest Holder
    • 5 days ago

    num1=return_num1()

    • 5 days ago
  • as800201
    Contest Holder
    • 5 days ago

    num2 is positive random integer between 0-15 which is generated randomly, you cannot make any changes to that.

    • 5 days ago
  • as800201
    Contest Holder
    • 5 days ago

    num1 is positive integer between 0-15.

    • 5 days ago
  • gerroo
    gerroo
    • 5 days ago

    Hey! Can you post the indented version of the code? Use https://pastebin.com/

    • 5 days ago
    1. as800201
      Contest Holder
      • 5 days ago

      https://pastebin.com/1fJHL1cj

      • 5 days ago

Show more comments

How to get started with contests

  • Post your contest

    Post Your Contest Quick and easy

  • Get tons of entries

    Get Tons of Entries From around the world

  • Award the best entry

    Award the best entry Download the files - Easy!

Post a Contest Now or Join us Today!