Problems with usually short solutions to test in a programming language
I'm currently creating an experimental programming language for fun and educational purpose and in search for some tasks beyond the classical "Hello, World!"-program.
I've already come up with these ideas:
- Print out the program's input
- Calculator
- Generate Prime numbers, Fibonacci series
What other interesting programming problems do you have for me to test?
It would be good if they required the language to solve a broad spectrum of task, take prime numbers for example: You 开发者_运维技巧need variables, increment them, divide them, perform actions under certain conditions, etc.
How about a program that takes a dollar amount, such as $27.32, and spits out the minimum set of bills and coins needed to produce it? Lots of looping, some formatting, and an opportunity for a table-driven approach.
Sample output (for the above value):
0 $100
0 $50
1 $20
0 $10
1 $5
2 $1
0 $0.50
1 $0.25
0 $0.10
1 $0.05
2 $0.01
The first thing that springs to mind: place 8 queens on a chess board so that none of them attack each other. Heap- or merge sort might also be interesting examples.
Find the decimal value of pi or e to an arbitrary precision.
精彩评论