Random Shuffling isn't Easy! - Friday Minis 316

  Рет қаралды 979

0612 TV w/ NERDfirst

0612 TV w/ NERDfirst

Күн бұрын

Пікірлер: 15
@Maazin5
@Maazin5 3 жыл бұрын
Found your channel today and this was a great video to follow along to.
@NERDfirst
@NERDfirst 3 жыл бұрын
Hello and thank you very much for your comment! Glad you like my work =)
@maratdavletov380
@maratdavletov380 3 жыл бұрын
Hello, i started to learn programming recently and i dont understand why you choose other language to write this function. Is python dont let you to write it using "for" function? I am trying to make .shuffle with "for" but i cant understand how to manage with repeating elements.
@NERDfirst
@NERDfirst 3 жыл бұрын
Hello and thank you for your comment! The same can absolutely be done with Python - I chose C because it's a lower-level language that doesn't give us things like random.shuffle(). Of course, if you're already using Python then you can just call random.shuffle() directly, but the algorithm given here can be implemented in any language.
@Rumble_Ball
@Rumble_Ball 3 жыл бұрын
Why not use the entire array index range for the new index? Only using indexes behind seems bad for the end of the array and is more computation.
@NERDfirst
@NERDfirst 3 жыл бұрын
Hello and thank you for your comment! You could certainly do a fixed number of random swaps across the entire array, and you'd get a shuffled result too. My goal here was to make it fair for every element in that every index is considered once for the swap.
@Rumble_Ball
@Rumble_Ball 3 жыл бұрын
@@NERDfirst but if your are realy unlucky you will always get the last index. And the more you process the higher the chance to get the last index as the possible numbers get reduced
@NERDfirst
@NERDfirst 3 жыл бұрын
That's absolutely true! I'm not trying to guarantee that the list does gets shuffled. I mean, after all, getting the exact same list back is a possible result, and if my probability and statistics isn't too rusty, it's equally likely as getting any other combination. Having said that, I can't confirm that my technique here gives rise to all possible combinations in equal probability!
@JohnSmithhh
@JohnSmithhh 2 жыл бұрын
I thought you will explain how rand() method works :)
@NERDfirst
@NERDfirst 2 жыл бұрын
Hello and thank you for your comment! Anything about rand() you'd like me to clarify?
@lawrencedoliveiro9104
@lawrencedoliveiro9104 3 жыл бұрын
4:57 rand(3) returns integers up to RAND_MAX which, as you noticed, can be quite small man7.org/linux/man-pages/man3/rand.3.html . That man page recommends using something like random(3) instead.
@NERDfirst
@NERDfirst 3 жыл бұрын
Hello and thank you for your comment and for sharing! This is a toy example so in fact RAND_MAX is more than enough for such an application. But perhaps someone else doing more complex random number generation in C might find this useful!
@lawrencedoliveiro9104
@lawrencedoliveiro9104 3 жыл бұрын
If you want something more like cryptographically strong random or pseudorandom numbers, then perhaps use /dev/urandom or /dev/random linux.die.net/man/4/urandom .
CPU Pipelining - The cool way your CPU avoids idle time!
15:25
0612 TV w/ NERDfirst
Рет қаралды 12 М.
17-4: Random Shuffle & Fisher-Yates Algorithm
26:37
Shusen Wang
Рет қаралды 2,1 М.
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
5 Python Libraries You Should Know in 2025!
22:30
Keith Galli
Рет қаралды 69 М.
I made a Nerdle "Solver" with as many Software Engineering concepts as I could!
22:30
How to Reason about Recursion
39:38
0612 TV w/ NERDfirst
Рет қаралды 2 М.
Python laid waste to my C++!
17:18
Sheafification of G
Рет қаралды 144 М.
Python Logging: How to Write Logs Like a Pro!
11:02
ArjanCodes
Рет қаралды 183 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 335 М.
"Clean" Code, Horrible Performance
22:41
Molly Rocket
Рет қаралды 928 М.
H-Bridge: An elegant way to drive motors!
7:46
0612 TV w/ NERDfirst
Рет қаралды 1,3 М.
All Quicksort does is call this function - Partition!
15:53
0612 TV w/ NERDfirst
Рет қаралды 1,2 М.
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41