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

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

Posted Jul 6, 2020, 4:02 AM UTC

8020
wolfmansideburns:py: :js: :sc: :cp: •

Liiiissssst commmmprrreehee nice work!

9
noizedOP:py: :cs:•

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

4
ce-walalang•

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!

3
TheSupahDupah•

I'm pretty sure it's supposed to be normal pooh vs. fancy pooh.

2
ce-walalang•

thank you for the correction and sorry for the overlook. i will go ahead and edit my comment :)

1
[deleted]•

Good human

1
Yin-Hei•

couldn't u just shift the bits

3
dietibol•

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?

2
mr_hard_name:j: :kt: :js:•

There’s 2**i which is 2^i

2
dietibol•

Ah, gotcha, good to know

1
Xelopheris•
def foo(n): 
 return [n/(2**I) for i in range(1,4)]
2
wolfmansideburns:py: :js: :sc: :cp: •
NameError: name 'I' is not defined
1
Xelopheris•

That's what I get for writing a coding comment on my phone.

1
wolfmansideburns:py: :js: :sc: :cp: •

Don't worry about it, runtime errors barely count

1
Kered13•

Hey you never know, you might need sixteenths in the future.

2
[deleted]•

[deleted]

1
noizedOP:py: :cs:•

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.

2
Nat1CommonSense•

Missed the second multiplier😅

1
Unknown-Paws:py:•

I like dat

1
Hollowplanet•

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.

-6
noizedOP:py: :cs:•

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.

1
[deleted]•

[deleted]

1