Build a randomizer algorithm with arrays and array objects.
Budget: $30 – $250 USD
Hi everyone.
I need someone to develop me a script that uses these basic variables to be able to generate random numbers based on the input.
I added a test script which kinda of does what i want to do, in a fashion that i want it done, but it does not do it properly.
the numbers repeat themself, and i just gave up at this point in hopes that there is someone way smarter then me to fix this.
the function addToArray receives "random" parameter, and that random number is a long random integer usually.
The goal is to add to the itemsReceived array with random numbers between 1 - itemsLeft.
When it has been called 10 times, the itemsReceived needs to contain 10 numbers between 1-10 that does not repeat.
itemsRceived cannot have the same number twice.
THey have to be logically added to the array.
We cannot use any functions like find/filter etc, as i need to rewrite this whole code in solidity.
No Classes, and no For Loops.
These are the only variables we can use.
let itemsReceived = [];
let itemsLeft = 10;
let items = {};
const addToArray = (random) => {
let randomResult = random % itemsLeft;
itemsLeft--; //everytime we add to array, itemsLeft needs to decrease.
console.log('--------------------------------------')
};
Excpected result: [1,3,4,10,5,6,2,7,9,8]; //(True random order).
I need someone to develop me a script that uses these basic variables to be able to generate random numbers based on the input.
I added a test script which kinda of does what i want to do, in a fashion that i want it done, but it does not do it properly.
the numbers repeat themself, and i just gave up at this point in hopes that there is someone way smarter then me to fix this.
the function addToArray receives "random" parameter, and that random number is a long random integer usually.
The goal is to add to the itemsReceived array with random numbers between 1 - itemsLeft.
When it has been called 10 times, the itemsReceived needs to contain 10 numbers between 1-10 that does not repeat.
itemsRceived cannot have the same number twice.
THey have to be logically added to the array.
We cannot use any functions like find/filter etc, as i need to rewrite this whole code in solidity.
No Classes, and no For Loops.
These are the only variables we can use.
let itemsReceived = [];
let itemsLeft = 10;
let items = {};
const addToArray = (random) => {
let randomResult = random % itemsLeft;
itemsLeft--; //everytime we add to array, itemsLeft needs to decrease.
console.log('--------------------------------------')
};
Excpected result: [1,3,4,10,5,6,2,7,9,8]; //(True random order).