Lines & ListsLesson 360Free preview
Shuffle Lines
This lesson is part of Web Developer Tools · All levels
Summary
Shuffle Lines trace the sequence of lines without changing the content of each line. A good implementation uses the Fisher-Yates algorithm so that every permutation has a fair chance. For testing, seeds can make random results reproducible, whereas for security a cryptographic random source must be used.
Key points
- Shuffle changes the order of the lines, not the content of the lines
- Fisher-Yates is a fair and efficient tracking algorithm.
- Seeds allow the same random outcomes to be reproduced
- Python's built-in random is for simulation, not for secrecy.
- Use secrets or CSPRNG when the hacking is security related
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.