Hello everyone. Is there any way we can roll dice but no recurring numbers (e.g. 1 to 10) in one row?
Let the seed become today’s date, so the first number is 7.
In the same row, how can I roll dice, but there is no option 7 in hand.
The purpose is simple, in one row, there are fixed 10 numbers with no recurring. So that, if the user add new response (new row) the numbers combination will be different with the previous one.
I have used random number. But when I refresh the app, it always changing. I want it to be fixed. For example, in 1st cell the number is 7, the 2nd cell is 3, so on and so forth, when I refresh it stay still.
The p3 parameter is a unique seed value, such as a RowID
function getRandomNumbers(min, max, seed) {
let numbers = [];
// Populate the array with numbers from min to max
for (let i = min; i <= max; i++) {
numbers.push(i);
}
// Calculate seed based on ASCII values of characters in the seed text
let seedValue = 0;
for (let i = 0; i < seed.length; i++) {
seedValue += seed.charCodeAt(i);
}
// Shuffle the array using seedValue
let random = function() {
let x = Math.sin(seedValue++) * 10000;
return x - Math.floor(x);
};
for (let i = numbers.length - 1; i > 0; i--) {
const j = Math.floor(random() * (i + 1));
[numbers[i], numbers[j]] = [numbers[j], numbers[i]];
}
// Generate comma-delimited string
function getRandomString() {
const result = [];
while (numbers.length > 0) {
result.push(numbers.pop());
}
return result.join(',');
}
return getRandomString();
}
return getRandomNumbers(p1, p2, p3);
The result will be a comma delimited list of random numbers that are different for each row. Add a Split Text column to convert the comma delimited list of numbers into an array. Finally add several Single Value columns to retrieve each number out of the array.