Created
October 19, 2018 13:53
-
-
Save Traderain/02bf86ac64639799d143e42cd8653a03 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
namespace GrandPrix | |
{ | |
class Program | |
{ | |
[STAThread] | |
static void Main(string[] args) | |
{ | |
Console.Title = "GRAND PRIX LOGO MEME"; | |
var res = new StringBuilder(); | |
res.AppendLine("#include \"stdio.h\""); | |
res.AppendLine("#define p(x) printf(x);"); | |
res.AppendLine("#define a(x) p(#x);"); | |
res.AppendLine("#define d() p(\".\")"); | |
res.AppendLine("#define t(c) for(int i=0;i<c;i++)p(\".\");"); | |
res.AppendLine("#define w(c) for(int i=0;i<c;i++)p(\" \");"); | |
res.AppendLine("#define s(c) for(int i=0;i<c;i++)p(\"/\");"); | |
res.AppendLine("#define b(x,n) for(int i=0;i<n;i++)p(#x);"); | |
res.AppendLine("#define c(x) p (#x\"\\n\");"); | |
res.AppendLine("int main(){"); | |
using (var of = new OpenFileDialog()) | |
{ | |
if (of.ShowDialog() == DialogResult.OK) | |
{ | |
var str = File.ReadAllLines(of.FileName); | |
foreach (var l in str) | |
{ | |
var stop = false; | |
var rem = l; | |
char curr = rem[0]; | |
int conc = 1; | |
for (int i = 0; i < l.Length-1; i++) | |
{ | |
//New characer | |
if (l[i] != curr) | |
{ | |
if (l[i + 1] != curr) | |
{ | |
if (conc > 7) | |
{ | |
if (curr == ' ') | |
{ | |
//Repeating whitespace | |
res.GPAppendWhiteSpace(conc); | |
} | |
else | |
{ | |
//Repeating non whitespace | |
res.GPAppendRepeat(curr.ToString(),conc); | |
} | |
} | |
else | |
{ | |
if (curr == ' ') | |
{ | |
res.GPAppendWhiteSpace(conc); | |
} | |
else | |
{ | |
//TODO:This needs a merger | |
var app = Enumerable.Range(0, conc).Aggregate("", (c, n) => c += curr); | |
res.GPAppend(app); | |
} | |
} | |
conc = 1; | |
} | |
else //Its new but it repeates again. | |
{ | |
conc++; | |
} | |
} | |
else //Repeating character | |
{ | |
conc++; | |
} | |
curr = l[i]; | |
rem = l.Substring(i); | |
} | |
res.AppendLine("c(" + rem + ")"); | |
} | |
} | |
} | |
res.Append(";return 0;}"); | |
File.WriteAllText("res.txt",res.ToString()); | |
Console.WriteLine("-- DONE --"); | |
} | |
} | |
public static class StbExt | |
{ | |
public static StringBuilder GPAppend(this StringBuilder sb, string str) | |
{ | |
sb.Append("a(" + str + ")"); | |
return sb; | |
} | |
public static StringBuilder GPAppendRepeat(this StringBuilder sb, string str,int count) | |
{ | |
sb.Append("b(" + str + "," + count + ")"); | |
return sb; | |
} | |
public static StringBuilder GPAppendEnd(this StringBuilder sb, string str) | |
{ | |
sb.Append("c(" + str + ")"); | |
return sb; | |
} | |
public static StringBuilder GPAppendWhiteSpace(this StringBuilder sb, int count) | |
{ | |
sb.Append("w(" + count + ")"); | |
return sb; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment