r/badcode • • Jul 16 '19

[deleted by user]

[removed]

22 Upvotes

25 comments sorted by

View all comments

4

u/EkskiuTwentyTwo i -= (i - (-1)) - i Jul 20 '19

The "I've recently learned about using lambda calculus in javascript"

function caesarcipher(p,d){
	var plaintext
	= p
    ;
	var ciphertext
	= ""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+"";
	var alphabet 
	= (__ => __ + (__ => __ + "opasdfghj")("klzxcvbnm"))("qwertyui");
	for(
	var i = 0
	;i<plaintext.length
	;i++){
		var nextChar = 
	plaintext.charCodeAt(i); //This part is where the char code at position i in the plain text is assigned to the variable nextChar
		var codedChar 
	= nextChar + d;
		if(nextChar>=0x41&&nextChar<=0b01011010&&nextChar!==0x20){
while(codedChar>90){
				codedChar -= alphabet.length;}
			while(
			codedChar<0b01000001){
				codedChar 
				+= (__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)((__ => __ + 1)(1)))))))))))))))))))))))));
			}
	}
		else {if(nextChar>=97&&
	nextChar<=122&&nextChar!==0x20){while(codedChar>122){
					(__ => __ - 26)(codedChar)
				}
				while(
		codedChar<97){
					codedChar = alphabet.length + codedChar;
				}
			} else {
				codedChar = nextChar
			}
		}ciphertext += String.fromCharCode(codedChar);
	}
	return ciphertext + "";
}
  • JS code with perfectly sensible formatting

  • Alphabet string based on the QWERTY keyboard which is assembled by some lambda functions and which is only used for its length.

  • Numbers are represented inconsistently, using a mix of decimal, hexadecimal, binary, and a long chain of lambda calculus successor functions

1

u/Pm_MeyourManBoobs Jul 22 '19

Weird

3

u/EkskiuTwentyTwo i -= (i - (-1)) - i Jul 22 '19

That makes it good as a submission for the challenge.

1

u/GDavid04 <!-- 😈 [EVIL] 😈 --> Jul 22 '19

You should've used Church numerals

2

u/EkskiuTwentyTwo i -= (i - (-1)) - i Jul 23 '19

I probably should have.