in reply to Re^4: convert columns into matrix and get population count?
in thread convert columns into matrix and get population count?

Hello fasoli,

Don’t be discouraged! Learning to program is a lot like learning to ride a bike or drive a car — you can go only so far by studying the theory, to really learn you need to practice a lot. And be prepared to make mistakes, and to learn from those mistakes.

...in most cases what I've tried is either scribbles on paper or just me racking my brains about *how* to start...

Try turning the scribbles into pseudocode. That will allow you to develop the needed algorithm without having to worry about issues of syntax. When you write pseudocode, you then take on the role of the computer: beginning with sample input, you implement (on paper) each step in the pseudocode exactly as written, then evaluate the result and, if necessary, adjust the pseudocode accordingly. In this way you design an algorithm which will work; that’s half the battle won.

...if I actually write some code, just a bunch of syntax errors.

The compiler is your friend here: get it to alert you to as many errors as possible as early as possible. Start with:

use strict; use warnings;

and welcome each error or warning message as though it were a cash windfall. If you have trouble understanding what the messages are getting at, adding:

use diagnostics;

will help. But, most importantly: proceed in small, self-contained steps. Make a small, simple addition to your code, then test that it does what you expect it to. Revision control and regression testing will help you here. Then, when you run into a problem you can’t solve, you’ll have something (pseudocode, working Perl code, additional non-working Perl code) to show the monks.

I think this requires either training (computer science degree etc) or years of practice and I have neither...

I have an IT degree, but I learned the basics of programming before this, and largely on my own. And I have worked in a startup where almost all of the programmers and managers had degrees — including master’s degrees and doctorates — and the best programmer in the whole company — by a long distance — was entirely self-taught with no formal qualifications. But yes, practice is the key (as in so many other areas of life). ;-)

One of my lecturers had a picture on her office wall: a cartoon of a bird in the process of swallowing a frog. But the frog has its arms around the bird’s throat, preventing it from swallowing. And the caption reads, “Never give up!

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,