
5.3 Alternatives
There are many alternatives that can be found with a search engine. However, they are usually more complicated than the “simple algorithm” we used above. Incidently I also found a few online answers that did not give the correct answer. Hence testing results is essential.
Here are 2 mini “programs” found online13 that provided the correct answer with a file (x.
) containing only the matrix of numbers (i.e. removed first line and last column.)
Awk version:
Perl version:
Note: The commands to prepare x.
and the perl
or awk
commands could all be stringed together with the pipe symbol to create a single pipeline. For example for the awk
version we would string commands together as:
Finding the simplest and least specific solution is usually the best answer as it can be used in multiple settings. The simplest solution “version 3” above is probably the best answer to finding the largest number.