[HN Gopher] Adventures in Advent of Code
___________________________________________________________________
Adventures in Advent of Code
Author : ingve
Score : 66 points
Date : 2022-12-03 19:36 UTC (3 hours ago)
(HTM) web link (davedelong.com)
(TXT) w3m dump (davedelong.com)
| jamamp wrote:
| I'm confused. The post mentioned that this was fixed in Swift
| 5.7, but I have Swift 5.7.1 on my macOS Monterey and the bug is
| still present if I modify my AoC solution to exhibit the problem.
| Is Swift 5.7.1 on Monterey different from the 5.7.1 on Ventura?
| $ swift -v Apple Swift version 5.7.1
| (swiftlang-5.7.1.135.3 clang-1400.0.29.51) Target:
| arm64-apple-macosx12.0
|
| I love Swift as a language, but the lack of release notes for
| 5.7.1 (aside from a blog post for 5.7 as a whole), OS-specific
| releases (especially for SwiftUI), Xcode removing old toolchains
| when it upgrades (making me re-download tvOS 15.4 runtime for no
| reason), and all these other little things are starting to weigh
| on me.
| davedelong wrote:
| Turns out the fix is only on Ventura. I was also on Monterey. I
| updated the blog post to include this.
| forrestthewoods wrote:
| Having to update your entire OS to get bug fixes in a programming
| language is... not ideal.
| js2 wrote:
| > The bug is fixed in Swift 5.7, but my computer is running macOS
| Monterey (12.6) and thus using an earlier version of Swift. I
| have since confirmed that the code works as expected on macOS
| Ventura.
|
| You don't have to update the entire OS to get the latest Swift.
| Swift 5.7.1 is available as part of Xcode 14.1 which installs on
| macOS 12.5 and later.
|
| You can also install development versions from
| https://www.swift.org/download/
|
| If you're building from the command-line you may need to set
| TOOLCHAINS=swift:
|
| https://www.swift.org/getting-started/#on-macos
| mtlmtlmtlmtl wrote:
| I'll be doing AoC in C this year. And I've decided to do that
| every year as I enjoy doing it in C and trying to get the entire
| calendar, all 50 parts to run in less than one second on a single
| core, which it turns out is quite doable, but only with a much
| deeper understanding of the problems. I end up learning a lot
| more computer science this way.
|
| I also like it since I don't do any work or even side projects in
| C these days, and so it's nice to keep my C chops up to scratch.
| disposedtrolley wrote:
| Nice! I'm writing in C this year too, although I'm very much a
| beginner in C.
|
| What kinds of optimisations have you had to do? Are you hosting
| your code anywhere?
| sokoloff wrote:
| Hat tip if you did 2021:14:2 under this constraint. I didn't
| find the trick to allow that type of performance.
| satvikpendem wrote:
| I'm doing AoC in ChatGPT this year:
|
| https://news.ycombinator.com/item?id=33821092
| stareatgoats wrote:
| When your code fails it's never the fault of the language. It's
| always ones own fault, a typo, some error in the logic, or
| something. Debugging always reveals that with a stone face.
| Always.
|
| Except
|
| > "It turns out, there was a bug in Set.intersection(_:), but it
| had only been discovered this past June, and the fix hasn't made
| it into a public version of Swift yet. "
| davedelong wrote:
| (Hi, I'm the author of the post)
|
| It turns out the bug fix has been released publicly, but only
| on newer OS versions.
| Avshalom wrote:
| Don't know what to search for to bring it up but there's a
| story HN used to post occasionally about finding a CPU bug...
| talk about _Always. Except._
| frollo wrote:
| Yeah, luckily, those exceptions are really rare. Last time one
| happened to me I wasted three days before finding the culprit.
| shaftoe444 wrote:
| I picked go for my language this year, which doesn't have good
| support for sets. May end up writing my own buggy implementation
| of this.
| [deleted]
| angrais wrote:
| What if you used a map and stored the value as a key? Then get
| all keys? Could work as a simple alternative and you could
| check if values are in it.
|
| Requires thinking if you want to implement set difference or
| intersection. I just figured depending on needs using existing
| built-in types may be fun.
| forrestthewoods wrote:
| You don't need a map for AoC 2022 day 3. There's only 52
| elements. Which means a 64-bit bitmask is sufficient.
___________________________________________________________________
(page generated 2022-12-03 23:00 UTC)