LOADING: An error occurred. Update Chrome, try Firefox, or visit this post for more details.

⚠️Reddit changed how removals work, which breaks Reveddit's website. Install the extension to track removed content:Add to chromeAdd to firefoxWhat changed?
✖︎
about reveddit
⚙F.A.Q.add-ons
r/
status
copy sharelink
[+] show filters
137
SOLUTION MEGATHREAD-🎄- 2020 Day 1 Solutions -🎄-(self.adventofcode)
submitted 5 years, 1 month ago* (edited 3 hours, 3 minutes after) by daggerdragon to /r/adventofcode (134.8k)
1384 commentsredditother-discussionssubreddit-indexmessage modsop-focus

It's been one heck of a crappy year, so let's make the holidays bright with Advent of Code 2020! If ...

... view full text

since 5 years, 1 month ago
2 of 2

Tip Reveddit Real-Time can notify you when your content is removed.

your account history
(check your username's removed content. why?)
Tip Check if your account has any removed comments.
view my removed comments
you are viewing a single comment's thread.
view all comments
[–][deleted]3 points5 years, 1 month ago* (edited 7 minutes after)

Python

Part 1 O(n log(n))

with open('day1.txt') as file:
  s = list(sorted(map(int,file)))

low = (x for x in reversed(s) if x <= 1010)
high = (x for x in s if x > 1010)

l = next(low)
h = next(high)

while True:
  if l + h > 2020:
    l = next(low)
  elif l + h < 2020:
    h = next(high)
  else:
    print(l,h,l+h,l*h)
    break

Part 2 O(n^2)

with open('day1.txt') as file:
  s = list(sorted(map(int,file)))

for y in s:
  low = (x for x in reversed(s))
  high = (x for x in s)

  l = next(low)
  h = next(high)
  try:
    while True:
      if y + l + h > 2020:
        l = next(low)
      elif y + l + h < 2020:
        h = next(high)
      else:
        print(y,l,h,y+l+h,y*l*h)
        break
  except StopIteration:
    continue
permalinkhide replies (1)as-of
[–]backtickbot1 point5 years, 1 month ago

Hello, elmusfire: code blocks using 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. It's a bit annoying, but then your code blocks are properly formatted for everyone.

An easy way to do this is to use the code-block button in the editor. If it's not working, try switching to the fancy-pants editor and back again.

Comment with formatting fixed for old.reddit.com users

FAQ

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

permalinkparentcontextauthor-focusas-ofpreserve
r/revedditremoved.substack.com
🚨 NEWS 🚨
✖︎

Important: Reddit Changed How Removals Work

A recent Reddit update makes mod-removed content disappear from profile pages, which breaks Reveddit's website.

Install the browser extension to receive removal alerts.

Add to chromeAdd to firefox

What changed?

r/revedditremoved.substack.com