Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static List<String> PossibleCommands(int lines) {
- List<string> outputList = new List<string>();
- Rec(outputList, lines, "", -1);
- return outputList;
- }
- static void Rec(List<string> outputList, int linesLeft, string stringAcc, int last = -1) {
- // recursion bottom
- if (linesLeft == 0) {
- outputList.Add(stringAcc.Substring(0, stringAcc.Length - 1));
- return;
- }
- // dj, d2j, ...
- for (int i = 1; i < linesLeft; i++) {
- // dNj
- Rec(outputList, linesLeft - i - 1, stringAcc + $"d{i}j ", i + 1);
- if (i == 1) {
- // dj
- Rec(outputList, linesLeft - i - 1, stringAcc + "dj ", 2);
- }
- }
- // dd
- Rec(outputList, linesLeft - 1, stringAcc + "dd ", 1);
- // dot command
- if (last > 0 && linesLeft >= last) {
- string add = ". ";
- Rec(outputList, linesLeft - last, stringAcc + add, last);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement