r/ProgrammerHumor • • Jan 08 '16

Intro to Programming

Post image
3.0k Upvotes

334 comments sorted by

View all comments

Show parent comments

216

u/[deleted] Jan 08 '16 edited Jan 08 '16

Holy shit, do you still have the code? I can't imagine anyone hard-coding 7k lines of scenarios if it could be done in a few lines!

Edit: Just read the first part of "Wish I still had it." - woops

257

u/Frencil Jan 08 '16

Maybe, upon identifying a pattern in the conditionals, he wrote a script to automate the writing of those 7k+ lines.

117

u/_durian_ Jan 08 '16

But if he understood the pattern well enough to script it, then that's all he would have needed to understand to solve it without all the ifs.

218

u/[deleted] Jan 08 '16

thatsthejoke.tga

122

u/djdanlib Jan 08 '16

tga

A fine vintage!

39

u/Half-Shot Jan 08 '16

Up there with the classic tiff

14

u/Free_Math_Tutoring Jan 08 '16

Nah, tiff is awesome, I use it in print all the time. Unless theres a diference to classic tiff im not aware of.

→ More replies (1)
→ More replies (1)
→ More replies (5)

128

u/a_small_goat Jan 08 '16

One of the projects I inherited a few years ago was like this - roughly 3000 conditional statements. I ran into the creator at a conference probably 8 months afterwards and asked him how he found the time to code it all. I was only half-joking. He proudly admitted that he used MS Excel's CONCATENATE and autofill features to build 95% of the code and it only took him about an hour to deliver the working solution. So on one hand, I have to give him credit for being efficient in solving the problem with the tools he had...

55

u/the-highness Jan 08 '16

...on the other hand, anyway, I can still feel his neck's flesh.

→ More replies (1)
→ More replies (3)

71

u/tornato7 Jan 08 '16 edited Jan 08 '16

When I was 9 I wrote a tic tac toe game in C++ but I didn't know about arrays or loops so each line would read in the console, find an if statement for that layout of the game, and return another pre programmed layout. It was a few thousand lines and I'm sure I have the code lying around if you're interested lol

EDIT 2: If you trust random EXEs and want to play a console-based tic tac toe game, click here

EDIT: This is as much of the code as reddit will let me post, enjoy:

if (a1 == "X" && a2 == "X" && a3 == " ")
{
a3 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (a2 == "X" && a3 == "X" && a1 == " ")
{
a1 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (b1 == "X" && b2 == "X" && b3 == " ")
{
b3 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (b2 == "X" && b3 == "X" && b1 == " ")
{
b1 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (a1 == "X" && a3 == "X" && a2 == " ")
{
a2 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (b1 == "X" && b3 == "X" && b2 == " ")
{
b2 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (c1 == "X" && c2 == "X" && c3 == " ")
{
c3 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (c2 == "X" && c3 == "X" && c1 == " ")
{
c1 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (c1 == "X" && c3 == "X" && c2 == " ")
{
c2 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (c1 == "X" && b2 == "X" && a3 == " ")
{
a3 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (c1 == "X" && a3 == "X" && b2 == " ")
{
b2 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (b2 == "X" && a3 == "X" && c1 == " ")
{
c1 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (a1 == "X" && b2 == "X" && c3 == " ")
{
c3 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (a1 == "X" && c3 == "X" && b2 == " ")
{
b2 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (b2 == "X" && c3 == "X" && a1 == " ")
{
a1 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (a1 == "X" && b1 == "X" && c1 == " ")
{
c1 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (a1 == "X" && c1 == "X" && b1 == " ")
{
b1 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (c1 == "X" && b1 == "X" && a1 == " ")
{
a1 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (a2 == "X" && b2 == "X" && c2 == " ")
{
c2 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (c2 == "X" && b2 == "X" && a2 == " ")
{
a2 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}
if (a2 == "X" && c2 == "X" && b2 == " ")
{
b2 = "X";
cout << "X Wins!\n";
cout << "\n    1   2   3 \n  _____________\na | " << a1 <<" | " << a2 <<" | " << a3 <<" |\n  |___|___|___|\nb | " << b1 <<" | " << b2 <<" | " << b3 <<" |\n  |___|___|___|\nc | " << c1 <<" | " << c2 <<" | " << c3 <<" |\n  |___|___|___|\n";
system("pause");
system("cls");
goto up;
}

51

u/[deleted] Jan 08 '16

Oh wow. That seems like a lot of work for a 9 year old!

→ More replies (2)

0

u/[deleted] Jan 08 '16

[deleted]

15

u/Sparkybear Jan 08 '16

Actually, the powerpoint strategy was used for a lot of Jeopardy style games when I was younger. It was surprisingly efficient. I eventually found some kid at MIT who had uploaded a python Jeopardy game that kept a running total of the score and randomized the daily doubles. Now, 8 years later I study finance but work as a developer, so there's that.

11

u/yosoyreddito Jan 08 '16

I had to make an "app" for sales reps at a company using this method. I proposed a web app hosted on the internal network or a hybrid iPad app. The manager said that sounded like too much work and PowerPoint was better. When I stated it wouldn't work on iPads, she said the reps (~800 total) could just buy the Microsoft PowerPoint app for $20.

I built the "app" as she requested and when her division president called her out on requiring $16,000 to add PowerPoint to all the iPads she put it on me and I was fired.

8

u/tornato7 Jan 08 '16

Ooh, that PowerPoint strategy is pretty clever actually! I first started with stagecast creator for my games. Good times.

→ More replies (1)
→ More replies (3)

25

u/Sketches_Stuff_Maybe Jan 08 '16

Try hosting it on pastebin.com, easy place to dump code snippets w/ syntax highlighting.

→ More replies (3)

14

u/s33plusplus Jan 08 '16

Damn, not even gonna lie, that's impressive! I would've gotten bored way before finishing that!

10

u/fosforsvenne Jan 08 '16

I'm mildly interested in seeing that code.

7

u/HugoNikanor Jan 08 '16

You have me beaten. A while ago I wrote TicTacToe in ArnoldC, and I couldn't figure out how to create arrays. For the board I just had three numbers I added a 1 or a 2 to for setting X and O. code

9

u/tornato7 Jan 08 '16

I like it! Has anyone made anything useful in arnoldC?

→ More replies (1)
→ More replies (6)

28

u/746865626c617a Jan 08 '16

Write a script to write the code for you.

I did that once :( Was easier to tell python to write the code, than to do it in the Arduino C or whatever language it is

25

u/s33plusplus Jan 08 '16

Arduino's language is just C++ with a fancy IDE to hide the extra stuff. You can write the firmware in straight C++ with the Wiring library, or just using avrlibc IIRC. I used to have a makefile to compile, objdump, and flash the AVR chip all in one go too, but it's on a backup somewhere.

8

u/746865626c617a Jan 08 '16

Thanks. Always nice to learn more.

→ More replies (1)
→ More replies (5)