A Million Ways to Code in the West

Actually, it doesn’t matter west, east, north, or south, as multiple solutions exist for any programming puzzle.

As an example, and for this month’s exercise, I present to you the following code:

#include <stdio.h>

int main()
{
    puts("1 one");
    puts("2 two");
    puts("3 three");

    return(0);
}

That’s a simple, basic program that spews out text:

1 one
2 two
3 three

Your assignment is to devise multiple ways to generate the same output as the above sample code.

Yes, you can use various functions. You can write simple code. You can write complex code. You can use array notation, pointers, anything you want, but in the end you must have at least five different ways to code a solution.

And that’s five ways in addition to the sample shown above.

I’ve written multiple solutions to the puzzle, each of which are linked to below. Within each source code file you’ll find additional techniques you could try, so the total number of solutions is really greater than those shown. And if you come up with something I didn’t think of, then good for you!

Exercise Solution Theme 1
Exercise Solution Theme 2
Exercise Solution Theme 3
Exercise Solution From Beyond Infinity

Leave a Reply