
Hello friends!
Welcome to this weekās Sloth Bytes. I hope you had a great week.

Dex AI Scrapes the internet and sets up interviews for you
Dex is a conversational AI and career matchmaker that works on behalf of each person. You spend 15-20 minutes on the phone with him, talking about your experience, your ambitions and your non-negotiables.
Dex then scans thousands of roles and companies to identify the most interesting and compatible opportunities.
Once weāve found a match, Dex connects you to hiring managers and even helps you prep for interviews.
Thousands of exceptional engineers have already signed up and weāre partnered with many of the UKās leading Start-ups, Scale-ups, hedge funds and tech companies.
Donāt waste another day at a job you hate. Speak with Dex today.
Go from AI overwhelmed to AI savvy professional
AI will eliminate 300 million jobs in the next 5 years.
Yours doesn't have to be one of them.
Here's how to future-proof your career:
Join the Superhuman AI newsletter - read by 1M+ professionals
Learn AI skills in 3 mins a day
Become the AI expert on your team

Why Random isnāt āRandomā

A few years ago, I was in a final-round technical interview.
Fun little zoom call. Multiple interviewers. My hands were sweating like crazy.
After finishing all the normal interview problems we had some extra time.
So they asked me a fun bonus question:
āHow would you write a program to randomly shuffle a deck of cards?ā
Easy enough, right? I asked if I can use the random package and they said sure.
Now in my head I thought āWow this is way easier than the other questions.ā
The solution basically looks like this with the random package.
#Simplified version - shuffling numbers in an array
import random
deck = [1,2,3,4]
#Yep the random package has a shuffle method.
random.shuffle(deck)
Boom. Done.
At this point I felt pretty confident, but then one interviewer hit me with this question:
āHow do you know if that package is truly shuffling them random?ā
And thatās where I froze. Because I had no idea.
Is random actually random?
Well⦠Software Usually Uses Pseudorandomness
Ordinary software is deterministic: given the same internal state and inputs, it follows the same rules. So most general-purpose ārandomā APIs generate pseudorandom values with algorithms rather than inventing entropy from nothing.
But computers can also collect nondeterministic physical/environmental signals through hardware and operating-system entropy sources. Modern secure randomness usually combines that entropy with a cryptographically secure pseudorandom generator.
So the useful distinction isnāt ācomputers can never do true random.ā Itās: normal PRNGs are deterministic and reproducible; security-sensitive generators are designed to be unpredictable and are seeded/reseeded from high-quality entropy.
For simulations, games, tests, and shuffling where adversaries are not involved, a normal PRNG is often exactly what you want.
For passwords, tokens, keys, and cryptography, use the operating systemās secure randomness APIs or a library built on top of them.
What is the computer doing then?
When you ask your computer for randomness, it doesnāt pull chaos out of thin air. Instead, it uses a pseudorandom number generator (PRNG).
A PRNG is an algorithm that produces a sequence that looks random. If you know enough about its algorithm and internal stateāincluding its seed/stateāyou may be able to reproduce or predict the sequence. That reproducibility is a feature for simulations and testing, but a disaster for secrets.
PRNGs in simple terms
PRNGs usually consist of two parts:
The seed
A math algorithm that spits out numbers.
The seed is the starting point and the math algorithm uses that seed to generate a sequence of numbers.
Why do we need a seed?
To reproduce the ārandomā result. Weird, I know.
Same seed + same PRNG algorithm/implementation/state rules ā the same pseudorandom sequence.
Different seed ā usually a different sequence.
Example you can try
import random
random.seed(42)
print([random.randint(1, 10) for _ in range(5)])
The output you should get is [2, 1, 5, 4, 4].
With the same Python version/compatible random implementation and seed, you should reproduce the same sequence. Donāt treat a seeded stream as a cross-language or forever-across-versions serialization format unless the library explicitly guarantees that behavior.
Why is this useful?
Because reproducibility matters:
In ML experiments, you want the same ārandom splitā of data.
In debugging, you want to replay the same test run.
In games, you want to recreate the same world from a seed (Minecraft)
So ārandomā in this case isnāt true randomness. Itās just math following rules.
Where Do Seeds Come From?
Okay, so if PRNGs need seeds, where do those come from?
How a generator gets initialized depends on the language/library. Non-cryptographic PRNGs may use an explicit seed for reproducibility or automatically initialize themselves. Secure randomness APIs typically draw seed material from the operating systemās entropy facilities, which aggregate unpredictable system and hardware events.
An explicit developer-provided seed (useful for reproducible tests/simulations)
Operating-system randomness such as
getrandom(),/dev/urandom, or platform equivalentsEntropy gathered by the OS from hardware and system events
Once a deterministic PRNG has a particular internal state, its future sequence is determined. The security question is whether an attacker can feasibly learn or predict that state.
ā ļø Back to the Deck Shuffle
Now we only covered how the ārandomā part works, but how does the shuffle work?
A common way to implement an unbiased in-place shuffle is the FisherāYates shuffle. Pythonās random.shuffle() uses a well-designed shuffle routine, but the important idea is broader than one language: each step must choose uniformly from the remaining valid positions.
Hereās the implementation in Python (thanks wikipedia):
def shuffle(numbers: list[int]) -> list[int]:
for i in range(len(numbers) - 1, 0, -1):
#IMPORTANT PART!
j = random.randint(0, i)
numbers[i], numbers[j] = numbers[j], numbers[i]
return numbersYou see that random.randint(0, i)?
That is whatās making this implementation possible.
The shuffle is only unbiased if those index choices are uniform. A correct FisherāYates algorithm paired with a biased range-mapping method can still produce a biased deck. Good standard-library integer APIs avoid common mistakes such as naive modulo reduction when the source range is not evenly divisible by the target range.
And if an attacker needs to be unable to predict the shuffleāthink online gambling, lotteries, secret assignments, or security protocolsāthe randomness source must also be cryptographically secure. Pythonās normal random module is explicitly for simulation/general-purpose randomness, not secrets.
And that means itās not that ārandom.ā
š Crypto-Grade Randomness
WAIT A MINUTE⦠If patterns can exist, doesnāt that mean encryptions and random password generators are not that secure?
Couldnāt attackers could guess the seed and reproduce the sequence.
Yesāif you use a predictable non-cryptographic generator for secrets, an attacker who recovers or infers its state may be able to predict future values.
But donāt worry, modern systems provide cryptographically secure PRNGs (CSPRNGs).
CSPRNGs are designed so that, assuming their secret internal state remains unknown and the implementation is sound, observing previous outputs does not make future outputs feasibly predictable. Operating systems seed and reseed these generators from entropy sources.
Example
# Python's secure randomness
import secrets
print(secrets.token_hex(16))For a security-sensitive shuffle in Python, use a secure generator such as random.SystemRandom(), which draws from the operating system rather than the deterministic Mersenne Twister used by the normal random module:
import random
secure_random = random.SystemRandom()
deck = list(range(52))
secure_random.shuffle(deck)These are what youād use for things like password-reset tokens, API keys, session identifiers, cryptographic keys, and other security-sensitive values.
Knowing the algorithm is not supposed to be enough to predict the sequence; security comes from the generatorās unknown internal state and high-quality entropy, not from hiding how the algorithm works.
Cameras capture unpredictable visual patterns, and that data contributes entropy to Cloudflareās randomness systems. The lamps do not directly encrypt TLS traffic; they are one additional entropy source feeding systems that need unpredictable random values.

Cloudflareās lava lamps contribute physical entropy; they are not tiny glowing TLS servers.
Takeaway
That interviewer asked a really good question. I donāt know if this was the answer they were looking for, but still a good question.
If I could go back to that interview, Iād probably say something like this:
āPythonās random module uses a deterministic pseudorandom generator, so itās great for ordinary shuffling but not for security. A proper shuffle algorithm like FisherāYates can be unbiased if each random choice is uniform. If the shuffle were security-sensitive, Iād use a cryptographically secure randomness source such as Pythonās secrets or the OS CSPRNG.ā
If I said that, I probably wouldāve gotten the jobā¦
But hey, maybe itāll help you with one.
If you want to keep learning
How passwords actually work ā secure password systems rely on random salts and security-focused hashing rather than predictable values.
How two-factor codes work ā authentication apps depend on secret keys that need to be generated and protected securely.
How environment variables and secrets leak ā generating a secure key is only half the battle; you also have to keep it out of Git, logs, and frontend builds.



Thanks to everyone who submitted!
grcc492, Melvis-07, Yeshua235 , AspenTheRoyal, gcavelier (used a crate/package to handle it. Practical. I respect it), jsjasee, NeoScripter, and Suji-droid!
A lot of you solved it with dfs and bfs great job!
Keyword Cipher
A Keyword Cipher replaces each letter of a message with a letter from a shifted alphabet built using a keyword.
Start with the keyword.
Add the remaining letters of the alphabet (AāZ) in order, skipping any that already appeared in the keyword.
Example keyword:
"KEYWORD"Cipher alphabet:
KEYWORDABCFGHIJLMNPQSTUVXZ
Encrypt by replacing each letter in the message with the letter at the same position in the cipher alphabet.
Plain alphabet:
ABCDEFGHIJKLMNOPQRSTUVWXYZCipher alphabet:
KEYWORDABCFGHIJLMNPQSTUVXZ
Write a function that takes a key and a message, and returns the encrypted message.
Examples
keyword_cipher("keyword", "abchij")
Output = "keyabc"
keyword_cipher("purplepineapple", "abc")
output = "pur"
keyword_cipher("mubashir", "edabit")
output = "samucq"
keyword_cipher("etaoinshrdlucmfwypvbgkjqxz", "abc")
Output = "eta"
keyword_cipher("etaoinshrdlucmfwypvbgkjqxz", "xyz")
Output = "qxz"
keyword_cipher("etaoinshrdlucmfwypvbgkjqxz", "aeiou")
Output = "eirfg"How To Submit Answers
Reply with
A link to your solution (github, twitter, personal blog, portfolio, replit, etc)
or if youāre on the web version leave a comment!
If you want to be mentioned here, Iād prefer if you sent a GitHub link or Replit!
Thatās all from me!
Have a great week, be safe, make good choices, and have fun coding.
If I made a mistake or you have any questions, feel free to comment below or reply to the email!
See you all next week.
What'd you think of today's email?
Want to advertise in Sloth Bytes?
If your company is interested in reaching an audience of developers and programming enthusiasts, you may want to advertise with us here.








