Skip to main content
Commonmark migration
Source Link

###A: 95 bytes

A: 95 bytes

###B: 438 + 18 bytes

B: 438 + 18 bytes

###A+B: 533 + 18 bytes

A+B: 533 + 18 bytes

###A: 95 bytes

###B: 438 + 18 bytes

###A+B: 533 + 18 bytes

A: 95 bytes

B: 438 + 18 bytes

A+B: 533 + 18 bytes

added 2 characters in body
Source Link
Kamil Drakari
  • 4.4k
  • 12
  • 21

Program B is weird in isolation, but essentially the same. It creates a Class A containing a static variable i initialized to 0, and then runs the Main method of Class B, which does the same as Program A because A.iA.i is less than 1, and returns before any of the weird stuff. The newlines aren't necessary here, but are important for A+B.

Program B is weird in isolation, but essentially the same. It creates a Class A containing a static variable i initialized to 0, and then runs the Main method of Class B, which does the same as Program A because A.i is less than 1, and returns before any of the weird stuff. The newlines aren't necessary here, but are important for A+B.

Program B is weird in isolation, but essentially the same. It creates a Class A containing a static variable i initialized to 0, and then runs the Main method of Class B, which does the same as Program A because A.i is less than 1, and returns before any of the weird stuff. The newlines aren't necessary here, but are important for A+B.

Fixed a small error and saved a few bytes
Source Link
Kamil Drakari
  • 4.4k
  • 12
  • 21

C# (Visual C# Compiler), 558551 bytes

###A: 9895 bytes

class A{public static boolint i=1<0;statici=2;static void Main(string[]args){System.Console.Write(args[0]);}}// 

Try it online!Try it online!

###B: 442438 + 18 bytes

class A{public static boolint i=1>0;i=0;} class B{static void Main(string[]args){if(A.ii<1){System.Console.Write(args[0]);return;}var a="classa=@"class A{{public static boolint i=1<0;statici=2;static void Main(string[]args){{System.Console.Write(args[0]);}}}}//class A{{public static boolint i=1>0;i=0;}}\nclass class B{{static void Main(string[]args){{if(A.ii<1){{System.Console.Write(args[0]);return;}}var a=a=@{0}{1}{0};System.Console.Write(a,'{0}',a);}}}}";System.Console.Write(a,'"',a);}} 

Try it online!Try it online!

###A+B: 540533 + 18 bytes

class A{public static boolint i=1<0;statici=2;static void Main(string[]args){System.Console.Write(args[0]);}}//class A{public static boolint i=1>0;i=0;} class B{static void Main(string[]args){if(A.ii<1){System.Console.Write(args[0]);return;}var a="classa=@"class A{{public static boolint i=1<0;statici=2;static void Main(string[]args){{System.Console.Write(args[0]);}}}}//class A{{public static boolint i=1>0;i=0;}}\nclass class B{{static void Main(string[]args){{if(A.ii<1){{System.Console.Write(args[0]);return;}}var a=a=@{0}{1}{0};System.Console.Write(a,'{0}',a);}}}}";System.Console.Write(a,'"',a);}} 

Try it online!Try it online!

Program A is straightforward. Class A contains an (unused) static variable i initialized to false2, and prints its first argument when run. The // at the end is important for the A+B code, but does nothing in A itself.

Program B is weird in isolation, but essentially the same. It creates a Class A containing a static variable i initialized to true0, and then runs the Main method of Class B, which does the same as Program A because A.i is trueless than 1, and returns before any of the weird stuff. The newline between the classes isn'tnewlines aren't necessary here, but isare important for A+B.

When combined, the // from Program A comments out the Class A declaration from Program B, but because of the newline Class B is fine, allowing A.i to refer to the false2 value from Program A instead. The Compiler Flag makes the Program run B.Main() since A.Main() also exists. The result is that Program A+B does not output its argument, but instead goes to the following segment of B.Main(), which is basically just the standard C# quine.

C# (Visual C# Compiler), 558 bytes

###A: 98 bytes

class A{public static bool i=1<0;static void Main(string[]args){System.Console.Write(args[0]);}}// 

Try it online!

###B: 442 + 18 bytes

class A{public static bool i=1>0;} class B{static void Main(string[]args){if(A.i){System.Console.Write(args[0]);return;}var a="class A{{public static bool i=1<0;static void Main(string[]args){{System.Console.Write(args[0]);}}}}//class A{{public static bool i=1>0;}}\nclass B{{static void Main(string[]args){{if(A.i){{System.Console.Write(args[0]);return;}}var a={0}{1}{0};System.Console.Write(a,'{0}',a);}}}}";System.Console.Write(a,'"',a);}} 

Try it online!

###A+B: 540 + 18 bytes

class A{public static bool i=1<0;static void Main(string[]args){System.Console.Write(args[0]);}}//class A{public static bool i=1>0;} class B{static void Main(string[]args){if(A.i){System.Console.Write(args[0]);return;}var a="class A{{public static bool i=1<0;static void Main(string[]args){{System.Console.Write(args[0]);}}}}//class A{{public static bool i=1>0;}}\nclass B{{static void Main(string[]args){{if(A.i){{System.Console.Write(args[0]);return;}}var a={0}{1}{0};System.Console.Write(a,'{0}',a);}}}}";System.Console.Write(a,'"',a);}} 

Try it online!

Program A is straightforward. Class A contains an (unused) static variable i initialized to false, and prints its first argument when run. The // at the end is important for the A+B code, but does nothing in A itself.

Program B is weird in isolation, but essentially the same. It creates a Class A containing a static variable i initialized to true, and then runs the Main method of Class B, which does the same as Program A because A.i is true, and returns before any of the weird stuff. The newline between the classes isn't necessary here, but is important for A+B.

When combined, the // from Program A comments out the Class A declaration from Program B, but because of the newline Class B is fine, allowing A.i to refer to the false value from Program A instead. The Compiler Flag makes the Program run B.Main() since A.Main() also exists. The result is that Program A+B does not output its argument, but instead goes to the following segment of B.Main(), which is basically just the standard C# quine.

C# (Visual C# Compiler), 551 bytes

###A: 95 bytes

class A{public static int i=2;static void Main(string[]args){System.Console.Write(args[0]);}}// 

Try it online!

###B: 438 + 18 bytes

class A{public static int i=0;} class B{static void Main(string[]args){if(A.i<1){System.Console.Write(args[0]);return;}var a=@"class A{{public static int i=2;static void Main(string[]args){{System.Console.Write(args[0]);}}}}//class A{{public static int i=0;}} class B{{static void Main(string[]args){{if(A.i<1){{System.Console.Write(args[0]);return;}}var a=@{0}{1}{0};System.Console.Write(a,'{0}',a);}}}}";System.Console.Write(a,'"',a);}} 

Try it online!

###A+B: 533 + 18 bytes

class A{public static int i=2;static void Main(string[]args){System.Console.Write(args[0]);}}//class A{public static int i=0;} class B{static void Main(string[]args){if(A.i<1){System.Console.Write(args[0]);return;}var a=@"class A{{public static int i=2;static void Main(string[]args){{System.Console.Write(args[0]);}}}}//class A{{public static int i=0;}} class B{{static void Main(string[]args){{if(A.i<1){{System.Console.Write(args[0]);return;}}var a=@{0}{1}{0};System.Console.Write(a,'{0}',a);}}}}";System.Console.Write(a,'"',a);}} 

Try it online!

Program A is straightforward. Class A contains an (unused) static variable i initialized to 2, and prints its first argument when run. The // at the end is important for the A+B code, but does nothing in A itself.

Program B is weird in isolation, but essentially the same. It creates a Class A containing a static variable i initialized to 0, and then runs the Main method of Class B, which does the same as Program A because A.i is less than 1, and returns before any of the weird stuff. The newlines aren't necessary here, but are important for A+B.

When combined, the // from Program A comments out the Class A declaration from Program B, but because of the newline Class B is fine, allowing A.i to refer to the 2 value from Program A instead. The Compiler Flag makes the Program run B.Main() since A.Main() also exists. The result is that Program A+B does not output its argument, but instead goes to the following segment of B.Main(), which is basically just the standard C# quine.

Source Link
Kamil Drakari
  • 4.4k
  • 12
  • 21
Loading