Live data from Hacker News

Advent of Code 2019

adventofcode.com

111–120 of 124 posts

Re: Advent of Code 2019

#111
post #27

Earlier quoted context omitted.

Learning new environments can be painful so it’s good it starts off easy. I’m trying to solve them with Swift Playgrounds on the iPad, for example. And I can’t figure out how to create a simple text file for the data.

I couldn't figure it out on a Mac. Then I Googled it, and decided I'm better off solving this in languages I know (whatever I feel like today: JS, Python, Java, perhaps even Erlang) or in a language that has a reasonable standard library (Rust) than in this mess: https://twitter.com/dmitriid/status/1201441652507844608

Last night I gave the complete solution in Swift below. Here are the two lines to read the file:

   let path = Bundle.main.url(forResource: "input01", withExtension: "txt")
   var text = try String(contentsOf: path!, encoding: .utf8)

Re: Advent of Code 2019

#112

Earlier quoted context omitted.

I couldn't figure it out on a Mac. Then I Googled it, and decided I'm better off solving this in languages I know (whatever I feel like today: JS, Python, Java, perhaps even Erlang) or in a language that has a reasonable standard library (Rust) than in this mess: https://twitter.com/dmitriid/status/1201441652507844608

Last night I gave the complete solution in Swift below. Here are the two lines to read the file: let path = Bundle.main.url(forResource: "input01", withExtension: "txt") var text = try String(contentsOf: path!, encoding: .utf8)

There's no chance in hell anyone learning Swift can figure these two lines out.

Besides, there are immediate additional questions:

- what's a bundle, and why does a Bundle deal with urls?

- What's the difference between Bundle.main.url and FileManager.main.urls, and why one and not the other?

- where does the resource come from?

- how do I read a file from a path?

- Why is String responsible for reading (and writing!) contents of a file? In which world is this good design?

Re: Advent of Code 2019

#113
post #96
post #14

Many of the comments are about the event as a whole, but I'd like to commend the author for the day 1 puzzle, which I think is very cleverly written. Many people (including myself) use these as an opportunity to try out learning a new language, and the first puzzle does a good job of making sure you know enough basic operations for some of the puzzles coming up. The puzzle itself wasn't very difficult, you could do i…

> Many people (including myself) use these as an opportunity to try out learning a new language I hadn't thought about that! I'll take this as an opportunity to learn Rust!

I'm doing the same thing this year!

Re: Advent of Code 2019

#114
post #100
post #14

Many of the comments are about the event as a whole, but I'd like to commend the author for the day 1 puzzle, which I think is very cleverly written. Many people (including myself) use these as an opportunity to try out learning a new language, and the first puzzle does a good job of making sure you know enough basic operations for some of the puzzles coming up. The puzzle itself wasn't very difficult, you could do i…

Good idea. I have used http://www.https://cryptopals.com/ for a similar purpose, with the added benefit of learning about cryptography as a parallel outcome.

Poorly formatted link, it should be https://cryptopals.com/.

Re: Advent of Code 2019

#115
post #14

Many of the comments are about the event as a whole, but I'd like to commend the author for the day 1 puzzle, which I think is very cleverly written. Many people (including myself) use these as an opportunity to try out learning a new language, and the first puzzle does a good job of making sure you know enough basic operations for some of the puzzles coming up. The puzzle itself wasn't very difficult, you could do i…

> The puzzle itself wasn't very difficult, you could do it by hand if you really wanted to, but it required you to know how to read and parse lines in a file, handle compound data structures, iterate through, and perform basic operations (floor, casting strings to ints, etc).

I don't believe that it required any compound data structures, just looping through the lines in the file.

You're right about the rest, though.

Re: Advent of Code 2019

#116
post #96

Earlier quoted context omitted.

> Many people (including myself) use these as an opportunity to try out learning a new language I hadn't thought about that! I'll take this as an opportunity to learn Rust!

I'm doing the same thing this year!

Thanks to these comments, in spite of already having starting advent coding, I have begun learning basic Rust, have the stack and development environment set up and I'm looking forward to doing the first two days again in Rust...

Re: Advent of Code 2019

#117
post #86

I'm trying to use J and still struggle with the second part of day 1. Any other J users?

I have found a solution someone posted [0] It looks similar to what I though I had to write, but I will have to reread it and the documentation to understand it well. And day 2 seems a bit too complex with my meager J knowledge. OTOH with the J interpreter for android and its terseness it seems the most suited language for programming on a phone, so I will probably stick to it. [0] https://www.reddit.com/r/adventofco…

I'm actually surprise how many J/APL/K/Q solutions get posted there already. It seems to be popular among golfers.

Re: Advent of Code 2019

#119

The third puzzle mentions Halt and Catch Fire, a brilliant TV show about innovation and the lives of the (fictional) people behind it.

It actually references the thing that the show is named after. If you click on the link, it's not about the show.

Re: Advent of Code 2019

#120
post #86

I'm trying to use J and still struggle with the second part of day 1. Any other J users?

If you haven't already found the discussion, Reddit is very active and very helpful. Seems to be the primary water cooler for the event. https://www.reddit.com/r/adventofcode/

I'd argue /g/ on 4chan is actually. 3-4 threads get filled a day (~300 replies each).

It's honestly the only real reason to go on /g/ (or really 4chan in general) for me.

Post reply on HN