TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Lessons Learnt from Solving AoC in One Second

17 pointsby sulamiover 2 years ago

2 comments

mappuover 2 years ago
Sorry - if this is your website, could you please not hide the scrollbar?<p>The CSS file has a comment <i>This below keeps the regular scrollbar for scrolling the page, if present, because that one makes sense to be there.</i> but it doesn&#x27;t seem to be taking effect for me.<p>Regarding the AoC i&#x27;m very impressed with adding the extra time constraint on yourself.
评论 #34154686 未加载
powersnailover 2 years ago
`nom` is incredible. I used to iterate input by line, make up regex with capture groups, and do something ad hoc if the input isn&#x27;t line by line. It gets quite ugly, if the input has multiple parts, or multiple lines as one part.<p>Now I just take the whole stdin and pass it into a parser written in `nom`. If it&#x27;s line-by-line, it&#x27;s a trivial: `separated_list1(tag(&quot;\n&quot;), parse_line)`, not more difficult than iterating through lines, parsing each, and combining them. If the input isn&#x27;t line-by-line, a proper parser is way more cleaner than anything I&#x27;ve done before.<p>And there has never been a performance problem for me. (To be fair, AOC doesn&#x27;t have truly giant input size)