Last active
October 26, 2023 07:51
-
-
Save wlkns/ff6c6b32377a1c9dc776308259d4856d to your computer and use it in GitHub Desktop.
Unique Sequencer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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