Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
, where each x
is replaced with a random hexadecimal digit from 0 to f, and y
is replaced with a random hexadecimal digit from 8 to b.
There's also @LeverOne's approach using iteration, which is one byte shorter.
@AndrWeisR code golfing is harmless fun and a useful exercise that teaches you the details of the language. Would I put this in a project when I'm trying to collaborate with others? of course not, but golfing isn't just "genius programmers showing off", it's also just programmers challenging each other to practice, improve and have 𝒇𝒖𝒏™. 🙃