The ChekaiBeingLazy algorithm

Che Kai LIANG
2 min readMar 13, 2022

This post will be extremely stupid and cringey. This is your final warning.

Hi there! I am Che-kai, and I want to tell you about a very bad algorithm I designed. I am not proud of it, and I don’t want anyone to use it, because it is both inefficient and stupid, but I find the process of making an algorithm fun and really satisfying.

You see, I was supposed to use the greedy algorithm to write something, but the only problem with that is I have a brain the size of a peanut and I cannot remember. So, I tried using a substitute.

The ChekaiBeingLazy algorithm works like the greedy algorithm, but used for only three to four items.

We define 3 things:

  1. Cost
  2. Required
  3. NeedMore

You see, if you are familiar with the greedy algorithm, it is essentially the same, but way less complicated. If you are not familiar with the greedy algorithm, check here: https://chekailiang.medium.com/python-algorithm-pt-12-greedy-d-cd0e0ea71c0f. I am going to assume you know the basics. Required should be the required amount of “something” and cost is the cost of such. Needmore is 1 at the beginning.

Here is an incomplete example:

print("Greedy test Nr.1")Greedycourse = 0requiredderps = 6

You see, the greedycourse is the cost.

Here we define the essential elements.

print('''Derp1 (3, 3),Derp2 (3, 4),Derp3 (4, 4)''')

Here, we give the list. The cost goes second, and the amount goes first.

choose = 0choose2 = 0needmore = 1

very important.

if choose == 1:Greedycourse + 4requiredderps - 3elif choose == 2:Greedycourse + 4requiredderps - 3

The required amount subtracts and the cost adds depending on the item.

elif choose == 3:Greedycourse + 4requiredderps -4if choose2 == 1:Greedycourse + 3requiredderps - 3elif choose2 == 2:Greedycourse + 4requiredderps - 3elif choose2 == 3:Greedycourse + 4requiredderps -4if requiredderps == 0:print(choose, choose2)needmore = 0print("done")if requiredderps > 0:

See?

needmore = 1if needmore == 1:

And the rest is pretty obvious.

Now, I hope you enjoyed my trash post. Clap for this story, and follow to not miss out on more stupid python stuff, and so long!

--

--