Learn an Algorithm in 60 Seconds! - Shuffle @zoran-horvat
Learn an Algorithm in 60 Seconds! - Shuffle  @zoran-horvat
Uploaded May 2024 | Updated September 2026, 3 weeks ago
Become a sponsor to access source code ► patreon.com/zoranhorvat
Join Discord server with topics on C# ► codinghelmet.com/go/discord
Enroll course *Beginning Object-Oriented Programming with C#* ► codinghelmet.com/go/beginning-oop-with-csharp
Subscribe ► youtube.com/channel/UCxsWfh8LCcn55mFB6zGBT1g?sub_confirmation=1

Learn an algorithm in 60 seconds!
There is a sequence of playing cards representing a deck.
I want to draw a hand of 13 cards.
But the deck is not shuffled.
This won't work.
Can you write a function that returns the elements of a sequence in a shuffled order?
First, get hold of all the objects.
You will need a random number generator.
This function should return as many items as there are objects in the input sequence.
Elements starting at this index and past it have not been sent to the output.
Pick one on the random position.
Swap it to the i-th position.
Yield-return it to support deferred evaluation.
The rest of the array remains pending.
This is known as the Fisher-Yates shuffle algorithm.
Apply it to the deck before drawing and enjoy.
Follow the link to the long video to learn more.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
👨 About Me 👨
Hi, I’m Zoran, I have more than 20 years of experience as a software developer, architect, team lead, and more. I have been programming in C# since its inception in the early 2000s. Since 2017 I have started publishing professional video courses at Pluralsight and Udemy and by this point, there are over 100 hours of the highest-quality videos you can watch on those platforms. On my YouTube channel, you can find shorter video forms focused on clarifying practical issues in coding, design, and architecture of .NET applications.❤️
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
⚡️COPYRIGHT NOTICE:
The Copyright Laws of the United States recognize a “fair use” of copyrighted content. Section 107 of the U.S. Copyright Act states: “Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phono records or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright." This video and our youtube channel, in general, may contain certain copyrighted works that were not specifically authorized to be used by the copyright holder(s), but which we believe in good faith are protected by federal law and the Fair use doctrine for one or more of the reasons noted above.

#csharp #dotnet #interviewquestions
Learn an Algorithm in 60 Seconds! - ShufflePrevent GitHub Copilot Hallucinations With This Prompting TechniqueMaster The L in SOLID3 Shocking Misconceptions Among C# ProgrammersC# Records Are Functional - Use Them That Way!C# Constructors Just Got Better!How Do You Cancel an async Method? | Step-by-Step TutorialThe Real Story Behind C# 15 Union TypesSolving the Deep Immutable Problem in EF CoreDoes This Class Violate LSP?Coding Style vs EF Core & Dapper: Pick a SideMost Developers Dont Know About This Security Hole
Zoran on C# |

Learn an Algorithm in 60 Seconds! - Shuffle

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER