Questions tagged [non-repetitive]
57 questions
134
votes
6 answers
Non-repetitive random number in numpy
How can I generate non-repetitive random numbers in numpy?
list = np.random.random_integers(20,size=(10))

Academia
- 3,984
- 6
- 32
- 49
5
votes
4 answers
Generate non repeating random number within range in Java
I want to generate random numbers within the range 1 to 4, 4 including.
Here is my code:
int num = r.nextInt(4) + 1; //r is instance of Random.
However, I am running the above code in a loop and don't want repeating random number.
What happens now…

ashish.gd
- 1,713
- 1
- 14
- 25
4
votes
3 answers
Generate Unique Values
I want to create a C program to generate numbers from 0 to 999999, keeping in mind that the number generated should not have any digits that are repetitive within it. For example, "123" is an acceptable value but not "121" as the '1' is repeated. I…

clamismagic
- 53
- 7
4
votes
2 answers
Regular expression which will match if there is no repetition
I would like to construct regular expression which will match password if there is no character repeating 4 or more times.
I have come up with regex which will match if there is character or group of characters repeating 4…

mybrave
- 1,662
- 3
- 20
- 37
3
votes
2 answers
Avoid repetitive coding when disposing of objects
With a purpose of memory optimization we've been adding these lines of code:
public class Whatever: IDisposable
private bool disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
…

Emilija Vilija Trečiokaitė
- 611
- 4
- 7
3
votes
1 answer
Shuffle/Randomize Questions from an Array with no Repetition (SWIFT)
I've been browsing for several hours to find the right answer but seems like I can't apply it properly to my own code.
Most of the time, the answers given on stackoverflow for this problem are with Strings & Int examples and I'm struggling with the…

Yami Yams
- 33
- 3
2
votes
4 answers
Eliminating Repetition in a Randomized Matrix
I am writing a program that involves placing one number into each cell of a 7x7 grid. There are 56 numbers, chosen from at random, and there must be no repetition.
The end result should be a 7x7 grid in which each cell contains an integer from 1 to…

user1125619
- 47
- 4
2
votes
8 answers
How to replace characters in a string in c#
So the title might be a little misleading, but hear me out. It's not as simple as I worded it in the title.
So I have a string say,
String dna="ACTG";
I have to convert said string into it's complement form. To complement said string, I have to…

Glynn Bacanto
- 439
- 2
- 6
- 12
2
votes
2 answers
Calling a function without explicitly refering to it that changes according to input
I am trying to create a speed distance and time calculator that is as efficient as possible and would like to refer to call a function using a pointer that changes according to input but am not sure how to do so. I have tried many different…

exitcode
- 111
- 4
- 12
2
votes
2 answers
Non-repeated arrays in a matrix in matlab
I am looking for non-repeated rows in a matrix.
Assume:
A =
8 1
2 2
2 2
2 2
2 2
3 6
5 7
5 7
I would like to get "B" which is:
B=
8 1
3 6
Please mind C=unique(A,'rows') will give us unique rows of…

Iman
- 412
- 4
- 18
2
votes
3 answers
non-repeating random numbers
I need to generate around 9-100 million non-repeating random numbers, ranging from zero to the amount of numbers generated, and I need them to be generated very quickly. Several answers to similar questions proposed simply shuffling an array in…

user2635469
- 68
- 9
2
votes
4 answers
Repetitive JavaScript (jQuery) code
Here's something simple I am doing. I have some div's, each called ".item-1", ".item-2", etc. When the user hovers on ".item-1", the "#city-info-1" div slides up, while it slides down when the user hovers off. I knew enough to do that, and know…

ansarob
- 825
- 2
- 13
- 32
1
vote
0 answers
Refactor validation with return if statement
I have lots of method and on each method I have to do a validation. Currently, my code look like this and it works fine.
@Service
public class UserService {
@Autowired
private UserValidation userValidation;
public…

Justin Xu
- 13
- 3
1
vote
1 answer
Sumproduct of sub-arrays in excel
I need to find a performant and smart way to redesign the formula or the tables on which it depends (COSTO_DUMMY and GG_TARGET). Can you help me, please? I can add new support tables if…

Franco
- 87
- 9
1
vote
7 answers
Non-repetitive random seek in a range Algorithm
I'm looking for an efficient algorithm that produces random values within a range, without repetitions.
In pseudo-code: (in class Rand)
Rand(long from, long to) {
this.from = from;
this.to = to;
// ...
}
long getNumber() {
//…

Déjà vu
- 28,223
- 6
- 72
- 100