Live data from Hacker News

A list of practical projects that anyone can solve in any programming language

github.com

21–30 of 67 posts

Re: A list of practical projects that anyone can solve in any programming language

#21

Not only do I doubt that "anyone" can write these programs, most of them do not look particularly interesting or fun. Many if not all of the non-mathematical ones are simply replicating off-the-shelf utilities or tools; what is the point of reinventing the wheel? Even if you are looking to hone your skills in a new language, creating something genuinely new seems like it would be more useful and motivational.

Creating something genuinely new can be really tricky if you are learning at the same time.

I.e. look at the TodoMVC as the comparison benchmark for various frontend frameworks.

Re: A list of practical projects that anyone can solve in any programming language

#22
post #9

Nice list, but ‘anyone’? The first on the list is ”Find PI to the Nth Digit - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go” Easily solvable if you set that limit low and cheat. Just put a string representation of pi in the program, and chop it off at the requested length: n = Input “num digits?” if n between 0 and 8 inclusive print left(“3…

Pi was already being approximated by Archimedes and Co. some time ago, I don't think its outside of the realm of possibility that a modern developer looks up following inequality and just approximates pi to some degree of accuracy with

  P/(2*r) > Pi > P/(2*R)
Once you have approximated it, returning a string with the first x digits is trivial

Re: A list of practical projects that anyone can solve in any programming language

#23
If you're talking German, I can wholeheartedly recommend Taschenbuch der Algorithmen by Vöcking et al., Springer 2008. Unlike the name suggests, it is a highly entertaining, but more or less unsystematic collection of common and also less common algorithms. The descriptions are informal and just detailed enough so you can implement them on your own.

It's a great little book that is unfortunately only available in German.

Re: A list of practical projects that anyone can solve in any programming language

#24
post #9

Nice list, but ‘anyone’? The first on the list is ”Find PI to the Nth Digit - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go” Easily solvable if you set that limit low and cheat. Just put a string representation of pi in the program, and chop it off at the requested length: n = Input “num digits?” if n between 0 and 8 inclusive print left(“3…

There are fast algorithms for calculating the Nth digit of pi.

The entire 'fun' of this is implementing it with as much of your own code as possible. Using existing fast algorithms only leaves you with splitting the output to the nth digit, which is trivial and leaves you without having learned or achieved anything imo.

Re: A list of practical projects that anyone can solve in any programming language

#25
post #9

Nice list, but ‘anyone’? The first on the list is ”Find PI to the Nth Digit - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go” Easily solvable if you set that limit low and cheat. Just put a string representation of pi in the program, and chop it off at the requested length: n = Input “num digits?” if n between 0 and 8 inclusive print left(“3…

Series for approximating Pi can be found in almost every formulary.

Re: A list of practical projects that anyone can solve in any programming language

#26
post #4

Looks really good :-) I would just change Classes sot something more generic like Domain modeling ? I.e. I am thinking of using this as a list to help me learn some languages I find interesting, currently Purescript/Haskell and ReasonML/Ocaml. I don't think you would model any of the solutions to the projects in the list by creating class-hierarchies (and Ocaml even is capable of creating class-hierarchies.) Even in…

Agreed. The tagline talks about any programming language, and then the classes section goes on to talk aout classes, abstract classes, class hierarchies, etc. To me it seems like "any language" in that chapter at least would refer to what people traditionally call object oriented languages. Lisps, some low level c-style languages (go and rust among the newer ones), and some ML languages with algebraic data types don'…

To nitpick your nitpick, Common Lisp has one of the strongest object oriented abstractions around (The MOP). It would be quite fun to see how far you could abuse the metaobject protocol to implement some of these..

Re: A list of practical projects that anyone can solve in any programming language

#27

Not only do I doubt that "anyone" can write these programs, most of them do not look particularly interesting or fun. Many if not all of the non-mathematical ones are simply replicating off-the-shelf utilities or tools; what is the point of reinventing the wheel? Even if you are looking to hone your skills in a new language, creating something genuinely new seems like it would be more useful and motivational.

> what is the point of reinventing the wheel?

The point of reinventing the wheel is to develop a more intimate familiarity with the tool or framework or utility you're trying to re-create. Yes the original ls program is perfectly functional but recreating it can be a good way to learn how to write C programs. This is applicable to any type of project really.

Re: A list of practical projects that anyone can solve in any programming language

#28
post #5

Personally (but most likely majority of the people) motivation is so much higher when new knowledge can be applied in the short-term, and a pool of ideas like this comes very useful after e.g. reading the basics of a language.

Yes. I find it very hard to really learn a new language without a project to use it for, but most projects I want to work on are too large to do in a language I don't yet know, or I want to actually finish so it doesn't make sense to use a new language, but a list of smaller problems like this is really useful.

Re: A list of practical projects that anyone can solve in any programming language

#29
post #17

Earlier quoted context omitted.

You need to use an arbitrary precision math library, I don't know how hard to use those. Those formulas have a hard limit in precision for standard floating point types.

You don't need arbitrary precision, use a spigot https://en.wikipedia.org/wiki/Pi#Spigot_algorithms

Wow, this blew my mind. And it's so simple, too.

    def nthHexDigitOfPI(n):
        return 4/(8*n+1) - 2/(8*n+4) - 1/(8*n+5) - 1/(8*n+6)

Re: A list of practical projects that anyone can solve in any programming language

#30
post #17

Earlier quoted context omitted.

You need to use an arbitrary precision math library, I don't know how hard to use those. Those formulas have a hard limit in precision for standard floating point types.

You don't need arbitrary precision, use a spigot https://en.wikipedia.org/wiki/Pi#Spigot_algorithms

I took a look at a spigot algorithm[1]. I still think it needs arbitrary precision arithmetics but maybe I miss something obvious.

[1] https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%9...

Post reply on HN