Informatica problems to solve.

- i want to know if i can program in programming languages like F# or nim.
- in order to know if i can program i should exercise.
- Any known list of "informatica problems" from easy to difficult. So i can exercise. And know if i can program.
By preference not requiring a webserver or gui.
 
The classics are sorting algorithms, from simple bubblesort to not-so-simple quicksort. Bonus points for writing tests that feed random test data. Not every algorithm may be suitable for a functional language like F# though.
Arrays in F# are mutable data types.
 
Arrays in F# are mutable data types.

I only have some brief experience with older ML based languages, interesting programming concepts. IIRC there was no way to split an "array" at arbitrary length for functional processing, you'd have to use list traversal. Which somehow defies the purpose of some sorting algorithms. F# may be different, though.
 
- i want to know if i can program in programming languages like F# or nim.
- in order to know if i can program i should exercise.
Why not write something small but useful.
An interesting problem is also "Conway's game of life".
life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵}
I always get a kick out of Martin Kromberg's live derivation of GoL in APL!
View: https://www.youtube.com/watch?v=a9xAKttWgP4
 
Hi Alain

Here is a little perl program I wrote. It's a bmi calculator. You provide your weight in kg and it tells you your weight in imperial units and your bmi value. It uses the bmi weight range definitions (underweight, normal weight, etc) provided here: https://www.nhlbi.nih.gov/health/educational/lose_wt/BMI/bmicalc.htm

Synopsis.

bmi [-c] [-v] [-t] <weight in kg>

Options.

-c: convert weight to imperial units only
-t: prepend current time
-v: print version and exit

Some usage examples:-

$ bmi 55
bmi: 55kg 121lbs 8:9st bmi 17.7 underweight

$ bmi 75
bmi: 75kg 165lbs 11:11st bmi 24.2 normal weight

$ bmi 80
bmi: 80kg 176lbs 12:8st bmi 25.8 overweight ##........

$ bmi 85
bmi: 85kg 187lbs 13:5st bmi 27.4 overweight #####.....

$ bmi 95
bmi: 95kg 209lbs 14:13st bmi 30.6 obese

The imperial units notation "12:8st" means 12 stone 8 lbs; similarly "13:5st" means 13 stone 5 lbs. You may be wondering why bother converting to imperial units; that is because my brain still works in imperial, but my scales only provide a measurement in kg!

Within the 'overweight' bmi range, it prints a bar of '#' and '.' characters to indicate the position of the current bmi value within the range.
This is to provide a visual indication or "bar chart" of how far you will have to move in either direction to reach either the 'normal weight' or 'obese' ranges.

Using the -t option prepends the output with the current time in 24-hour format.
Using the -c option performs the weight to imperial units conversion only and then exits.
The -v option prints the program version and exits.
Currently the person's height in metres is hard-coded inside the program, in the scalar variable $height.

It would be interesting to see this re-written in both F# and Nim! (I expect my perl version can be improved too haha! :) )

For bonus points add the two features I've listed under the TODO comment in the code:-
1. add a .bmirc file that contains the default height;
2. add a [-h <height in cm>] option to allow height to be specified on the command line
 

Attachments

Every time I venture into a new programming language, the first 3 programs I create are ...
1.) Hello World - This proves that I can handle a structurally complete yet minimalistic source code, and I have everything set up to successfully compile it.
2.) Number guessing game - This proves that I can handle basic loops, conditions, user input, text output, and variables.
3.) Lottery number generator - Introduces random number generation, rounding, etc.
After these I move towards file input and output, and more advanced topics like arrays, lists, hashes, whatever.
If you need specific examples, just run a web search for primary and secondary school programming contests.
 
Implement some standard data structures and algorithms. Implement some of the simpler Unix utilities like wc, head, tail, join, cut, paste, uniq etc.
 
Back
Top