Sometimes programming challenges are a little too easy so you have to add your own twist

Posted Jul 6, 2020, 4:02 AM UTC

Posted Jul 6, 2020, 4:02 AM UTC
Image Transcription: Meme
[Photo of normal Pooh vs. fancy Pooh with code as caption]
[Normal Pooh]
def halfQuarterEighth(n):
return [n/2, n/4, n/8]
[Fancy Pooh]
def half_quarter_eighth(n):
lst = []
for i in range (1, 4):
lst.append(n/(2**i))
return lst
^^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!
I'm pretty sure it's supposed to be normal pooh vs. fancy pooh.
thank you for the correction and sorry for the overlook. i will go ahead and edit my comment :)
Good human
couldn't u just shift the bits
not a python expert, but range(1, 4) would be 1, 2, 3 right?, so would the list not be n/2, n/4 and n/6 or am I missing something?
There’s 2**i which is 2^i
Ah, gotcha, good to know
def foo(n):
return [n/(2**I) for i in range(1,4)]
NameError: name 'I' is not defined
That's what I get for writing a coding comment on my phone.
Don't worry about it, runtime errors barely count
Hey you never know, you might need sixteenths in the future.
[deleted]
The last value in range is non-inclusive, so it loops from 1-3 then breaks.
E:
Wait, you said 6 not 16, no because 2^1 = 2, 2^2 = 4, and 2^3 = 8.
Missed the second multiplier😅
I like dat
Don't use reserved words. list is a reserved word. I would reject this PR in both cases. The first one is using camel case for a function name.
I didn't use list I used lst, and did so because of the reason you stated. I also didn't write the first one, copied it from someone else's challenge submission.
[deleted]
Liiiissssst commmmprrreeheenice work!I was thinking of doing some bit shifts in a list comprehension, but I wanted the meme to be easily readable for people that don't know Python. Also wanted to further parameterize the function to make it scalable, but it's from a challenge website and I'm not the one writing the test cases :/
I'm doing all the easy challenges because I want to 100% all of the challenges on the website (https://edabit.com/ btw, not affiliated).