mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 08:16:50 +08:00
Dynamic-Programming : remove live code & console.log, leave examples as comments.
This commit is contained in:
@ -76,21 +76,21 @@ function randomizeOutputFromDataset (datasetSource, output) {
|
||||
return newOutput
|
||||
}
|
||||
|
||||
const main = () => {
|
||||
/**
|
||||
* Generates a random range of data, with values between 0 and 2^31 - 1
|
||||
* @param {number} length The number of data items to generate
|
||||
* @returns {Iterable<number>} Random iterable data
|
||||
*/
|
||||
function * generateRandomData (length) {
|
||||
const maxValue = Math.pow(2, 31) - 1
|
||||
for (let i = 0; i < length; i++) {
|
||||
yield Math.floor(Math.random() * maxValue)
|
||||
}
|
||||
}
|
||||
// Example
|
||||
|
||||
const source = generateRandomData(1000)
|
||||
const result = shuf(source, 10)
|
||||
console.log(result)
|
||||
/**
|
||||
* Generates a random range of data, with values between 0 and 2^31 - 1
|
||||
* @param {number} length The number of data items to generate
|
||||
* @returns {Iterable<number>} Random iterable data
|
||||
*/
|
||||
function * generateRandomData (length) {
|
||||
const maxValue = Math.pow(2, 31) - 1
|
||||
for (let i = 0; i < length; i++) {
|
||||
yield Math.floor(Math.random() * maxValue)
|
||||
}
|
||||
}
|
||||
main()
|
||||
|
||||
// const source = generateRandomData(1000)
|
||||
// const result = shuf(source, 10)
|
||||
|
||||
export { shuf, generateRandomData }
|
||||
|
Reference in New Issue
Block a user