+ 4

Bad Programming Challenge

I heard a friend in comp sci was giving a assignment to make the worst program to add 3 numbers. It had this whole lesson to teach people to use good programming practices by adding in a twist. -after everyone had written thire programs they exchanged them with a classmate and the classmate had to modify it. The point of this assignment was with programming alot of the time you'll find yourself reading other peoples code and it may come across as incomprehensible or be just plain poorly written...it ended with the quote "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." The point of this is not to encourage bad programming practices. When writeing code that will be used for anything useful you should always code for readability-however as a challenge it seemed kinda fun so if anyone wants to try writeing the worst addition program feel free to join me. it can be as obviously or as obfuscated as you like the only requirement is for it to add 3 (user defined) numbers and output thire result. A quick c example for obsfucating it unduly https://code.sololearn.com/cwyIdpHn1TkG/#c #include <stdio.h> #define magic(A,B,C) asm("addl %%ebx,%%eax \n\t addl %%ecx, %%eax \n\t movl %%eax, %%ebx \n\t andl $0x507A1014, %%eax \n\t movl %%ebx, %%ecx \n\t andl $0x86044A81, %%ebx \n\t andl $0x2981A56A, %%ecx \n\t":"=a"(A),"=b"(B),"=c"(C):"a"(A),"b"(B),"c"(C)) int main() { int A=10,B=42,C=53; //default numbers replace with your own by adding 3 numbers scanf("%d %d %d",&A,&B,&C); magic(A,B,C); printf("%d",A^B^C); return 0; } I also made a github randomly https://github.com/BlueLightning42/Bad-Addition Either way if anyone posts a code feel free to try to decode it and change it so that it takes the first number and subtracts the second two numbers from it-it can be a lesson in deciphering other peoples codes or simply for fun.

1st Jun 2018, 7:11 PM
Justin Whittam-Geskes
Justin Whittam-Geskes - avatar
4 Respostas
+ 5
Justin Whittam-Geskes if you use the android app, you'll find 'What's going on?' / 'Share Anything Coding' / 'Share your thoughts' written in a place beside your avatar. Tap it, and you are on your way to creating a feed.
2nd Jun 2018, 6:31 PM
DAB
DAB - avatar
+ 5
I really like this challenge, but I'm busy with exams. Also, this question had better be posted as a feed. It's programming related, but not a question. [OFF-TOPIC] You can turn easy, readable JavaScript code into some nasty, vertigo-causing stuff using this: https://code.sololearn.com/WaW0SXDs2IM6/?ref=app
2nd Jun 2018, 7:56 AM
DAB
DAB - avatar
0
sorry to be a bother but how would I go about posting it as a feed- I tried looking about the app for a bit before giving up and just posting it in the disscussions where I've seen other challenges
2nd Jun 2018, 2:24 PM
Justin Whittam-Geskes
Justin Whittam-Geskes - avatar
0
I've seen bad coding with very little/no comments, too many comments, and terrible reading layout. While some of them ran, they weren't lean and often contained bloated scripts which were a resource hog.
2nd Jun 2018, 4:36 PM
Apple Blossom
Apple Blossom - avatar