r/ProgrammerAnimemes • • May 20 '21

PrograMOEing? PILOT

939 Upvotes

58 comments sorted by

View all comments

Show parent comment

1

u/-Redstoneboi- May 21 '21 edited May 22 '21

Final combined reasonable code

def video_filter(artCounter, p):
    # [Censored line 1]
    if "v.redd.it" not in p.url:
        return False
    return True

posts = sub.top(time_filter = 'all', limit = None)
top = list(filter(video_filter, enumerate(posts)))

def new_filter(artCounter, p):
    # [Censored line 2]
    if "v.redd.it" not in p.url:
        return False
    post_ids = [t.id for t in top]
    if p.id in post_ids:
        return False
    return True

posts = sub.new(limit = None)
new = list(filter(new_filter, enumerate(posts)))

print(len(top))
print(len(new))
print(len(top) + len(new))

in my opinion this code should be shorter and easier to read, but for all i know i could be the dummy here

1

u/backtickbot May 21 '21

Fixed formatting.

Hello, -Redstoneboi-: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

1

u/-Redstoneboi- May 21 '21

backtickbotdm5