{"id":730,"date":"2014-07-01T00:01:57","date_gmt":"2014-07-01T07:01:57","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=730"},"modified":"2014-06-28T08:21:05","modified_gmt":"2014-06-28T15:21:05","slug":"a-million-ways-to-code-in-the-west","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=730","title":{"rendered":"A Million Ways to Code in the West"},"content":{"rendered":"<p>Actually, it doesn&#8217;t matter west, east, north, or south, as multiple solutions exist for any programming puzzle.<br \/>\n<!--more--><br \/>\nAs an example, and for this month&#8217;s exercise, I present to you the following code:<\/p>\n<pre class=\"screen\">\r\n#include &lt;stdio.h&gt;\r\n\r\nint main()\r\n{\r\n    puts(\"1 one\");\r\n    puts(\"2 two\");\r\n    puts(\"3 three\");\r\n\r\n    return(0);\r\n}<\/pre>\n<p>That&#8217;s a simple, basic program that spews out text:<\/p>\n<p><code>1 one<br \/>\n2 two<br \/>\n3 three<\/code><\/p>\n<p>Your assignment is to devise multiple ways to generate the same output as the above sample code.<\/p>\n<p>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.<\/p>\n<p>And that&#8217;s five ways in addition to the sample shown above.<\/p>\n<p>I&#8217;ve written multiple solutions to the puzzle, each of which are linked to below. Within each source code file you&#8217;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&#8217;t think of, then good for you!<\/p>\n<p><a href=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2014\/07\/07exercise.1.c\">Exercise Solution Theme 1<\/a><br \/>\n<a href=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2014\/07\/07exercise.2.c\">Exercise Solution Theme 2<\/a><br \/>\n<a href=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2014\/07\/07exercise.3.c\">Exercise Solution Theme 3<\/a><br \/>\n<a href=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2014\/07\/07exercise.4.c\">Exercise Solution From Beyond Infinity<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How many different ways can you code a simple program? <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=730\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-730","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=730"}],"version-history":[{"count":6,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/730\/revisions"}],"predecessor-version":[{"id":826,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/730\/revisions\/826"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}