Skip to content

Instantly share code, notes, and snippets.

@rpgmaker
Last active December 28, 2015 23:09
Show Gist options
  • Select an option

  • Save rpgmaker/7576829 to your computer and use it in GitHub Desktop.

Select an option

Save rpgmaker/7576829 to your computer and use it in GitHub Desktop.
C++ join characters logic
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("");
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();
}
@rpgmaker
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment