Earlier quoted context omitted.
So fun fact, if you compile int sum(int n) { int sum = 0; for(int i = 0; i clang, with -O2, will turn this into the polynomial (n+1)*n//2. It can also do similar transformations for multiple loops. https://godbolt.org/z/so6neac33 So if you do a brute force solution which could have been reduced to a polyomial, clang has a shot of doing just that.
That is mind blowing, but it’s not immediately obvious to me that it’s equivalent for n > sqrt(INT_MAX). Is it? And if so, is the compiler somehow smart enough to know that?
Project Euler #912: Where are the Odds?
91–100 of 105 posts
Re: Project Euler #912: Where are the Odds?
#92I'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…
> 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…
Re: Project Euler #912: Where are the Odds?
#93I'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…
Re: Project Euler #912: Where are the Odds?
#94I'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…
Exercism.io does what you want? It has language tracks and each track has questions geared to seal your understanding of some language concept. It also has it gamified by building a community around it and folks comparing their solutions.
Re: Project Euler #912: Where are the Odds?
#95Earlier quoted context omitted.
Am I missing something here or would that be as simple as 2N nCr N for an NxN grid?
You’re not missing anything. This is an easy problem aimed at people who are not familiar with basic combinatorics.
I learned so much poring over the solutions of earlier solvers. Without that knowledge, there's no way I could have gotten lots of later problems.
Sure, problem #15 is very early and I happened to know the answer right off, back the first day I started solving PE problems. But even so, there are some gems in the posts from other solvers.
Re: Project Euler #912: Where are the Odds?
#96Earlier quoted context omitted.
Wow. The idea of getting to 100% on PE is almost incomprehensible to me. I've solved basically none outside the first couple pages. What was your strategy like? How much math background do you have?
I've got a bachelor's in math, but that's 40+ years ago. I had intended to go on for a PhD in math, but fell into computers instead - programming was easier and way more lucrative, even in the early 80s. Once I was retired and found my way to Project Euler, it became an obsession, tickling that desire to go deeper into math that I had in my college days. I attacked roughly the first 250 problems in order. The early p…
There are some much later problems where some obscure technique gets mentioned, even though the problem is doable without that technique. But then later on, there are other problems where that technique is practically required. I can think of multiple 100% difficulty problems which were actually much easier than that for me, because I had already seen and tried out the techniques that enable a fast solution.
And sorry, not going to mention any of those techniques. A lot of the fun I have in solving PE problems is that incremental increase in knowledge as time goes on.
Re: Project Euler #912: Where are the Odds?
#97I don’t understand this problem (I didn’t tackle it myself) but wanted to see how quickly chatgpt could solve it and how far along it would go.
First it made a naive solution that would work until 10^6. Then we used that output to verify improved versions.
And we managed to improve it until 10^10 only. (Staying within a minute timeout.)
It did a DP approach (it suggested itself). I suggested to try numba and numpy. And with that it managed until 10^10. I think it’s still brute forcing it and one might leverage much better techniques in order to reach 10^16.
Re: Project Euler #912: Where are the Odds?
#98Earlier quoted context omitted.
Am I missing something here or would that be as simple as 2N nCr N for an NxN grid?
You’re not missing anything. This is an easy problem aimed at people who are not familiar with basic combinatorics.
Re: Project Euler #912: Where are the Odds?
#99Earlier quoted context omitted.
Am I missing something here or would that be as simple as 2N nCr N for an NxN grid?
You’re not missing anything. This is an easy problem aimed at people who are not familiar with basic combinatorics.
Re: Project Euler #912: Where are the Odds?
#100Earlier quoted context omitted.
Yup! That was it!
If you want a few similar problems, in ascending order of difficulty, try #81 through #83: https://projecteuler.net/problem=81 https://projecteuler.net/problem=82 https://projecteuler.net/problem=83