Hacker News new | comments | ask | show | jobs | submit login
A list of practical projects that anyone can solve in any programming language (github.com)
320 points by truth_seeker 3 months ago | hide | past | web | favorite | 64 comments



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?

For many of us (me included), it's not REinventing the wheel, it's inventing it. I've taken a quick look through here, and some of these are in the 'yeah, I can do that straight off' category, some are in the 'I -think- I could do that' and some are in the '...right.... I'm not sure how I'd approach that' category. Remember that not everyone is in the same boat as you, and at the same level. I'm sure I'm way behind 99% of the people on HN, so maybe this is the wrong audience.

In addition, there's also the element of the development of the wheel - after all, they used to be wooden, and then gained a steel tyre, a proper bearing, etc... The code you create today may well be completely different (and hopefully better in every respect) than the code from yesteryear.

>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.

Maybe, but sometimes having the limitation of producing a specific thing can be useful - certainly when teaching music in the past, there has been room for both approaches, and I think that carries across into coding. There are also plenty of people who don't know -what- to create, and anything they look at is such a massive, difficult project combining multiple skills they may not have 100% down that it's probably better to do some simple 'test pieces' like I had to do when I was an engineering apprentice.


> I'm sure I'm way behind 99% of the people on HN

Two things about this:

First, I seriously doubt you're in the bottom 1% of HN users when it comes to programming ability. Not only is it statistically very unlikely, but there are many people who read and participate here who aren't programmers at all. While I realize you probably didn't mean that statement literally, in my experience being self-deprecating is something of a self-fulfilling prophesy. You're almost certainly more skilled than you believe yourself to be.

Second, speaking of skills as "ahead" or "behind" without context isn't very precise. I'm mostly a back-end web dev, but I have a little over a decade of experience. A brand new developer fresh out of a bootcamp that teaches modern React would be "ahead of me" if the task were to build a SPA front-end for an existent API. On the other hand, I would be far "ahead of them" if implementing the API itself was part of the task.


I think you're right for many people, especially those who haven't done much programming and aren't sure they really want to.

But whenever I learn a new language (many times over many decades), I want to build lots of small projects of many different sorts in order to habituate myself to the new tools and patterns (using the tools in various combinations) as quickly as possible. My ideal is when I find a set of these small but diverse projects implemented by an expert in the language, so I can try it my way, see how a "native speaker" does it, get some explanation from him (again, ideally), adjust my approach to be more "native", and repeat, again, and again, and again. I can usually find the problems, but finding the "native" solutions is harder.

I don't need the exercises to be "useful" in any way other than delivering the desired fluency efficiently, and I don't need them to be "motivational". If I want the skill, I'm motivated by anything that can help me get it, and if I don't want it, the problems don't matter. I have other things to do.


I have a similar approach to learning a new language. The first thing I usually do is implement some sort of self-balancing binary search tree (usually AVL, Splay, or Red-Black). It's usually something that I can do in just a few hours in a new language, using just the core language features and maybe a couple of standard library functions. It's also just complex enough to force me to learn some of the language idioms so that the resulting code is sufficiently readable/elegant/small/performant.

Once I've done this I'm usually much more comfortable reading other code in the language and navigating the language documentation. From there it's much easier to do things where I want to use external libraries, frameworks, build tools etc.


I was writing a chess app a while back and a non-programmer friend mocked me for re-making something that already ships for free on every computer in the world.

This took me by surprise!

Why do people complete crossword puzzles that millions of people have also completed? Why do people learn to play songs on the piano that millions before them have learned? Why do people learn math proofs that have been known to others for hundreds of years?

I can't quite apprehend the kind of confusion required to provoke such questions.


When I'm working on a side project, I always prefer to do something that hasn't been done before, even if it's just a small improvement. I wouldn't criticize your chess app, and that sounds like a great learning experience. But even if the goal is to learn something new, I'd prefer to end up with a project that is useful or interesting, and might even make some money. In other words, I only want to build something if I can write a blog post about it and Hacker News might find it interesting. (And there's plenty of ways to make a chess app interesting - using a different programming paradigm, machine learning, AR, building a chess engine in VHDL for an FPGA, etc.)

> Why do people learn to play songs on the piano that millions before them have learned?

I honestly asked myself that same question when I was a teenager, and I decided to quit piano lessons. It felt like a waste of time and a useless skill now that we have MIDI and self-playing pianos. So I switched to jazz and improvisation, and tried to compose my own music (although I'm not very good.) But I enjoy the creativity a lot more than playing songs from sheet music.


> what is the point of reinventing the wheel?

Making a wheel is pretty much the "Hello, world!" of engineering. It ensures that you know how to operate the equipment, procure materials, safely work them, and retrieve the finished product from the machinery.

Just getting started with a lathe? Go make a wheel. Just got a 3D printer? Go make a wheel. Just getting started with a whittling knife? Go make a wheel.


>Just getting started with a whittling knife? Go make a wheel.

I used to go to primitive skills meetups, and at one of them I met a guy who taught woodworking. At the meetup, he carried around a few blocks of wood and some basic tools, and when he sat down to eat he'd bang out a wood spoon and eat with that. This was good advertising, but he said he did that sort of thing a lot for practice.


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.


I'm not sure others have said this specifically when I started writing this. The point of reinventing the wheel is that you understand the domain and are focusing on the language, framework, or alternative approach. This is at the core of the programming Kata. Code retreats focus around things like Conway's Game of Life which participants have probably programmed many times before, but it lets them focus energy on learning in a specific way.

To be fair, I think there can be some value to the approach where everything is new, but it probably shouldn't be the norm. Feeling out of control because you don't understand multiple elements can generate energy and growth at times, but it may require more time to progress.

For people looking to demonstrate their skills for a job, having examples like these can be useful. They don't take time to for an interviewer to understand so the focus can be on how the interviewee built the solution.


> 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.


If people stopped 'reinventing the wheel', we'd still be using circular rocks (or whatever the first wheel was), no one would have cared to learn how to make it and then improve upon it.

Recreating existing tools is a perfectly valid way to 1) learn or become proficient in a language, 2) learn how the tool works, and 3) position yourself to improve the tool if you wanted


That's the funny thing about that phrase. There's so many different types of wheels out there! And it's not the result of engineers being cute, but rather the reality that different requirements do call for different solutions.

People who argue against reinventing the wheel are the same ones sticking bicycle wheels on jumbo jets, and wondering why it can't handle the load.


"Why would you want to learn this stuff? We're never going to use it."


> Even in literature and art, no man who bothers about originality will ever be original: whereas if you simply try to tell the truth (without caring twopence how often it has been told before) you will, nine times out of ten, become original without ever having noticed it.

-- C. S. Lewis

Why wouldn't that hold for programming, at least if you make something you actually want and use? For me, it's about being able to make something exactly how I want it, without having all the stuff I don't need.

For example, I started out with a simple CMS that was based on text files. The next iteration used MySQL, but each "type" of page (link, text, image, audio) was it's own thing. That sucked, so I did it a third time, this time everything was a node that could have a type and a parent and children, but could also nodes "inside" it, which in turn also can also be nested and have nodes inside themselves, initially just because I thought "why not", but it's so useful, I didn't realize how much so until after the fact.

The commenting system is the same, imagine a tree like this discussion, but then every comment could have such a tree of comments inside it, as well as nested replies on the level it is on. I know it's dumb to do that for comments (but it's dumb in a way that makes me laugh so it stays in), but for content it's just awesome.

Some node types like empty, text, links, etc., then let every node decides how subnodes and nodes inside it get displayed, and that's been all I need for over 6 years now. I don't worry about my setup being no longer supported, ever, because my setup is the developer setup. And the project will also by definition not be abandoned before I stop using it. Those are huge benefits actually. I keep checking out what's available on the "shelf", and I want none of it, while my CMS contains a lot of deal breakers for anyone who doesn't have my exact setup and needs.

The point of not getting something off the shelf is not to remake the same thing, but to get something that's not "off-the-shelf", what you count as just a negative is actually also plus. You might say e.g. Drupal can do all that and much more, but Drupal is a huge, and trimming it down to exactly what I want would mean I have to do it again when it updates. Sure, it took years to get to a point where what I had was better for me than off-the-shelf, but I wouldn't have gotten there at all if I had just stuck with off-the-shelf. That also kinda limits the imagination to off-the-shelf.. how can I know I needed something that didn't exist before I made it, right?

Speaking of imagination, that wheel analogy has to die, no offense. It's always more than just "the idea that a round thing rolls", apart from the ideas being more complex the implementation details do matter.


Great quote, haven't ever heard it put that way! I remember David Friedman remarking that one of his most lauded essays was him just saying, what he felt, was how things always worked. (I think it was the one on evolution of private property as a Schelling point.)

My own experience with this phenomenon was when I virtually rolled my eyes at someone insisting that an evolved biological adaptation "wasn't designed", and explained what "designed" meant in that context, and someone praised it for being a good definition he hadn't seen before.

https://news.ycombinator.com/item?id=11121874


Writing a game should be on the list as well. You touch many of the listed topics, and some more, have to combine them in an efficient way, and also it's fun. And your can write games of any complexity level.


I started a game clone challenges[1] list, but haven’t had much time to work on it.

Some more project related resources are awesome-for-beginners[2], The UChicago X-Projects[3], and Beginner Projects[4].

1. https://github.com/rby90/Game-Clone-Challenges

2. https://github.com/MunGell/awesome-for-beginners

3. http://chi.cs.uchicago.edu/index.html

4. https://github.com/jorgegonzalez/beginner-projects


A Roguelike.


Fun enough list. I'm not sure the "any programming language" part holds up. Some of these programs require a GUI element. Others, you have to squint at to see how you would put into some languages due to the wording (cough, class and abstract class, cough). The web ones, it will be hard to avoid JavaScript.


> The web ones, it will be hard to avoid JavaScript.

I don't think any of the projects mentioned are incompatible with a server-side implementation. You could even use something like HTML's image ismap attribute to implement an online white board.


I would add a bunch of cellular automata to that list, Conway's Game of Life, Wolfram and Wireworld are easy to make something very rewarding, cover many bases, and are absolutely open ended.


I've been working on trying to make a (relatively) performant and easy to extend strict cellular automaton in C#, as a project to learn more about .NET core and making stuff for multiple environments. It's been fun and rewarding, but as you try to generalize and expand, you can run into some annoying situations.


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 more mainstream languages, such as Golang or Javascript, you wouldn't go with classes/inheritance.


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't really have the same object orientation abstractions as Java, C#, and Python. Further more the class system in Javascript ES6 are a bit special.

It would be better to talk about domain modelling, suggest interesting domains to model, without actually specifying any particular way to do it.

Edit: I must add that the author have done a great job of collecting these suggestions for tasks though!


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..


Yeah, it really is a minor nitpick, even the "Classes" list is really solid :)

The last update seems to be five years ago and I have to admit, If were writing this 5+ years ago, I too might assume "All modern languages have class hierarchies, right?" comming from Object-Pascal/Java/Python/Ruby

Funny enough, 5 years ago I started workin on a Clojure project at work, which changed my perspective somewhat :)


Check out Common Lisp, which was the first standardized OOP language (1994) with its Common Lisp Object System. Classes, class hierarchies, meta-classes, ... all there. It's not using message passing, but that can be viewed as a simple case of its generic functions...


My personal favorite to implement in order to learn a new framework (mostly GUI oriented): A RPN calculator.

Learn about stacks, state, GUI... Small enough in scope, lots of additional features imaginable.


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.


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.1415927”, n+1)
    else
      print “number out of supported range”
If you don’t cheat or if ”Keep a limit to how far the program will go” doesn’t mean what I read in it, I have my doubts anyone can write that program, even with support from Google.


There are simple math formulas that approximate pi. You can look one up and run it to the right number of digits. It would be hard without Google, but most programmers should be able to do it with Google so that they don't need to figure out any of the math.


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...


Here's an example if you want to try http://www.benzedrine.ch/pi-spigot.c


This doesn't look like a spigot algorithm. It has a link in the comments[1], it calculates the digits of PI from the beginning. The code you linked seems to implement the exact same algorithm.

I don't fully comprehend the code still, but the SCALE parameter suggest that it handles the elements of the array as a fixed point representation of real numbers. I wonder if it's correct for large number of digits.

[1] http://www.codecodex.com/wiki/Calculate_digits_of_pi#C


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)


What you wrote just returns 0 for a large enough n.


Serves me right for stopping the reading on the first line :)


> I have my doubts that anyone can write that program

Simon Plouffe did it, years ago, with no help from Google.

http://plouffe.fr/Simon%20Plouffe.htm

https://en.m.wikipedia.org/wiki/Bailey–Borwein–Plouffe_formu...


Sorry, didn’t realize that “anyone” switched meaning (from “any person or people” to “a person of importance or authority” (https://en.oxforddictionaries.com/definition/anyone)) between the two uses. My second use should have been quoted, too, because it refers to the “that anyone can solve” in the page’s title, which (at least in my reading) can only have the first meaning.


I’m not sure I understand what you mean. For me, your comment doesn’t hinge on the meaning of ‘anyone’ at all. You clearly implied the problem wasn’t solvable by any person, important or not, by saying “even with support from Google”. You implied you weren’t aware the solution was available with a Google search. But it was solved, first by Simon Plouffe, and then by others, so now you know.

For the lay-programmer, e.g., “any person or people”, everything on that list is an exercise in learning how the problem was solved by someone else, and writing the code for it. The idea is to learn, not to invent the solution from scratch without help. The way to code the spigot algorithm for pi is to lookup the formula, understand it, figure out how to deal with precision and numeric base conversion, and write the code. Pretty much anyone can do that.


”You implied you weren’t aware the solution was available with a Google search. But it was solved, first by Simon Plouffe, and then by others, so now you know.”

Where did I imply it? The site being discussed uses “anyone” in the sense “any person”. I questioned that, but didn’t realize that I used the word in the second meaning the second time I used it.

”The way to code the spigot algorithm for pi is to lookup the formula, understand it, figure out how to deal with precision and numeric base conversion, and write the code. Pretty much anyone can do that.”

That, we disagree about. We live in a world where “Fizz-Buzz” is a thing, so I’m not that optimistic that anybody can do what you describe.


> Where did I imply it?

It seems weird you asked that since I just said where, explicitly. This part of the conversation feels tedious and unnecessary. The precise meaning of “anyone” being used by you & the article is pretty irrelevant.

> I’m not that optimistic that anybody can do what you describe.

You’re right, I disagree. I’m sorry for your pessimism. My children can and do lookup formulas on Wikipedia and code them, it’s not hard, if you care to try. I understand if you feel it is too difficult. FWIW, that’s precisely what the post we’re commenting on is aiming to help curious and optimistic people with. Maybe consider how it might be able to help your situation rather than criticize? Everyone can do fizzbuzz too, it’s existence doesn’t prove anything.


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


If you accept only a finite n this seems easily doable. You just may have to wait awhile for execution to complete.


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.


You can implement the algorithm yourself.


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


It's sad that there isn't a single item related to implementing a compiler or an interpreter here.

That is how I got interested in computer science, and I can bet, a significant fraction of the others here had that experience too.


Someone already suggested that (https://github.com/karan/Projects/issues/87), but it doesn't seem to be incorporated.


Additional one which I found very fun to dick around with: a symbolic calculator capable of doing simple differentiation and integration.


I have also played around with differentiation. I even wrote a template metaprogram in C++ that could differentiate formulas in compile time. However integration is tough, I have never attempted to do it.


There's a whole set specifically about class-based OO, which is pretty hard for “anybody” to solve in a non-class-based or non-OO language; any solution involves developing a class-based OO extension to the language, which is kind of big deal.

That could probably be addressed in part by focussing on types or data structures rather than classes per se.

Similarly, there are problems which mandate threading rather than either concurrency or parallelism, whichever is intended; there are languages in which threads as such are not directly supported, but with one or more structures for concurrency/parallelism that could solve the problem (and languages where threads are supported but directly using them may not be the idiomatic approach depending on the actual concurrency/parallelism requirements.)

So, for a language-neutral set of tasks, it focuses in some places too much on specific languages solutions rather than the problem to be solved.


How about this?

Write an autopilot module to take inputs from altimeters, airspeed instruments, compasses, gyros, GPS, and user input. Give outputs suitable for controlling ailerons, elevator, rudder, and throttles. Extra credit: deploy it in an airliner. :-) :-)


Recently implemented A* Path finding algo using Go as a way to learn Go. Couldn't help myself and went ahead and added a UI layer on top of it using a 2d game library called Ebiten.

Very fun little project! Got a hairy bug, which took me about 1-2 hours to figure out, which involved not realising that when I created a struct and added it to a slice, it was not the same struct as I had just created, in terms of memory address!

So in pseudo code:

myThing := struct{attributes...} mySlice[0] := myThing sameThing := mySlice[0] &sameThing == &myThing False

Definitely know Go a lot better now. Looking forward to doing some others on this list.


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.


i would love to see these projects and solutions be contributed to https://rosettacode.org/

the readme mentions rosettacode as inspiration, which is great. i live the idea of working on tasks through git, but i'd love it even more if i could work on rosettacode tasks directly this way.

greetings, eMBee.


The Web list is a good one for beginners


This is seriously awesome




Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: