Skip to content

Instantly share code, notes, and snippets.

@wlkns
Last active October 26, 2023 07:51
Show Gist options
  • Save wlkns/ff6c6b32377a1c9dc776308259d4856d to your computer and use it in GitHub Desktop.
Save wlkns/ff6c6b32377a1c9dc776308259d4856d to your computer and use it in GitHub Desktop.
Unique Sequencer
"AAA"
"BAA"
"CAA"
"DAA"
"EAA"
"FAA"
"GAA"
"HAA"
"IAA"
"JAA"
"KAA"
"LAA"
"MAA"
"NAA"
"OAA"
"PAA"
"QAA"
"RAA"
"SAA"
"TAA"
"UAA"
"VAA"
"WAA"
"XAA"
"YAA"
"ZAA"
"ABA"
"BBA"
"CBA"
"DBA"
"EBA"
"FBA"
"GBA"
<?php
class UniqueSequencer {
private static int $counter = -1;
static private function char(int $num)
{
return chr(65 + $num);
}
static public function value(): string {
self::$counter++;
return
self::char(self::$counter % 26) .
self::char(floor(self::$counter / 26) % 26).
self::char(floor(self::$counter / 676) % 26);
}
static public function betterValue(): string {
return strrev(self::value());
}
}
for($i = 1; $i <= 100; $i++)
{
dump(UniqueSequencer::prefix());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment