What are some "classic" programming exercises?
I've been learning java/android for about 4 months, have been dabbling in php, sql, and C/GTK+ along the way, and starting to feel somewhat comfortale in at least java/android.
What are some of the classic things everyone learns to do? Do you write basic html engines from scratch? Make your own string class just to see if you can? I'm just looking for ideas of things to do, not for a practical purpose, but to learn along the way, things you might do in the first 2 or 3 years of a comp sci degree. |
Fizzbuzz is one of the classic job interview questions...
|
There are many, but a few algorithmic ones are tic-tac-toe, solving various chess problems; not chess games, but special problems like max num of eg queens on a board http://codegolf.stackexchange.com/qu...queens-problem (sometimes known as 'golfing' problems) & https://en.wikipedia.org/wiki/Knight%27s_tour.
Try to program eg linked lists, hashes etc from scratch ie no modules (think basic C code only, inc ptrs). |
"game of life" is always good fun.
|
A simple, but classic challenge, is the Towers of Hanoi.
Ok, well, I'm not sure if that is a classic. It probably should be referred to as "classical" (as in old)... it was a teaser presented to 1st year CS majors many, many, many years ago. |
Towers of hanoi!!!
Yes we all never bored with lectures on that at college! |
Thanks guys, those are the kinds of things I am looking for.
I also found these exercises/puzzles, same author as "The Pragmatic Programmer." http://codekata.pragprog.com/ |
|
|
i remember a simple one from my programming class in college
create a program that outputs this Code:
* make it so it takes input on how many rows tall |
All good suggestions, I have plenty to stay busy with now.
Thanks for the tree idea, spent a couple hours with it, lots of fun. Here is the code I wrote. I'll be working on the others too. |
Quote:
Code:
10 INPUT "how many rows? ",n |
My Radio Shack Color Computer (CoCo, original 1) booted up straight into BASIC. The book that came with it had programming excercises like Russian roulettte. Prompt the user to press enter, use a random number generator, output click, click, bang you're dead. ;)
|
Quote:
Code:
r=11 # r = number of rows in the output file This code fragment creates a character string called cs. Code:
for (j=1;j<=r;j++) {bs=bs" ";as=as"* "}; cs=bs as; Is there a syntax which allows direct specification? Something like ... Code:
cs=" "(r) "* "(r) |
Producers and consumers: https://en.wikipedia.org/wiki/Produc...sumers_problem
Dining philosophers: https://en.wikipedia.org/wiki/Dining...ophers_problem |
All times are GMT -5. The time now is 11:45 AM. |