Skip to content(if available)orjump to list(if available)

Solving the first 100 Project Euler problems using 100 languages

archargelod

From one of blog posts [0]:

> Nim > > Nim is the language that impressed me the most in this batch. Everything I thought would be a problem (significant whitespace, choose-your-own-function syntax, intermediate C compliation step) didn't bother me at all. The small sample of the standard library I played with was a little quirky, but Nim seems like excellent bang for your buck. > > Notes: > > - Release binary was only 120 KB (linked against libc)! > - Thought I'd dislike the syntax, but it was fine > - Really easy to get started, many things "just worked" (e.g. grabbing a slice of an array) > - Didn't have to specify too many types, but still ran fast > - Fast compilation > - Didn't like the "hints" it spews out during compilation, even for nim r (build and run) > - Why did all take an anonymous function, but foldl took just an expression (with a and b seemingly picked out of thin air) -- is foldl a macro? > - Nim might be a good language for hobby projects because it's easy, fast, and produces small binaries > - I wonder what the debugging experience is like -- if it's decent, I might be writing a lot more Nim in the future!

This exactly my thoughts on Nim and why I use it almost exclusively for all my hobby projects.

0-https://log.schemescape.com/posts/programming-languages/100-...

gre

Why did I expect 10,000 files?

moomin

Worth emphasising: Project Euler is a mathematical computation challenge, not a programming challenge like Advent of Code. The principal skill is algorithm design and as the problems progress you need to do more and more maths before you start coding.

thaumasiotes

Do you ever need to start coding? I thought it was a requirement of the project that problems be solvable with pencil and paper.

wholinator2

Well you probably _could_ whiteboard it but some of them are about extending a pattern to the millionth term. If you're really smart you might be able to find a closed form to get there quick, but you can also just program the basic rule and iterate

xzyyyz

I find it rather annoying and irrespectful for Project Euler. They specifically ask not to publish solutions.

Some other collection could be used for demonstration of skills and languages.

sigbottle

The first 100 problems are fair game to publish, I can't find it on their website anymore, but it's generally accepted that this is the case. You can check out the project euler discord for more authoritative information on this

eru

I know they ask, but it's really easy to find solutions online.

For what it's worth, when I was doing Project Euler myself, I never had a problem _not_ looking up solutions.

null

[deleted]

wesselbindt

Just because a bus stop already has a broken window does not make it ok to smash in another.

portercable

From Project Euler homepage:

> the rule about sharing solutions outside of Project Euler does not apply to the first one-hundred problems

sigbottle

fwiw this only shows up if you're logged in (at least for me), which confused me for a bit

portercable

Oops, you are right!

thunkingdeep

Well, HN specifically asks for people to not comment shallow dismissals of others work, but here we are…

wakawaka28

I find it annoyingly unrealistic to demand that nobody publish solutions, especially interesting ones like this. Some people will always do it anyway, and once they do, any further resistance to such publications is pointless. If you want something secret, your ultimate mistake is publishing the problems in the first place. For a problem set as old as Project Euler, it's not reasonable to expect solutions to not be out there, and it is ultimately on the honor system whether a problem solver cheats or not.

dankwizard

It's ChatGPT answers anyway.

7thaccount

I wonder which ones the author liked the most and which they disliked the most. I didn't see any comments on that. If they're on HN, it'd be cool to find out.

middayc

The author wrote a short comment about each language in the following blogposts:

https://log.schemescape.com/posts/100-languages/index.html

fuzzythinker

It's hard to form a good opinion of a language if the knowledge of it is shallow, which I'm inclined to believe based on using 100 languages. More interesting is why the author decide to use a particular language for each problem.

tocs3

I am interested in seeing Verilog used as one of the 100 languages.I have been wondering how it would be to use some sort of hardware description language to solve some of (all?)the problems. I worked thru the first half of "Nand to Tetris" [1] and thought I might try working some of the problems with that.

[1] https://www.nand2tetris.org/

entaloneralie

Wowow! this is fantastic, so many exciting and weird languages in there, even Mouse-83 is in the list!

It was really nice to read about the author's impression of each language.

Well done

joshuamcginnis

Let's say an experienced engineer is starting Euler for the first time. What's the best way to approach it given that many of the problems require some prerequisite algorithmic knowledge to solve? Is there a good method for approaching Euler and LeetCode problems with new eyes aside from reading the solutions first, studying them and then solving it many times until committed to memory?

eru

IMHO, Project Euler is a lot harder than LeetCode and requires a lot more math.

I'm not sure why you would want to solve it many times and committing those solutions to memory? I think you would be better off using some of the time to just read some text books?

For some of Project Euler https://www2.math.upenn.edu/~wilf/gfology2.pdf is a good math book to consult. The techniques in there will allow you to solve some of the problems with just pen and paper (and perhaps a pocket calculator, if you are too lazy to do the arithmetic by hand, but no need for a full blown programmable computer), especially the first few problems if memory serves right. Eg where they ask you to add up the first few billion even terms of the Fibonacci numbers and similar; you can just derive a simple closed formula and evaluate that by hand.

xzyyyz

Project Euler is collection of puzzles based on math. The coding and designs skills are completely secondary to the math. The algorithms (except for computational number theory, computation geometry) are completely secondary. So it is knowledge of math that is barrier.

I keep learning math (and, sometimes, relatively new development in math) by solving problems. To start, I would recommend reading G.H. Hardy & E.M. Wright "An Introduction to the Theory of Numbers".

With LeetCode -- this is more traditional exercise in coding. I did not pay much attention to it. So, sorry, cannot provide any advice

callc

I solved the first 100 problems a long time ago before learning the best practices we learn as professional engineers.

It’s alien code now.

hmng

From one of the blog posts:

> 8080 assembly (Altair 8800) > > First time I've heard of binary-coded decimals

I’m really surprised with that, that someone with such broad interests never heard of BCD. I mean, there’s is always something new to learn all the time, don’t get me wrong, nothing to criticize, just plain surprised. Wonder if that is just something older people came across?

munchler

Old PL/I programmer here. I’m still trying to forget BCD’s from the 80’s!

null

[deleted]

omoikane

I like how the author used four different variants of BASIC.

krick

I'm curious if they are really, like, different. All Basic that I've seen in my life was a minuscule bit of VB and some really ancient programming book I've picked up when I was like 7 y.o. and didn't really have access to a computer.

omoikane

I remember QBasic was notably different from Applesoft Basic in that QBasic did not require line numbers, and one of the demo programs (remline.bas) removed line numbers for you. Of the variants used by this author, the Commodore Basic variant is distinct in being the only one with line numbers. The others all look very similar.

MaysonL

Back in the day, over a decade or so, I wrote a few megabytes of VAX Basic. The language, and the code I wrote, at the end of that period looke nothing like it did at the beginning. So yes, it’s quite likely that the Basics are substantially different.

cgh

AmigaBasic is quite different from Commodore Basic v2.0, and that’s within the same company.