r/shittyprogramming • • Dec 09 '14

# My simple program which checks if the user input a number or word

Post image
393 Upvotes

r/shittyprogramming • • Jul 11 '16

What's this Pokemongo everyone is on about? I've never heard of this database before

392 Upvotes

is it web scale?


r/shittyprogramming • • May 02 '15

Actually for sale

Post image
389 Upvotes

r/shittyprogramming • • Aug 16 '20

What's the point of breakpoints when I can do this?

Post image
388 Upvotes

r/shittyprogramming • • May 23 '16

[low effort] This makes me very sad

Thumbnail
imgur.com
387 Upvotes

r/shittyprogramming • • Apr 17 '14

"like ur mother borad"

Post image
386 Upvotes

r/shittyprogramming • • Sep 25 '14

Yeah, that'll stop em

Thumbnail
imgur.com
384 Upvotes

r/shittyprogramming • • Oct 21 '18

They both have point in their names.

Post image
383 Upvotes

r/shittyprogramming • • Apr 23 '20

Is 127.0.0.1 down? Or is it just me?

382 Upvotes

r/shittyprogramming • • Jul 03 '15

How to use booleans the safe way

Post image
382 Upvotes

r/shittyprogramming • • Jan 31 '17

<wrong_sub>this</wrong_sup> Meanwhile in a multinational company...

Post image
381 Upvotes

r/shittyprogramming • • Jul 18 '20

super approved Raytracer written in bbc basic

380 Upvotes

r/shittyprogramming • • Nov 28 '18

Thanks for the tip, shitty Korean mobile game!

Post image
380 Upvotes

r/shittyprogramming • • May 16 '22

Babe wake up, new encryption scheme just dropped

379 Upvotes

r/shittyprogramming • • Mar 14 '17

If C++ is so much safer than C, then why I have I been dealing with so much stds after I started working with C++!?

378 Upvotes

r/shittyprogramming • • May 20 '19

super approved Getting started with Python: "Hello World"

375 Upvotes
p = list(map(lambda _: ord(_) - 0x21, "!!&!!dzăC|"))
i = "DÒVV×0Ë×YVR "

while p[2] < len(p):
    if (p[p[2]] & 0xC0) >> 6 == 0:
        p[p[p[2]] & 0x07] = (p[p[2]] & 0x38) >> 3
    elif (p[p[2]] & 0xC0) >> 6 == 1:
        if (p[p[2]] & 0x38) >> 3 == 0:
            p[0] = ((((ord(i[0]) - 0x20) & 128) >> 7) | ((ord(i[0]) - 0x20) << 1)) & 0xFF
            i = i[1:]
        p[p[p[2]] & 0x07] = p[(p[p[2]] & 0x38) >> 3]
        if p[p[2]] & 0x07 == 1:
            print(chr(p[1]), end="")
    elif (p[p[2]] & 0xC0) >> 6 == 2:
        p[p[p[2]] & 0x07] = (p[p[2]] & 0x38) >> 3 + p[p[p[2]] & 0x07]
    else:
        p[p[p[2]] & 0x07] = p[(p[p[2]] & 0x38) >> 3] + p[p[p[2]] & 0x07]
    p[2] += 1
    p[4] = 1 if p[3] == 0 else 0

I know some of the non-Pythoners out there will be a bit confused. Let's walk through it line-by-line, together.

p = list(map(lambda _: ord(_) - 0x21, "!!&!!dzăC|"))

Set up some memory to be used by a virtual CPU.

i = "DÒVV×0Ë×YVR "

The desired text to display. For security, I've encrypted it with a military-grade encryption scheme.

⠀

A blank line to give your eyes a little breather.

while p[2] < len(p):

Make sure we're not reading too far outside of memory (the other bounds check will come in v2.0).

    if (p[p[2]] & 0xC0) >> 6 == 0:

Decode the current instruction, and check if its opcode is 0. The >> 6 makes the code run 6 times faster (we must be careful to not go too fast, so I use smaller amount sometimes).

        p[p[p[2]] & 0x07] = (p[p[2]] & 0x38) >> 3

Handle opcode 0: store an immediate value at a memory address.

    elif (p[p[2]] & 0xC0) >> 6 == 1:

Check for opcode 1.

        if (p[p[2]] & 0x38) >> 3 == 0:

The addresses 0 and 1 are mapped to input and output, respectively. Here we check if the first operand will read from address 0, i.e. the input.

        p[0] = ((((ord(i[0]) - 0x20) & 128) >> 7) | ((ord(i[0]) - 0x20) << 1)) & 0xFF

Read a byte of the input and store it at address 0 (decrypting it first, of course).

        i = i[1:]

Lop off the read byte. It is of no use to anyone now.

    p[p[p[2]] & 0x07] = p[(p[p[2]] & 0x38) >> 3]

Pretty self-explanatory.

    if p[p[2]] & 0x07 == 1:

Check if something was written to the output address.

        print(chr(p[1]), end="")

I forgot what this does, to be honest.

elif (p[p[2]] & 0xC0) >> 6 == 2:

Time to move to opcode 2.

    p[p[p[2]] & 0x07] = (p[p[2]] & 0x38) >> 3 + p[p[p[2]] & 0x07]

Addition: a useful function of any CPU.

else:

Due to budget constraints, there are only 4 opcodes for our CPU.

    p[p[p[2]] & 0x07] = p[(p[p[2]] & 0x38) >> 3] + p[p[p[2]] & 0x07]

More addition.

p[2] += 1

Move on to the next instruction.

p[4] = 1 if p[3] == 0 else 0

Personally, I find flags disgusting. I am no match against project management's requirements, however.

And that's it! I hope this inspires you to get out there and start coding in the language of the future, Java.


r/shittyprogramming • • May 05 '19

Writing code to urinate

Post image
375 Upvotes

r/shittyprogramming • • Jul 22 '15

Not *exactly* programming, but I had to use excel today and needed to display zeros as blanks. Googling turned up Microsoft's solution: color them white.

Post image
373 Upvotes

r/shittyprogramming • • Jun 28 '21

Just got this question on a Java practice test, and I'm so fucking confused

Post image
372 Upvotes

r/shittyprogramming • • Sep 22 '16

super approved PSA: Avoid the company 'localhost', their service sucks!

372 Upvotes

They only show my website at my house! So much for the World Wide Web.


r/shittyprogramming • • Oct 25 '15

super approved I'm having a syntax error in my Perl script. Can someone debug it for me? This is it: ((((((((((()(((()))))))))()()())()))))(()))()())(()()())))))()))(()())())))())()()()())((()))()((())()()())())())))()()()))())()((())()())()))()()()()))()()())))())()()))(()())())))()((()()()())(()))(()((()())())()

372 Upvotes

r/shittyprogramming • • Mar 28 '15

Real men hard-code their JSON

Post image
372 Upvotes

r/shittyprogramming • • Oct 21 '22

Major Government Entity of India

Post image
371 Upvotes

r/shittyprogramming • • Jan 21 '15

Don't get hacked. Use secure integers™.

Thumbnail
imgur.com
371 Upvotes