MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/shittyprogramming/comments/ocbfh1/guys_i_figured_it_out/
r/shittyprogramming • u/s3ddd • Jul 02 '21
15 comments sorted by
18
for the doubters
def is_even?(num)%w{0 2 4 6 8}.include?(num.to_s[-1])endputs is_even?(20320492305478203848234802384023848230482301)puts is_even?(20320492305478203848234802384023848230482308)
def is_even?(num)
%w{0 2 4 6 8}.include?(num.to_s[-1])
end
puts is_even?(20320492305478203848234802384023848230482301)
puts is_even?(20320492305478203848234802384023848230482308)
9
What language is this?
7 u/highaltitudesqurrel Jul 02 '21 Looks like Ruby 3 u/s3ddd Jul 03 '21 yes indeed 0 u/[deleted] Jul 03 '21 [deleted] — view deleted comment 3 u/PityUpvote Jul 03 '21 Ruby just allows whatever syntax you want 2 u/permalink_save Jul 03 '21 And a good bit of smalltalk
7
Looks like Ruby
3 u/s3ddd Jul 03 '21 yes indeed 0 u/[deleted] Jul 03 '21 [deleted] — view deleted comment 3 u/PityUpvote Jul 03 '21 Ruby just allows whatever syntax you want 2 u/permalink_save Jul 03 '21 And a good bit of smalltalk
3
yes indeed
0
[deleted] — view deleted comment
3 u/PityUpvote Jul 03 '21 Ruby just allows whatever syntax you want 2 u/permalink_save Jul 03 '21 And a good bit of smalltalk
Ruby just allows whatever syntax you want
2
And a good bit of smalltalk
53
for my python homies
is_even = lambda num: str(num)[-1] in "02468"
17 u/[deleted] Jul 02 '21 Typescript Gangconst isEven = (n: number) => "02468".includes(`${n}`.slice(-1)) 13 u/Earhacker Jul 02 '21 Missing return type smh 8 u/malduvias Jul 02 '21 Sub relevant. 12 u/[deleted] Jul 02 '21 it's trivially inferred, pr rejected
17
Typescript Gang
const isEven = (n: number) => "02468".includes(`${n}`.slice(-1))
13 u/Earhacker Jul 02 '21 Missing return type smh 8 u/malduvias Jul 02 '21 Sub relevant. 12 u/[deleted] Jul 02 '21 it's trivially inferred, pr rejected
13
Missing return type smh
8 u/malduvias Jul 02 '21 Sub relevant. 12 u/[deleted] Jul 02 '21 it's trivially inferred, pr rejected
8
Sub relevant.
12 u/[deleted] Jul 02 '21 it's trivially inferred, pr rejected
12
it's trivially inferred, pr rejected
32
This is just the same as the "real" implementation in base 10 instead of 2
10 u/Kangalioo Jul 02 '21 Mind blown
10
Mind blown
I approve because it validates my courses in number theory
1 u/nyaisagod Jul 03 '21 Clearly this is for base 10.
1
Clearly this is for base 10.
18
u/s3ddd Jul 02 '21
for the doubters
def is_even?(num)%w{0 2 4 6 8}.include?(num.to_s[-1])endputs is_even?(20320492305478203848234802384023848230482301)puts is_even?(20320492305478203848234802384023848230482308)9
u/TheeJazz Jul 02 '21
What language is this?
53
u/PityUpvote Jul 02 '21
for my python homies
32
u/Naimensoe Jul 02 '21
This is just the same as the "real" implementation in base 10 instead of 2
12
u/waiting4op2deliver Jul 02 '21
I approve because it validates my courses in number theory
0
u/[deleted] Jul 03 '21
[deleted] — view deleted comment