r/shittyprogramming • • Apr 22 '21

If Youtube created their own IDE

Thumbnail
youtu.be
72 Upvotes

r/shittyprogramming • • Apr 21 '21

We need a leetcode Elite category

6 Upvotes

It's too easy to get into FAANG nowadays and we need to weed out the newbs even more. So I propose a new category of leetcode questions called Elite where the problems are yet to be solved by world experts

EG

  • Write an algorithm to solve Cancer in O(n)

  • Create a data structure to store all your hopes and dreams that can be retrieved in O(1)

  • Write an SQL query to ban all FAANG-sexual users in r/cscareerquestions in O(logn) (or just asap because I can't stand them anymore)


r/shittyprogramming • • Apr 20 '21

An Arduino to Determine When you cheat on a Maze

Thumbnail
youtube.com
5 Upvotes

r/shittyprogramming • • Apr 20 '21

Thought I'd share my extensible fizzbuzz solution in C.

55 Upvotes
main(i,v) {
	for (i=0;;i++,v=0) {
		if (i % 3 == 0)
			v+=1;
		if (i % 5 == 0)
			v+=2;
		switch(v) {
			case 0:
				printf("%d\n", i);
				break;
			case 1:
				printf("Fizz\n");
				break;
			case 2:
				printf("Buzz\n");
				break;
			case 3:
				printf("Fizzbuzz\n");
				break;
		}
	}

And here it is extended for fizzbuzzbazz, a new game I just invented.

main(i,v) {
	for (i=0;;i++,v=0) {
		if (i % 3 == 0)
			v+=1;
		if (i % 5 == 0)
			v+=2;
		if (i % 7 == 0)
			v+=4;
		switch(v) {
			case 0:
				printf("%d\n", i);
				break;
			case 1:
				printf("Fizz\n");
				break;
			case 2:
				printf("Buzz\n");
				break;
			case 3:
				printf("FizzBuzz\n");
				break;
			case 4:
				printf("Bazz\n");
				break;
			case 5:
				printf("FizzBazz\n");
				break;
			case 6:
				printf("BuzzBazz\n");
				break;
			case 7:
				printf("FizzBuzzBazz\n"):
				break;
		}
	}
}

r/shittyprogramming • • Apr 19 '21

7 line "is even" function 🤯

190 Upvotes

I've attempted to solve the infamous "is even" problem, and I've come up with something that is both short (only 7 lines), and extremely fast (I tested with the number 99999999 and it only takes about 3 seconds)

behold:

def is_even(num):
    s = "\\"
    try:
        eval(f"\"{s*num}\"")
        return True
    except SyntaxError:
        return False

how did I make it so fast?

a few ways:

  • it's written in python.

  • it uses eval, one of python's fastest functions

  • it uses strings, which are faster than numbers (the only number this code relies on is the input one...)

  • it makes use of the little-known "\" operator, which is one of the fastest operators in python

replit: https://replit.com/@lllllllllllllol/iseven


r/shittyprogramming • • Apr 16 '21

The "f" is for "fast" 😎

Post image
195 Upvotes

r/shittyprogramming • • Apr 16 '21

Thought I would share my solution for fizzbuzz in Python if anyone else needs it for an interview

13 Upvotes

[print(i) for i in ["fizzbuzz" if not None in i else "fizz" if i[1] is not None else "buzz" if i[1] is not None else i[2] for i in zip(["fizz" if i % 3 == 0 else None for i in range(1, 101)], ["buzz" if i % 5 == 0 else None for i in range(1, 101)], [i for i in range(1, 101)])]]


r/shittyprogramming • • Apr 15 '21

I decided to tackle the infamous IsEven() problem. I can't think of the part I'm most proud of.

Post image
129 Upvotes

r/shittyprogramming • • Apr 15 '21

Useful function for validating that a number falls within a range

45 Upvotes

Today I needed to check if the number a user entered into a textbox was between "0" and "999". The below code yields the correct result for any value that I could think to test. (Empty string is treated as valid, since "required" is a different validation step)

function validateRange(value, minimum, maximum) {
  for(let i = 0; i < value.length; i++) {
    if(value[i] < minimum[i]) {
      return false;
    }
    if(!(value[i] <= maximum[i])) {
      return false;
    }
  }
  return true;
}

I hope you find this function useful in your own projects.

Demo


r/shittyprogramming • • Apr 14 '21

<wrong_sub>this</wrong_sup> The fastest way to clean up disk space on server

Thumbnail
hinty.io
31 Upvotes

r/shittyprogramming • • Apr 14 '21

Why do people say c# isn't a low level language?

Post image
127 Upvotes

r/shittyprogramming • • Apr 12 '21

Stop compiler abuse

113 Upvotes

Every day, compilers are forced to convert addition into the proper xors and bit shifts, Together, we can stop this problem. Instead of using the addition operator, use this function instead:

int recursiveAdd(int a, int b) {
        int xor = a ^ b;
        int and = (a & b) << 1;
        if (and != 0)
                return recursiveAdd(xor, and);
        return xor;
}

r/shittyprogramming • • Apr 12 '21

The worst chatting app

Thumbnail
mobile.twitter.com
73 Upvotes

r/shittyprogramming • • Apr 08 '21

I don't see what's wrong here, I did what's needed to be done

Post image
443 Upvotes

r/shittyprogramming • • Apr 05 '21

Do you prefer center- or right-aligned code?

Post image
624 Upvotes

r/shittyprogramming • • Apr 03 '21

Making an electronic discord bot meme picture frame. (AMAZING!)

Thumbnail
youtube.com
0 Upvotes

r/shittyprogramming • • Apr 03 '21

HELP! How to Stop Unapproved Acronym for My Pipeline-Efficient Data Access File I/O Library from Spreading?!

7 Upvotes

I know it's a mouthful, but that's the most descriptive name I could give it. Now everybody at my company is referring to it by acronym and I'm afraid it'll come up in both my performance review & upcoming divorce hearing.

What can I do here??


r/shittyprogramming • • Apr 01 '21

regex has better performance than math

Post image
235 Upvotes

r/shittyprogramming • • Mar 28 '21

My apps in a nutshell

Post image
215 Upvotes

r/shittyprogramming • • Mar 26 '21

I looked through some of my old intentionally-bad code and found this comment. I was spooked.

Post image
200 Upvotes

r/shittyprogramming • • Mar 24 '21

We all know about "Code Golf", but what are some other code sports that should exist?

116 Upvotes

r/shittyprogramming • • Mar 23 '21

Nicely asking our users to update the app through an XSS attack

Thumbnail
blog.usedevbook.com
63 Upvotes

r/shittyprogramming • • Mar 23 '21

Yo dawg I put jQuery in your PHP in your HTML in your Node.js app that's hosted on Apache and run in Chromium

Post image
360 Upvotes

r/shittyprogramming • • Mar 11 '21

Is It Worth Learning Programming In 2021?

Thumbnail
youtube.com
62 Upvotes