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?

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

We just wait out for the overflow

16 hours ago
sathdo
:j::g::c:

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

15 hours ago
Same-Letter6378

What happens if you run out of ram?

15 hours ago
goldenfrogs17

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

14 hours ago
kraskaskaCreature
:kt::lsp:

swap

14 hours ago
tapita69

we autoscale machines with more ram and keep going!

13 hours 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.

13 hours ago
AndreLinoge55
:sw:

just download more RAM

12 hours 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?

7 hours ago
IAmASwarmOfBees

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

4 hours ago
PrometheusAlexander
:py::js:

How bout abs?

8 hours ago
secret_green_link

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

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

2 hours ago
PinkSwayy

Technically correct. Also a speedrun to stack overflow

15 hours ago
wyldcraft

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

15 hours ago
theoht_

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

8 hours ago
Excellent-Refuse4883

IsEven(1000000000)

15 hours 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).

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

7 hours ago
goldenfrogs17

I finally understand recursion.

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

🫡

7 hours ago
FRleo_85
:py:

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

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

This is awesome

7 hours ago
FRleo_85
:py:

thank you 😅

7 hours ago
Obvious_Tea_8244

Somebody must’ve screenshotted another PirateSoftware project.

15 hours ago
PossibilityTasty

Did you just UperCamelCase a Python function?

15 hours ago
Excellent-Refuse4883

15 hours ago
x3n0m0rph3us

Old post.

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

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

7 hours ago
x3n0m0rph3us

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

16 minutes ago
Bonzie_57 OP
:ru::ts::py::ansible:

5 minutes 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 hour ago
strikerdude10

Almost there. Just needs some memoization!

12 hours ago
Reasonable-Hair-187

Why are we going back to this?

14 hours ago