Live data from Hacker News

Peter Norvig's “pytudes” for Advent of Code 2020

github.com

51–60 of 96 posts

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#51
post #49
post #46

Earlier quoted context omitted.

What am I confused about other than what I asked? There’s two books. The first is Paradigms of Artificial Intelligence Programming , which used Common Lisp, and the second is Artificial Intelligence: A Modern Approach , which to my knowledge primarily uses or encourages Python. I was trying to place what time Norvig was referring to in the linked comment. He mentions his book, which I assumed to be the modern approac…

Artificial Intelligence: A Modern Approach is "his and Russell's prior AI book". It seemed as if you were talking about a different book. In the HN comment he says "the Lisp code that Russell and I had online" so I don't think it's difficult to guess it's indeed AIMA he's talking about. I don't think that the book, in any of the four editions, "primarily uses or encourages Python". I have not checked them all, but I…

It seems my remark that confused you is that I indeed made a mistake about thinking Russell was a co-author on PAIP, which he is not. Although, I thought it was clear I was talking about AIMA and referring to PAIP in my parenthetical comment. I feel it's nicer to just ask a question rather than to say someone is confused.

I still think it's fair to say the book encourages the use of Python if one of the primary authors publishes solutions in that language over existing solutions in another language and the author promotes Python. Of course, it seems over time other languages have grown into providing solutions. I don't have the book (because of its exorbitant price) but do have PAIP, so I can't say for sure. Even the GitHub repo for the Lisp implementation says its out of date and was used back in 1995. This latter point is relevant and was what I was curious about. Were Norvig's comments referring to a time before the first edition was published, or was it after the first edition was published and sometime in between the first and second editions? I'm just generally curious about the context in which he's referring to.

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#52
post #51
post #49

Earlier quoted context omitted.

Artificial Intelligence: A Modern Approach is "his and Russell's prior AI book". It seemed as if you were talking about a different book. In the HN comment he says "the Lisp code that Russell and I had online" so I don't think it's difficult to guess it's indeed AIMA he's talking about. I don't think that the book, in any of the four editions, "primarily uses or encourages Python". I have not checked them all, but I…

It seems my remark that confused you is that I indeed made a mistake about thinking Russell was a co-author on PAIP, which he is not. Although, I thought it was clear I was talking about AIMA and referring to PAIP in my parenthetical comment. I feel it's nicer to just ask a question rather than to say someone is confused. I still think it's fair to say the book encourages the use of Python if one of the primary autho…

> It seems my remark that confused you [...] I feel it's nicer to just ask a question rather than to say someone is confused.

So you can say that I was confused but I cannot say that you were confused? Ok then.

What do you find unclear, really?

The 1st edition of AIMA is from February 1995.

The "Python for Lisp Programmers" page is from May 2000.

The second paragraph starts: "I looked into Python because I was considering translating the Lisp code for the Russell & Norvig AI textbook into Java."

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#53
post #44

Can someone please explain how `for y in nums & {2020 - x} ` in his day 1 solution?

It's a bit overly clever. I am a huge fan of Peter Norvig (and he was once my skip-level boss), but I'd call this code out in a code review for being obtuse. Notice that the input, `nums`, is a set. So he's taking the intersection of two sets. One set always has one item, so the result will be a collection with either 0 or 1 items. It could have also been written as: first(x * (2020 - x) for x in nums if (2020 - x) i…

when I saw the first() function, I thought it was some default python that was new to me.

But he defines it above in his commonly used functions:

    def first(iterable, default=None) -> object:
        "Return first item in iterable, or default."
        return next(iter(iterable), default)

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#54
post #47

Earlier quoted context omitted.

Why should we care what you find interesting or uninteresting?

You’re of course free not to care. That’s absurd. But isn’t this a website designed for people to say what they find interesting or not? Why are these comments so hostile?

I think it's because you sound condescending when sharing your opinions and seem to be insisting that others should agree with your sentiment.

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#55
post #4

Always look forward to these so I can compare my solutions afterwards. Sometimes it's almost frustrating to see how clean and concise the mess I made could have been, but I do learn a lot. It's like he gets as close to golfing as possible, without the obfuscation. Too bad he punted on 20... one of the few difficult problems this year. Usually the hard problems are where you really see the contrast between his solutio…

I had a similar feeling with that one, found the corners by counting edges on part one, and really got de-motivated for part two and actually solving the puzzle and looking for the patterns

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#57

How do you algorithmically code like this? In my software engineering career, I am a plumber at best. Would fail hard at anyone who would ask me to code anything more than fizz buzz under time pressure. That said, I've built some incredible production worthy and robust systems that move mountains as a plumber. I am damn good at that.

I wouldn't worry about it. Jobs that require this are few and far between - so the necessity isn't there. HN have a wideon for this leetcode stuff. In reality, unless it's your hobby, you don't need to be able.

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#58
post #44

Can someone please explain how `for y in nums & {2020 - x} ` in his day 1 solution?

It's a bit overly clever. I am a huge fan of Peter Norvig (and he was once my skip-level boss), but I'd call this code out in a code review for being obtuse. Notice that the input, `nums`, is a set. So he's taking the intersection of two sets. One set always has one item, so the result will be a collection with either 0 or 1 items. It could have also been written as: first(x * (2020 - x) for x in nums if (2020 - x) i…

abstruse

Completely agree, your solution is more clear.

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#59
If you like this, you will love https://github.com/mebeim/aoc/tree/master/2020

The guy created very clean python solutions, and very insigthful walkthrough (although a bit wordy some times). It was my go to repo after validating my solutions on AoC (he managed to publish daily during the whole challenge !).

Re: Peter Norvig's “pytudes” for Advent of Code 2020

#60
post #54
post #47

Earlier quoted context omitted.

You’re of course free not to care. That’s absurd. But isn’t this a website designed for people to say what they find interesting or not? Why are these comments so hostile?

I think it's because you sound condescending when sharing your opinions and seem to be insisting that others should agree with your sentiment.

Mind pointing out where? I asked a pretty simple question and got answers insinuating I said things I didn’t. Of course we all enjoy things for different reasons. I don’t insist on anything. People are free to disagree on whatever and have their own stance. If people like Advent of Code, that’s great. I have looked into it before, and it’s not for me. And I was also simply curious why Norvig seems to like Python so much. He either likes it or it’s convenient as a marketing tool or both (i.e., it fits all his needs). None of those are bad or wrong or whatever.
Post reply on HN