{"action":"closed","issue":{"url":"https://api.github.com/repos/johreh/gloomycompanion/issues/39","repository_url":"https://api.github.com/repos/johreh/gloomycompanion","labels_url":"https://api.github.com/repos/johreh/gloomycompanion/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/johreh/gloomycompanion/issues/39/comments","events_url":"https://api.github.com/repos/johreh/gloomycompanion/issues/39/events","html_url":"https://github.com/johreh/gloomycompanion/issues/39","id":221857990,"number":39,"title":"Shuffle algorithm is biased","user":{"login":"abies","id":574723,"avatar_url":"https://avatars2.githubusercontent.com/u/574723?v=3","gravatar_id":"","url":"https://api.github.com/users/abies","html_url":"https://github.com/abies","followers_url":"https://api.github.com/users/abies/followers","following_url":"https://api.github.com/users/abies/following{/other_user}","gists_url":"https://api.github.com/users/abies/gists{/gist_id}","starred_url":"https://api.github.com/users/abies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abies/subscriptions","organizations_url":"https://api.github.com/users/abies/orgs","repos_url":"https://api.github.com/users/abies/repos","events_url":"https://api.github.com/users/abies/events{/privacy}","received_events_url":"https://api.github.com/users/abies/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-04-14T17:57:15Z","updated_at":"2017-04-23T10:00:46Z","closed_at":"2017-04-23T10:00:46Z","body":"Current implementation of shuffle algorithm does\r\n\r\n    for (var i = 0; i < l.length; i++) {\r\n        var switch_index = Math.floor(Math.random() * l.length);\r\n\r\nThis unfortunately results in biased shuffle. Please read https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Implementation_errors for details. Proper shuffle will be something like\r\n\r\n    for (var i = 0; i < l.length-1; i++) {\r\n        var switch_index = i + Math.floor(Math.random() * (l.length-i));\r\n\r\nPlease doublecheck proposed solution - I might be off by one here (wikipedia uses ranges instead of arithmetics)."}}
{"actor":{"display_login":"GinoGalotti"}}