Skip to main content
added 1115 characters in body
Source Link
the default.
  • 8.5k
  • 1
  • 37
  • 63

Brainfuck interpreter, updated to crack the third cop (.=;). Input by command line arguments; I couldn't figure out how to do output without ., but IO is not necessary for Turing-completeness. Maybe it's possible to do it by using something from the namespace System.Linq.Expressions.

classnamespace ProgramSystem { 	staticnamespace voidCollections Main(string[]{ namespace args)Generic { 		if(new	class System.Collections.Generic.List<byte>MyList : Dictionary<int, byte> 	{ 		public MyList(string s, string inp) 		{ 			if(0} is var tapepc) {} 		if			if(0 is var pci) {} 		if			if(0 is var iinp_i) {} 		while		 	if(pcTryAdd(i, <0) args[0].Lengthis int) {} 					try { // to exit cleanly at end of program 			if			while(args[0][pc].Equalstrue) 			{ 				if((s[pc] ^ '+') < 1) if(tape[i]++Set(i,(byte)-~this[i]) <is 0int) {} 			if				if(args[0][pc].Equals(s[pc] ^ '-') < 1) if(tape[i]-Set(i,(byte)~-this[i]) <is 0int) {} 			if				if(args[0][pc].Equals(s[pc] ^ '>') < 1) 							{ 				if					if(i++ < 0) {} 				if					if(TryAdd(i > tape.Count - 1), if(tape.Add(0) is int) {} 							} 			if				if(args[0][pc].Equals(s[pc] ^ '<') < 1) 							{ 				if					if(i-- < 0) {} 				if(i < 0) if					if(tape.InsertTryAdd(0i, 0) is int || i++ > 0) {} 							} 			if				//if(args[0][pc].Equals('.'s[pc] ^ 46) < 1 && System.Console.Write((char)tape[i]this[i]) is int) {} // uncomment for output 			if				if(args[0][pc].Equals(s[pc] ^ ',') < 1) 							{ 				if					try 					{ 						if(System.Console.ReadSet(i, (byte)inp[inp_i++]) is var cint) {} 				if(c < 0 && c++ < 0) {					} 				while(tape[i] > c || tape[i] < c) if(tape[i]++ > 0)catch { } 							} 			if				if(args[0][pc].Equals(s[pc] ^ '[') < 1 && tape[i]this[i] < 1) 							{ 				if					if(1 is var bal) {} 				if					if(pc++ > 0) {} 				while					while(bal > 0) 									{ 					if						if(args[0][pc].Equals(s[pc] ^ '[') < 1 && bal++ < 0) {} 					if						if(args[0][pc].Equals(s[pc] ^ ']') < 1 && bal-- < 0) {} 					if						if(pc++ > 0) {} 									} 				if					if(pc-- < 0) {} 							} 			if				if(args[0][pc].Equals(s[pc] ^ ']') < 1 && tape[i]this[i] > 0) 							{ 				if					if(1 is var bal) {} 				if					if(pc-- > 0) {} 				while					while(bal > 0) 									{ 					if						if(args[0][pc].Equals(s[pc] ^ ']') < 1 && bal++ < 0) {} 					if						if(args[0][pc].Equals(s[pc] ^ '[') < 1 && bal-- < 0) {} 					if						if(pc-- > 0) {} 									} 							} 			if				if(pc++ < 0) {} 			} 			} catch {} 		} 		void Set(int i, byte s) 		{ 			try { if(Remove(i) is int){} } catch {} 			if(Add(i, s) is int) {} 		} 	} 	class Program { 		static void Main(string[] args) { 			try { 				if(new MyList(args[0], args[1]) is var x) {} 			} catch { 				if(new MyList(args[0], "") is var x) {} 			} 		} 	} }}}   

Brainfuck interpreter; cracks both sort-of-cops at once.

Try it online!Try it online!

class Program { 	static void Main(string[] args) { 		if(new System.Collections.Generic.List<byte>(){0} is var tape) {} 		if(0 is var pc) {} 		if(0 is var i) {} 		while(pc < args[0].Length) 		{ 			if(args[0][pc].Equals('+')) if(tape[i]++ < 0) {} 			if(args[0][pc].Equals('-')) if(tape[i]-- < 0) {} 			if(args[0][pc].Equals('>')) 			{ 				if(i++ < 0) {} 				if(i > tape.Count - 1) if(tape.Add(0) is int) {} 			} 			if(args[0][pc].Equals('<')) 			{ 				if(i-- < 0) {} 				if(i < 0) if(tape.Insert(0, 0) is int || i++ > 0) {} 			} 			if(args[0][pc].Equals('.') && System.Console.Write((char)tape[i]) is int) {} 			if(args[0][pc].Equals(',')) 			{ 				if(System.Console.Read() is var c) {} 				if(c < 0 && c++ < 0) {} 				while(tape[i] > c || tape[i] < c) if(tape[i]++ > 0) {} 			} 			if(args[0][pc].Equals('[') && tape[i] < 1) 			{ 				if(1 is var bal) {} 				if(pc++ > 0) {} 				while(bal > 0) 				{ 					if(args[0][pc].Equals('[') && bal++ < 0) {} 					if(args[0][pc].Equals(']') && bal-- < 0) {} 					if(pc++ > 0) {} 				} 				if(pc-- < 0) {} 			} 			if(args[0][pc].Equals(']') && tape[i] > 0) 			{ 				if(1 is var bal) {} 				if(pc-- > 0) {} 				while(bal > 0) 				{ 					if(args[0][pc].Equals(']') && bal++ < 0) {} 					if(args[0][pc].Equals('[') && bal-- < 0) {} 					if(pc-- > 0) {} 				} 			} 			if(pc++ < 0) {} 		} 	} } 

Brainfuck interpreter; cracks both sort-of-cops at once.

Try it online!

Brainfuck interpreter, updated to crack the third cop (.=;). Input by command line arguments; I couldn't figure out how to do output without ., but IO is not necessary for Turing-completeness. Maybe it's possible to do it by using something from the namespace System.Linq.Expressions.

namespace System { namespace Collections { namespace Generic { 	class MyList : Dictionary<int, byte> 	{ 		public MyList(string s, string inp) 		{ 			if(0 is var pc) {} 			if(0 is var i) {} 			if(0 is var inp_i) {} 		 	if(TryAdd(i, 0) is int) {} 			try { // to exit cleanly at end of program 			while(true) 			{ 				if((s[pc] ^ '+') < 1) if(Set(i,(byte)-~this[i]) is int) {} 				if((s[pc] ^ '-') < 1) if(Set(i,(byte)~-this[i]) is int) {} 				if((s[pc] ^ '>') < 1) 				{ 					if(i++ < 0) {} 					if(TryAdd(i, 0) is int) {} 				} 				if((s[pc] ^ '<') < 1) 				{ 					if(i-- < 0) {} 					if(TryAdd(i, 0) is int) {} 				} 				//if((s[pc] ^ 46) < 1 && Console.Write((char)this[i]) is int) {} // uncomment for output 				if((s[pc] ^ ',') < 1) 				{ 					try 					{ 						if(Set(i, (byte)inp[inp_i++]) is int) {} 					} catch { } 				} 				if((s[pc] ^ '[') < 1 && this[i] < 1) 				{ 					if(1 is var bal) {} 					if(pc++ > 0) {} 					while(bal > 0) 					{ 						if((s[pc] ^ '[') < 1 && bal++ < 0) {} 						if((s[pc] ^ ']') < 1 && bal-- < 0) {} 						if(pc++ > 0) {} 					} 					if(pc-- < 0) {} 				} 				if((s[pc] ^ ']') < 1 && this[i] > 0) 				{ 					if(1 is var bal) {} 					if(pc-- > 0) {} 					while(bal > 0) 					{ 						if((s[pc] ^ ']') < 1 && bal++ < 0) {} 						if((s[pc] ^ '[') < 1 && bal-- < 0) {} 						if(pc-- > 0) {} 					} 				} 				if(pc++ < 0) {} 			} 			} catch {} 		} 		void Set(int i, byte s) 		{ 			try { if(Remove(i) is int){} } catch {} 			if(Add(i, s) is int) {} 		} 	} 	class Program { 		static void Main(string[] args) { 			try { 				if(new MyList(args[0], args[1]) is var x) {} 			} catch { 				if(new MyList(args[0], "") is var x) {} 			} 		} 	} }}}   

Try it online!

Source Link
the default.
  • 8.5k
  • 1
  • 37
  • 63

C# (Visual C# Compiler), cracks Not A Chair's answer

class Program { 	static void Main(string[] args) { 		if(new System.Collections.Generic.List<byte>(){0} is var tape) {} 		if(0 is var pc) {} 		if(0 is var i) {} 		while(pc < args[0].Length) 		{ 			if(args[0][pc].Equals('+')) if(tape[i]++ < 0) {} 			if(args[0][pc].Equals('-')) if(tape[i]-- < 0) {} 			if(args[0][pc].Equals('>')) 			{ 				if(i++ < 0) {} 				if(i > tape.Count - 1) if(tape.Add(0) is int) {} 			} 			if(args[0][pc].Equals('<')) 			{ 				if(i-- < 0) {} 				if(i < 0) if(tape.Insert(0, 0) is int || i++ > 0) {} 			} 			if(args[0][pc].Equals('.') && System.Console.Write((char)tape[i]) is int) {} 			if(args[0][pc].Equals(',')) 			{ 				if(System.Console.Read() is var c) {} 				if(c < 0 && c++ < 0) {} 				while(tape[i] > c || tape[i] < c) if(tape[i]++ > 0) {} 			} 			if(args[0][pc].Equals('[') && tape[i] < 1) 			{ 				if(1 is var bal) {} 				if(pc++ > 0) {} 				while(bal > 0) 				{ 					if(args[0][pc].Equals('[') && bal++ < 0) {} 					if(args[0][pc].Equals(']') && bal-- < 0) {} 					if(pc++ > 0) {} 				} 				if(pc-- < 0) {} 			} 			if(args[0][pc].Equals(']') && tape[i] > 0) 			{ 				if(1 is var bal) {} 				if(pc-- > 0) {} 				while(bal > 0) 				{ 					if(args[0][pc].Equals(']') && bal++ < 0) {} 					if(args[0][pc].Equals('[') && bal-- < 0) {} 					if(pc-- > 0) {} 				} 			} 			if(pc++ < 0) {} 		} 	} } 

Brainfuck interpreter; cracks both sort-of-cops at once.

Try it online!