Computer Science Canada

Miniscule Poker Hand Shuffler

Author:  MEINsweeze [ Tue Mar 02, 2021 5:48 pm ]
Post subject:  Miniscule Poker Hand Shuffler

another submission, this one isn't very fancy, just small!

back in high school, my friend and i wanted to know which language was more compact.

we both made programs that shuffle a deck of cards and then give you the first 5
he did his in java in about 800 bytes, i did it in turing in around 650 (3-4 years later and we both still use our respective languages for side projects lmao)

since then, i've learned so much more about turing and tuned it to the point where i've spent an hour staring at it, trying to find a chink in the armour to get rid of another byte. i can't find anything else, so i'm deciding to publish it here!

it's a minuscule 390 bytes, and is as minimalist as i could possibly make it
of course, because of its compressed size, it's nearly illegible and has terrible terrible formatting...

i'll put it here too since it's not exactly bulky!
var A,B,C:=0var D:array 1..13,1..4 of boolean var G:array 1..13of string for E:1..13for F:1..4D(E,F):=true end for G(E):=intstr(E)end for G(1):="A"G(11):="J"G(12):="Q"G(13):="K"var H:array 1..4of string:=init("h","d","c","s")var I:array 1..52of string loop exit when C=52randint(B,1,4)randint(A,1,13)if D(A,B)then C+=1I(C):=G(A)+H(B)D(A,B):=false end if end loop for J:1..5put I(J)end for

Author:  scholarlytutor [ Fri Mar 05, 2021 4:02 pm ]
Post subject:  Re: Miniscule Poker Hand Shuffler

Wow, you're definitely a pro at keeping files small in terms of bytes. And it works well. The main drawback is that it's hard to read: the formatting, as you said, and also the single letter variable names. But your goal here was for the code to be compact, not readability.

I decided to challenge myself and make something similar in my 'style' of coding, and it's over 800 bytes! I'm sure I can make improvements, but I wrote it in under 30 minutes.