Last active
December 28, 2015 23:09
-
-
Save rpgmaker/7576829 to your computer and use it in GitHub Desktop.
C++ join characters logic
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
| static char[][] join(string text, int size = 4) { | |
| return new char[][] { ("0" + text).ToJoinArray(size), ("1" + text).ToJoinArray(size), ("2" + text).ToJoinArray(size), | |
| ("3" + text).ToJoinArray(size), | |
| ("4" + text).ToJoinArray(size), | |
| ("5" + text).ToJoinArray(size), | |
| ("6" + text).ToJoinArray(size), ("7" + text).ToJoinArray(size), | |
| ("8" + text).ToJoinArray(size), ("9" + text).ToJoinArray(size) }; | |
| } | |
| static char[][] join2(string text, int size = 4) { | |
| return Enumerable.Range(0, 10).Select(x => join(x.ToString() + text, size)).SelectMany(x => x).ToArray(); | |
| } | |
| static char[][] join3(string text, int size = 4) { | |
| return Enumerable.Range(0, 10).Select(x => join2(x.ToString() + text, size)).SelectMany(x => x).ToArray(); | |
| } | |
| static char[][] join4(string text, int size = 8) { | |
| return Enumerable.Range(0, 10).Select(x => join3(x.ToString() + text, size)).SelectMany(x => x).ToArray(); | |
| } | |
| static char[][] table1 = join(""); | |
| static char[][] table2 = join2(""); | |
| static char[][] table3 = join3(""); | |
| static char[][] table4 = join4(""); |
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
| static char[][] join(string text, int size = 4) { | |
| return new char[][] { (text + "0").ToJoinArray(size), (text + "1").ToJoinArray(size), (text + "2").ToJoinArray(size), | |
| (text + "3").ToJoinArray(size), | |
| (text + "4").ToJoinArray(size), | |
| (text + "5").ToJoinArray(size), | |
| (text + "6").ToJoinArray(size), (text + "7").ToJoinArray(size), | |
| (text + "8").ToJoinArray(size), (text + "9").ToJoinArray(size) }; | |
| } | |
| static char[][] join2(string text, int size = 4) { | |
| return Enumerable.Range(0, 10).Select(x => join(text + x.ToString(), size)).SelectMany(x => x).ToArray(); | |
| } | |
| static char[][] join3(string text, int size = 4) { | |
| return Enumerable.Range(0, 10).Select(x => join2(text + x.ToString(), size)).SelectMany(x => x).ToArray(); | |
| } | |
| static char[][] join4(string text, int size = 8) { | |
| return Enumerable.Range(0, 10).Select(x => join3(text + x.ToString(), size)).SelectMany(x => x).ToArray(); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://code.google.com/p/stringencoders/wiki/NumToA