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?

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

We just wait out for the overflow

2 days ago
sathdo
:j::g::c:

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

2 days ago
Same-Letter6378

What happens if you run out of ram?

2 days ago
goldenfrogs17

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

2 days ago
Bubbles_the_bird

Schrödinger’s function

1 day ago
kraskaskaCreature
:kt::lsp:

swap

2 days ago
AdventurousBowl5490
:j: :cp: :ts: :py: :cs: :asm:

What if you run out of page/swap space?

21 hours ago
kraskaskaCreature
:kt::lsp:

download more ram

20 hours ago
tapita69

we autoscale machines with more ram and keep going!

2 days ago
AndreLinoge55
:sw:

just download more RAM

2 days 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?

2 days 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.

2 days ago
NullOfSpace

It rents a cloud server and keeps going

1 day ago
hollowman8904

Then you download more

1 day ago
IAmASwarmOfBees

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

2 days ago
MathMaster85

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

1 day ago
PrometheusAlexander
:py::js:

How bout abs?

2 days ago
secret_green_link

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

2 days 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 day ago
Qzy

Are you the intern at work, by any chance?

1 day ago
PrometheusAlexander
:py::js:

Yeah no

1 day ago
PinkSwayy

Technically correct. Also a speedrun to stack overflow

2 days ago
theoht_

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

2 days ago
wyldcraft

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

2 days ago
Excellent-Refuse4883

IsEven(1000000000)

2 days 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).

2 days 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

2 days ago
goldenfrogs17

I finally understand recursion.

2 days ago
Qzy

I finally understand recursion.

1 day ago
doteroargentino
:cs:

I finally understand recursion.

1 day ago
SphericalGoldfish
:cp:

I finally understand recursion.

23 hours ago
Bonzie_57 OP
:ru::ts::py::ansible:

🫡

2 days ago
FRleo_85
:py:

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

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

This is awesome

2 days ago
FRleo_85
:py:

thank you 😅

2 days ago
Obvious_Tea_8244

Somebody must’ve screenshotted another PirateSoftware project.

2 days ago
PossibilityTasty

Did you just UperCamelCase a Python function?

2 days ago
Excellent-Refuse4883

2 days 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 day ago
strikerdude10

Almost there. Just needs some memoization!

2 days ago
meggamatty64
:j::py:

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

1 day ago
TerryHarris408
bool is_even(int i) {
  return !(i&1);
}
21 hours 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

14 hours 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

13 hours ago
x3n0m0rph3us

Old post.

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

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

2 days ago
x3n0m0rph3us

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

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

1 day ago
lgsscout

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

1 day ago
Reasonable-Hair-187

Why are we going back to this?

2 days ago