ProgrammerHumor

iEvenIsIntuative

iEvenIsIntuative
https://i.redd.it/onk8xxoa8ycf1.jpeg
Reddit

Discussion

secret_green_link

isEven(-8)

Uh? What do you mean that's not how it works?

1 week ago
Bonzie_57 OP
:ru::ts::py::ansible:

We just wait out for the overflow

1 week ago
sathdo
:j::g::c:

Python 3 ints don't overflow, they just allocate more ram.

1 week ago
Same-Letter6378

What happens if you run out of ram?

1 week ago
goldenfrogs17

then it's odd, or even, it depends on host system

1 week ago
Bubbles_the_bird

Schrödinger’s function

1 week ago
kraskaskaCreature
:kt::lsp:

swap

1 week ago
AdventurousBowl5490
:j: :cp: :ts: :py: :cs: :asm:

What if you run out of page/swap space?

6 days ago
kraskaskaCreature
:kt::lsp:

download more ram

6 days ago
tapita69

we autoscale machines with more ram and keep going!

1 week ago
AndreLinoge55
:sw:

just download more RAM

1 week ago
Disastrous-Event2353

Is there a python library to automate installing more ram? Or would that be too dangerous, since a script could just download all the ram in the world and everyone else would have none?

1 week ago
kampi1989

Kein Problem. Einfach auf den swap auslagern oder das Programm mit dem Hinweis pausieren das mehr RAM nachgerüstet werden muss. Wenn der swap ausgeht, wird einfach auf die Cloud umgestiegen.

1 week ago
NullOfSpace

It rents a cloud server and keeps going

1 week ago
hollowman8904

Then you download more

1 week ago
Tonmasson

In this case you probably would get stack overflow first. But if you set the stack limit high or have very little free RAM, then honestly idk, I guess it would crash, just another way

5 days ago
IAmASwarmOfBees

Also, python doesn't allow infinite recursion, it has a maximum depth.

1 week ago
MathMaster85

Yes, but there's a recursion limit. I believe it's about 1000 by default.

1 week ago
PrometheusAlexander
:py::js:

How bout abs?

1 week ago
secret_green_link

Still too much fat percentage for them to show I'm afraid :P

1 week ago
PrometheusAlexander
:py::js:

return IsEven(abs(-8)-2) would work

Edit: Tested and it does. Although can't fathom why not just return num % 2 == 0

1 week ago
Qzy

Are you the intern at work, by any chance?

1 week ago
PrometheusAlexander
:py::js:

Yeah no

1 week ago
PinkSwayy

Technically correct. Also a speedrun to stack overflow

1 week ago
theoht_

genuinely i sometimes forget that stack overflow is, like, a thing, and not just a website

1 week ago
wyldcraft

Some languages will optimize the tail recursion, but not python.

1 week ago
Excellent-Refuse4883

IsEven(1000000000)

1 week ago
callyalater
:kt:

Inside the else block, you could nest another if/else statement to check if the number is less than 0 and if it is, return isEven(num+2), else return isEven(num-2).

1 week ago
Bonzie_57 OP
:ru::ts::py::ansible:

I only push code that will break with edge cases that aren’t even really edge cases

1 week ago
goldenfrogs17

I finally understand recursion.

1 week ago
Qzy

I finally understand recursion.

1 week ago
doteroargentino
:cs:

I finally understand recursion.

1 week ago
SphericalGoldfish
:cp:

I finally understand recursion.

6 days ago
Samisacoolcat

RecursionError: maximum recursion depth exceeded

4 days ago
Bonzie_57 OP
:ru::ts::py::ansible:

🫡

1 week ago
FRleo_85
:py:

may i interest you in other ways to find if a number is even? https://github.com/desaleo/is-even

1 week ago
Bonzie_57 OP
:ru::ts::py::ansible:

This is awesome

1 week ago
FRleo_85
:py:

thank you 😅

1 week ago
Obvious_Tea_8244

Somebody must’ve screenshotted another PirateSoftware project.

1 week ago
PossibilityTasty

Did you just UperCamelCase a Python function?

1 week ago
Excellent-Refuse4883

1 week ago
Then-Hurry-5197

I created my own toy interpreted language and I didn't feel like adding the modulas operator at the time(And it obviously didn't have the bitwise operators) So I ended up using this exact method lol

1 week ago
TheHyperbolicTangent

What is this? Recycling badly written isEven memes over and over again. Chill, the joke is dead, don’t keep hammering it in the head

6 days ago
Bonzie_57 OP
:ru::ts::py::ansible:

It’s recursion dude, we haven’t hit the basecase yet.

Plus, you’re on a circlejerk sub, get over it

6 days ago
x3n0m0rph3us

Old post.

1 week ago
Bonzie_57 OP
:ru::ts::py::ansible:

I just wrote this in my notes app, whatcha on man

1 week ago
x3n0m0rph3us

It is an old post because the "is even" algorithm keeps being posted to this sub every month or so.

1 week ago
Bonzie_57 OP
:ru::ts::py::ansible:

1 week ago
lgsscout

so are the "this is repost" responses, and you still did... where is your original response for the unoriginal post?

1 week ago
strikerdude10

Almost there. Just needs some memoization!

1 week ago
meggamatty64
:j::py:

Make sure you return math.abs(num-2) so it works with negative numbers

1 week ago
TerryHarris408
bool is_even(int i) {
  return !(i&1);
}
6 days ago
OkSalamander2218

You should keep a cached list of numbers that have previously been calculated to be even to improve efficiency.

3 days ago
Reasonable-Hair-187

Why are we going back to this?

1 week ago