Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Conversions/RgbHslConversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const rgbToHsl = (colorRgb) => {
throw new Error('Input is not a valid RGB color.')
}

let colorHsl = colorRgb
// Work on a copy so the caller's RGB array is not mutated
let colorHsl = colorRgb.slice()

let red = Math.round(colorRgb[0])
let green = Math.round(colorRgb[1])
Expand Down
11 changes: 5 additions & 6 deletions Sorts/BogoSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ export function isSorted(array) {
}

/**
* Shuffles the given array randomly in place.
* Unbiased Fisher–Yates shuffle of the given array in place.
* Each permutation is equally likely.
*/
function shuffle(array) {
for (let i = array.length - 1; i; i--) {
const m = Math.floor(Math.random() * i)
const n = array[i - 1]
array[i - 1] = array[m]
array[m] = n
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))
;[array[i], array[j]] = [array[j], array[i]]
}
}

Expand Down
Loading