Live data from Hacker News

Project Euler #912: Where are the Odds?

projecteuler.net

71–80 of 105 posts

Re: Project Euler #912: Where are the Odds?

#71
post #16

The OG LeetCode. Highly recommend, helpful for becoming fluent in a programming language.

I wouldn't. The majority of problems there have mathematical optimizations which real problems never do. Worse if you start thinking in the way those problems encourage you to your programs will be completely invalidated even with a tiny change in the spec. A good set of questions would be something between the advent of code - where the problems are hard because the spec is so bad on purpose - and project Euler - wh…

The AoC spec isn't bad though?

The text always clearly states how your code has to behave, albeit it doesn't spell out every edge case you might overlook. Real world specs on the other hand is often contradictory and impossible to fullfil.

Re: Project Euler #912: Where are the Odds?

#72

I've been thinking recently about how things like Project Euler, LeetCode, and to a bit less of an extent, Advent of Code, are so heavily focused on making clever use of math, data structures and algorithms, that it makes them suboptimal as a tools for getting familiar with a new programming language. I know that that critique isn't new to anyone but it makes me think about how it would be cool if there were a code p…

Something I'd love to see is "AoC hard mode": the exact same problems but the input data set is ~10 GB, and/or similarly "scaled" such that naive solutions fail outright. Other scaling-of-inputs could include: Text with line-lengths over 2 GB, numbers above 2^60, data designed such that naive nested-loop solutions (quadratic scaling) take over a year to compute the answer, etc... Basically, force developers to solve…

There are a couple posters on 4chan's /g/ threads on AoC that create "Big Boy" inputs, which is what you're looking for. It's unofficial, though.

Re: Project Euler #912: Where are the Odds?

#73

I've been thinking recently about how things like Project Euler, LeetCode, and to a bit less of an extent, Advent of Code, are so heavily focused on making clever use of math, data structures and algorithms, that it makes them suboptimal as a tools for getting familiar with a new programming language. I know that that critique isn't new to anyone but it makes me think about how it would be cool if there were a code p…

Most of these wouldn't qualify as "puzzles", would they?

I find it nice to learn new languages via data structure puzzles, because to me the data structures of a language feel like the grammar and once I have that down everything else falls into place

Re: Project Euler #912: Where are the Odds?

#74

I've been thinking recently about how things like Project Euler, LeetCode, and to a bit less of an extent, Advent of Code, are so heavily focused on making clever use of math, data structures and algorithms, that it makes them suboptimal as a tools for getting familiar with a new programming language. I know that that critique isn't new to anyone but it makes me think about how it would be cool if there were a code p…

If you're trying to model those "puzzlers" on actual dev work, then doing any of those things without a library/framework is a wrong answer.

Or is that your point? That coding like a pro means gluing those things together?

Re: Project Euler #912: Where are the Odds?

#75

The OG LeetCode. Highly recommend, helpful for becoming fluent in a programming language.

Agreed about learning a new language starting with PE.

After that, I like to invent a big gnarly scenario that I don't have to completely solve, but one that takes me well out of the range of typical cookie-cutter tutorials. I want to find all the sharp edges on a new language/library/framework.

Re: Project Euler #912: Where are the Odds?

#76
post #31

Earlier quoted context omitted.

No. It's 20!/(10!x10!) You have 20 slots to be filled with 10 items vs other 10 items.

Close, it's 40!/(20!*20!) 20 Rs, 20 Ds in a 20x20 grid. Example pattern: RRDDDR...D (40 letters) Basically the number of permutations, with repetition, of 20 Rs and 20 Ds.

Now I see it. Twenty items (R operations) in 40 slots: 40!/(20!) and the order of the items does not matter, so again divide by 20!. The remaining slots are D operations.

The answer actually came to me in the shower this morning.

Re: Project Euler #912: Where are the Odds?

#77

Earlier quoted context omitted.

> How many such routes are there through a 20x20 grid? Is it 21! ?

Nope, and only off by a few orders of magnitude.

If it is any comfort, my answer produced a non-negative integer - just like the true answer ))

Re: Project Euler #912: Where are the Odds?

#78
post #70

Earlier quoted context omitted.

> Advent of Code, are so heavily focused on making clever use of math, data structures and algorithms I've done a fair amount of Advent of Code and I wouldn't say it's at all "focused" on this. The vast majority of the questions use hash tables and graph traversal as the full extent of their use of math/DS/algos. There's always one or two puzzles every year that require some particular math/CS insight but most of the…

AoC is still is algorithms and data structures: there's minimal interaction with the outside world, just solving the problem for the input data. It's just about coming up with the algorithm yourself instead of applying fancy well-known ones.

> It's just about coming up with the algorithm yourself instead of applying fancy well-known ones.

Isn’t that the whole fun?

Re: Project Euler #912: Where are the Odds?

#79
post #18

Project Euler 241 I have never really understood...

Check if the sum of number's divisors divided by the number itself gives x.5

Oh - I understand the question. I just don't understand how to calculate the answer up to 10^18 in a reasonable amount of time!

Re: Project Euler #912: Where are the Odds?

#80
post #70

Earlier quoted context omitted.

> Advent of Code, are so heavily focused on making clever use of math, data structures and algorithms I've done a fair amount of Advent of Code and I wouldn't say it's at all "focused" on this. The vast majority of the questions use hash tables and graph traversal as the full extent of their use of math/DS/algos. There's always one or two puzzles every year that require some particular math/CS insight but most of the…

AoC is still is algorithms and data structures: there's minimal interaction with the outside world, just solving the problem for the input data. It's just about coming up with the algorithm yourself instead of applying fancy well-known ones.

> just solving the problem for the input data

I think a lot of people here would be surprised how much of a step up this is from classic leetcode or DSA stuff. I have been involved in introducing people to AoC and helping them and the amount of people who have basic knowledge of algorithms but struggled to parse the input from a file was a little shocking to me at first. Of course, I do not blame anyone for not knowing something, classic academic courses can be misguided sometimes.

This doesn't negate the fact that there is somewhat of a lack in problems with more outside world interaction and it would be cool to see more of that.

Post reply on HN