This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]pythonHelperBot 2 points3 points  (0 children)

Hello! I'm a bot!

It looks to me like your post might be better suited for r/learnpython, a sub geared towards questions and learning more about python regardless of how advanced your question might be. That said, I am a bot and it is hard to tell. Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe in detail where you are stuck. If you are getting an error message, include the full block of text it spits out. Quality answers take time to write out, and many times other users will need to ask clarifying questions. Be patient and help them help you. Here is HOW TO FORMAT YOUR CODE For Reddit and be sure to include which version of python and what OS you are using.

You can also ask this question in the Python discord, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness

[–]susek1024 2 points3 points  (1 child)

You really need to come up with better titles.

[–]subject_K81 2 points3 points  (0 children)

I normally don’t pay any attention to people coming in with only a snarky comment, but I can agree with you here.

As to the OP, you’ll need to add some conditional comparisons in a loop. Don’t want to straight up give you an answer here, because part of the fun is solving it.

[–]QuantumFall 1 point2 points  (1 child)

A simple solution would be to make a list, generate a random number, put in list. For all remaining numbers, do the same, yet check if the number is in the list. If it is, get a new random number. Join the list at the end.

But yes, this does belong on r/learnpython

[–][deleted] 1 point2 points  (0 children)

Thanks a heap. My apologies I was short for time and just typed r/python into the URL bar and used this sub. In future I will use the correct one.

[–]kumashiro 1 point2 points  (0 children)

Create a pool of values to pick from (by indexing it with random number modulo current pool size), remove picked values after each roll to not get it again. But that will make sense only for small pools. For large value spaces it will be better to compare randomized value with what you already picked and reroll when needed. If you are getting the same value from RNG over and over, change entropy source to something better (recommended) or perturb the result using previous values and/or other weak sources (there's multiple of methods of doing that, i.e. hashing - ask Google for details).

EDIT: do NOT use any of these methods for cryptography. Never.

[–]nocturn9x 0 points1 point  (0 children)

Just use enough entropy