relevant-comic

rechosting with relevant comics

this page is @Anschel's fault


prophetgoddess
@prophetgoddess

it used to be so fucking easy to get your name immortalized in computer science dude. dijkstra's algorithm and the fisher-yates shuffle are literally just the first thing i would try


prophetgoddess
@prophetgoddess

ME: i need to write a shuffler i know there's an algorithm for it i wonder if it does anything special

FISHER AND/OR YATES: have you tried randomly swapping items in the array

ME:



You must log in to comment.

in reply to @prophetgoddess's post:

I did, genuinely, invent Dijkstra’s algorithm from first principles when I was about 16. I was doing a problem for a programming competition and came up with what I thought was a clever solution. A few years later in university I learned about Dijkstra’s algorithm and immediately recognized it as a more formalized and refined way of thinking about the exact thing I had built.

Fisher-Yates I did not invent; I had written some bad shuffling algorithms that I never quite trusted but it turns out it’s hard to prove/disprove that a shuffle algorithm gives a uniform distribution when you’ve had no formal training. And there are a few ways to get Fisher-Yates slightly wrong and mess it up.

to be fair it's slightly more complicated than randomly swapping items in the array. you can't just go to a random index and swap the value with another random index. you have to make sure that every element gets randomized. which is pretty simple