It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.
For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.
/u/Flamme2, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.
booo! in this house we write countably infinite lines of code to accomplish our goals. call it "quantum computing, minus the quantum so everything takes a lot longer"
Edit: oh, you‘re an actual human?! I thought it was a bot. So I want to apologize for my misunderstanding and thankfully greet to you: hello fellow transcriber (:
That depends on your definition of "more than int32", because it loses precision before it reaches the int64 limit and can't store every value between int32 limit and int64 limit - it uses floating point numbers, so it's not really comparable, it's not just a "bigger range"
This is pure genius only because of the fact that he thinks that not having enough if statements would be the problem here. He needs some kind of award.
Does it bother anyone else that this isn't really "isNumber", but should be called "isInteger"? Just to put a cherry on top of the insanity. This would fail with 3.14, but that's definitely a number.
It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.
For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.
/u/rpmerf, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.
48
u/liuziangexit Apr 27 '21
I was wondering maybe we should add a hashtable, each key is an individual natural number except 0, so we can verify an given input very fast!
code would be:
return allNaturalNumber.contains(input);And this new algorithm will be O(1) complexity which is better than the OP's O(n) solution. Am i smart?
366
u/Costyyy Apr 27 '21
I'm sure they'll manage to make checks for all numbers
413
u/[deleted] Apr 27 '21
The "Add more checks" says it all :-|
2
u/arvenyon Apr 27 '21
Hijacking this post to ask. Whats the tool called to beautify code and export as picture like here in the post done?
169
u/mareksl Apr 27 '21
That looks like a totally contrived example, and it's not even correctly typed.
117
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Apr 27 '21 edited Apr 27 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
73
u/Speedyjens Apr 27 '21
If the only tool you know is a hammer then everything starts to look like nails.
33
u/Yctallua Apr 27 '21
I gotchu
I'm on mobile, don't hate me for being lazy
Edit: typo
8
u/CW_Waster Apr 27 '21
I hope they use a programm to write the next lines...
22
u/Swaroog23 Apr 27 '21
Yandere-dev-kun, is that you?
11
u/XnaK_ Apr 27 '21
This is pure genius only because of the fact that he thinks that not having enough if statements would be the problem here. He needs some kind of award.
5
u/accuracy_frosty Apr 27 '21
This looks like the code they cook up in Hollywood shows
4
u/DarkSilux Apr 27 '21
“TODO: add more checks” Scary
3
u/egehurturk int a = 3; if (a == 3) {return a;} else {return 3;} Apr 27 '21
Imagine the developer who looks at this piece of shit and sees the
TODO: add more checks3
u/TheRealPitabred Apr 27 '21
Does it bother anyone else that this isn't really "isNumber", but should be called "isInteger"? Just to put a cherry on top of the insanity. This would fail with 3.14, but that's definitely a number.
3
u/green_kerbal Apr 27 '21
my solution in C:
int input; switch (input) case 1 : {} case 2: {}
etc
3
u/Rajarshi1993 Apr 27 '21
No offense, but this looks fake.
3
u/Aesfb_ Apr 28 '21
what is up guys this is yandere dev and today we are going to be starting day one of my programming course, beginner to master
2
u/[deleted] Apr 27 '21
It's pretty funny how most people here can't tell this is satire.
2
u/rpmerf Apr 27 '21 edited Apr 27 '21
Java:
Public boolean isNum(String input) { try { Integer.parse(input); return true; } Catch (exception e) { return false; } } Or use regex.
\d*$
2
u/[deleted] Apr 27 '21 edited Apr 28 '21
The real question tho is why isn't 11 a number?
2
u/Benimation Apr 27 '21
Maybe you should try making a list of all the things that aren't a number
2
u/Needleroozer Apr 27 '21
Any idiot knows the way to do this is convert the input to a string and then use a regular expression to look for ASCII codes in the digits range.
Well, okay, not this idiot. This idiot's figured out a new way.
2
u/Farpafraf Apr 27 '21
obvious satire
2
u/sivikiwi93 Apr 27 '21
No fucking way the if-declaration is written by whoever wrote the rest of the code lmao
2
u/[deleted] Apr 27 '21
The “TODO: add more checks” part will do the scaling. Good design.
2
u/ZeroGainZ Apr 27 '21
Sometimes it's easier to do the opposite, determine if it's not a number. Test against all possible strings, objects, arrays, booleans, etc.
2
u/icepc Apr 27 '21
javascript has a typeOf() function, in case you're curious
2
u/fugogugo Apr 28 '21
11 is not a number
this is racist
2
u/Ochidi Apr 28 '21
// TODO: Add the rest of the numbers
2
u/sk8r_dude Apr 28 '21
The things is, you don’t need anything more than ifs to make this better.
Edit: oh wait this is typescript. Nvm idk
2
u/eslint Apr 30 '21
but what is the point if they're using typescript anyways lmao
2
u/Ph4nt0m_Hydra1 May 08 '21
Please for the love of god just check for a range of numbers instead of using individual if statements to check every single fucking number
3
u/Hafas_ Apr 27 '21
The most elegant solution I could come up with:
1
u/[deleted] Apr 27 '21
B-but... why?
1
u/[deleted] Apr 27 '21
1
u/Verbose_Code Apr 27 '21
If only there was some operator for comparing the input to a range of numbers...
1
u/Tunro Apr 27 '21
I feel like this is bs, because why would someone make a todo comment if theyre this incompetent with functions.
On the other hand, I know people
1
u/Terrain2 Apr 27 '21
1
u/HerissonMignion Apr 28 '21
If loop
1
u/Nevix20 May 02 '21
It must be fake
1
u/siddharth904 Aug 12 '21
Gotta respect the usage of ===
1
u/Spynder shameless stealing content to r/YandereTechnique Apr 27 '21
r/YandereTechnique for beginners