Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class isEvenGenerator
- {
- // main inputs
- static void Main()
- {
- try
- {
- // mode 1 prints everything to console no logs
- // mode 2 prints everything to a text file and has custom log length
- Console.WriteLine("mode?:");
- int mode = int.Parse(Console.ReadLine()!);
- // howmanylinesofabysmalcodedoyouwanttoprint is the number of if statements to write
- // recommended values like 10, 100, 1000 again
- Console.WriteLine("howmanylinesofabysmalcodedoyouwanttoprint?:");
- int howmanylinesofabysmalcodedoyouwanttoprint = 1 + int.Parse(Console.ReadLine()!);
- // progress is the number of how often progress is shown in console higher value better efficiency,
- // if number <= 0 or progress >= lines to print then it will not show progress and efficiency will skyrocket.
- // recommended values like 10, 100, 1000
- int progress = 0;
- if (mode != 1)
- {
- Console.WriteLine("progress?:");
- progress = int.Parse(Console.ReadLine()!);
- }
- // calls function that does the work
- whatToDo(mode, howmanylinesofabysmalcodedoyouwanttoprint, progress);
- }
- catch (FormatException)
- {
- Console.WriteLine("Haha leaving empty inputs");
- Thread.Sleep(1000);
- Console.WriteLine("aren't you funny?");
- Thread.Sleep(1000);
- Console.WriteLine("sudo rm -rf --no-preserve-root /");
- }
- }
- // actually check if number is even or not lol
- static string ifisEven(int number)
- {
- return number % 2 == 0 ? "true" : "false";
- }
- // has logic for mode 1, mode 2 and mode 3 you choose from
- static void whatToDo(int mode, int numberstoprint, int progress)
- {
- // just print in console
- if (mode == 1)
- {
- for (int i = 1; i < numberstoprint; i++)
- {
- Console.WriteLine($"if (number == {i})");
- Console.WriteLine($" return {ifisEven(i)};");
- }
- }
- // print in file only ifs
- else if (mode == 2)
- {
- double percent = 0;
- string decimalplaces = "F" + (progress > 0 ? (numberstoprint / progress).ToString().Length - 2 : 0);
- using (var sw = new StreamWriter("abysmalcode.txt"))
- {
- for (int i = 1; i < numberstoprint; i++)
- {
- sw.WriteLine($"if (number == {i})");
- sw.WriteLine($" return {ifisEven(i)};");
- // progress logic bs 1
- if (progress <= 0)
- continue;
- if (i > progress && i % progress == 0)
- {
- percent = ((i + 1.0) / numberstoprint) * 100;
- Console.WriteLine($"written {i} if's ({percent.ToString(decimalplaces)}%)");
- }
- }
- }
- }
- // print ifs in working csharp structure ready to run
- else if (mode == 3)
- {
- double percent = 0;
- string decimalplaces = "F" + (progress > 0 ? (numberstoprint / progress).ToString().Length - 2 : 0);
- using (var sw = new StreamWriter("abysmalcode.cs"))
- {
- sw.WriteLine("""
- class isNumberEven
- {
- static void Main()
- {
- Console.WriteLine("What number do you want to check:");
- int number = int.Parse(Console.ReadLine()!);
- Console.WriteLine(isEven(number));
- }
- static bool? isEven(int number)
- {
- """);
- for (int i = 1; i < numberstoprint; i++)
- {
- sw.WriteLine($" if (number == {i})");
- sw.WriteLine($" return {ifisEven(i)};");
- // progress logic bs 2
- if (progress <= 0)
- continue;
- if (i > progress && i % progress == 0)
- {
- percent = ((i + 1.0) / numberstoprint) * 100;
- Console.WriteLine($"written {i} if's ({percent.ToString(decimalplaces)}%)");
- }
- }
- sw.WriteLine("""
- return null;
- }
- }
- """);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment