Files
Landon Curt Noll a1c86c8a7a add original C links to entry navigation bars
The navigation bar for a winning entry now has a "_Original C_" link
(between the ✅ and the Inventory on the right hand side) so that one
may easily view the original C code that was submitted for IOCCC judging.

Ran `make www timestamp` to perform the above.
2025-08-10 12:46:23 -07:00

783 lines
32 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>2018/burton1 - Best one liner</title>
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
<meta name="description" content="2018 IOCCC entry burton1 - Best one liner">
<meta name="keywords" content="IOCCC, 2018, IOCCC 2018, IOCCC entry, burton1, Best one liner">
</head>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- END: this line ends content from: inc/head.default.html -->
<!-- -->
<!-- This web page was formed via the tool: bin/readme2index.sh -->
<!-- The content of main section of this web page came from: 2018/burton1/README.md -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2018/burton1/README.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2018/burton1/README.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2018/burton1/README.md !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/topbar.default.html -->
<div class="theader">
<nav class="topbar">
<div class="container">
<div class="logo">
<a href="../../index.html" class="logo-link">
IOCCC
</a>
</div>
<div class="topbar-items">
<div class="item">
<span class="item-header">
Entries
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../years.html" class="sub-item-link">
Winning entries
</a>
</div>
<div class="outfit-font">
<a href="../../authors.html" class="sub-item-link">
Winning authors
</a>
</div>
<div class="outfit-font">
<a href="../../location.html" class="sub-item-link">
Location of authors
</a>
</div>
<div class="outfit-font">
<a href="../../bugs.html" class="sub-item-link">
Bugs and (mis)features
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
Fixing entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_author" class="sub-item-link">
Updating author info
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
Status
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../news.html" class="sub-item-link">
News
</a>
</div>
<div class="outfit-font">
<a href="../../status.html" class="sub-item-link">
Contest status
</a>
</div>
<div class="outfit-font">
<a href="../../next/rules.html" class="sub-item-link">
IOCCC rules
</a>
</div>
<div class="outfit-font">
<a href="../../next/guidelines.html" class="sub-item-link">
IOCCC guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../markdown.html" class="sub-item-link">
Markdown guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../SECURITY.html" class="sub-item-link">
Security policy
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
FAQ
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../faq.html" class="sub-item-link">
Frequently asked questions
</a>
</div>
<div class="outfit-font">
<a href="../../quick-start.html#enter" class="sub-item-link">
Enter the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#compiling" class="sub-item-link">
Compiling entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#running_entries" class="sub-item-link">
Running entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#help" class="sub-item-link">
How to help
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
About
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../index.html" class="sub-item-link">
Home page
</a>
</div>
<div class="outfit-font">
<a href="../../social.html" class="sub-item-link">
IOCCC social media
</a>
</div>
<div class="outfit-font">
<a href="../../about.html" class="sub-item-link">
About the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../judges.html" class="sub-item-link">
The judges
</a>
</div>
<div class="outfit-font">
<a href="../../thanks-for-help.html" class="sub-item-link">
Thanks for the help
</a>
</div>
<div class="outfit-font">
<a href="../../contact.html" class="sub-item-link">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</nav>
<div class="header-mobile-menu">
<noscript>
<a href="../../nojs-menu.html" class="topbar-js-label">
Please Enable JavaScript
</a>
</noscript>
<button id="header-open-menu-button" class="topbar-mobile-menu">
<img
src="../../png/hamburger-icon-open.png"
alt="hamburger style menu icon - open state"
width=48
height=48>
</button>
<button id="header-close-menu-button" class="hide-content">
<img
src="../../png/hamburger-icon-closed.png"
alt="hamburger style menu icon - closed state"
width=48
height=48>
</button>
<div id="mobile-menu-panel" class="hide-content">
<div class="mobile-menu-container">
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Entries
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../years.html">
Winning entries
</a>
<a class="mobile-submenu-item" href="../../authors.html">
Winning authors
</a>
<a class="mobile-submenu-item" href="../../location.html">
Location of authors
</a>
<a class="mobile-submenu-item" href="../../bugs.html">
Bugs and (mis)features
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
Fixing entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
Updating author info
</a>
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
Thanks for the help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Status
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../news.html">
News
</a>
<a class="mobile-submenu-item" href="../../status.html">
Contest status
</a>
<a class="mobile-submenu-item" href="../../next/rules.html">
IOCCC rules
</a>
<a class="mobile-submenu-item" href="../../next/guidelines.html">
IOCCC guidelines
</a>
<a class="mobile-submenu-item" href="../../markdown.html">
Markdown guidelines
</a>
<a class="mobile-submenu-item" href="../../SECURITY.html">
Security policy
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
FAQ
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../faq.html">
Frequently asked questions
</a>
<a class="mobile-submenu-item" href="../../quick-start.html#enter">
Enter the IOCCC
</a>
<a class="mobile-submenu-item" href="../../faq.html#compiling">
Compiling entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
Running entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#help">
How to help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
About
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../index.html">
Home page
</a>
<a class="mobile-submenu-item" href="../../social.html">
IOCCC social media
</a>
<a class="mobile-submenu-item" href="../../about.html">
About the IOCCC
</a>
<a class="mobile-submenu-item" href="../../judges.html">
The judges
</a>
<a class="mobile-submenu-item" href="../../contact.html">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
headerOpenMenuButton.addEventListener("click", () => {
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
headerOpenMenuButton.classList.add("hide-content");
headerCloseMenuButton.classList.remove("hide-content");
headerCloseMenuButton.classList.add("topbar-mobile-menu");
mobileMenuPanel.classList.remove("hide-content");
mobileMenuPanel.classList.add("topbar-mobile-panel");
});
headerCloseMenuButton.addEventListener("click", () => {
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
headerCloseMenuButton.classList.add("hide-content");
mobileMenuPanel.classList.add("hide-content");
mobileMenuPanel.classList.remove("topbar-mobile-panel");
headerOpenMenuButton.classList.add("topbar-mobile-menu");
headerOpenMenuButton.classList.remove("hide-content");
});
</script>
<!-- END: this line ends content from: inc/topbar.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<a href="../../2011/zucker/index.html">
<img src="../../png/ioccc.png"
alt="IOCCC image by Matt Zucker"
width=300
height=110>
</a>
<h1>The International Obfuscated C Code Contest</h1>
<h2>2018/burton1 - Best one liner</h2>
<h3>Hex dumper</h3>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/navbar.mid.html -->
<div class="navbar">
<a class="Left" href="../bellard/index.html">&larr; 2018/bellard</a>
<a class="Left" href="../index.html">&uarr; 2018 &uarr;</a>
<a class="Left" href="../burton2/index.html">2018/burton2 &rarr;</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/prog.c">C code</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/Makefile">Makefile</a>
<a class="Right" href="#inventory">Inventory</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/prog.orig.c">Original C</a>
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2018%2Fburton1%2Findex.html">&#x2713;</a>
</div>
<!-- END: this line ends content from: inc/navbar.mid.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<div class="content" id="content">
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
<h2 id="author">Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Dave_Burton">Dave Burton</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- BEFORE: 1st line of markdown file: 2018/burton1/README.md -->
<h2 id="to-build">To build:</h2>
<pre><code> make</code></pre>
<p>There is an alternate version of this entry. See <a href="#alternate-code">Alternate
code</a> below.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./prog &lt; any-file</code></pre>
<h2 id="try">Try:</h2>
<pre><code> ./try.sh</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>An alternate version of this entry, <a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/prog.alt.c">prog.alt.c</a>, is provided
This alternate code was supposed to compile without warnings, however
with modern compilers this is no longer the case so it will only cleanly compile
with <code>-Wno-</code> options.</p>
<h3 id="alternate-build">Alternate build:</h3>
<pre><code> make alt</code></pre>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>prog.alt</code> as you would <code>prog</code>.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>One line, one array, one loop and one statement but it prints many bytes. It won.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>Feed this anything on <code>stdin</code>.</p>
<p>The included <a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/scripthd.sh">scripthd.sh</a> may be used as a driver program for this entry.
It adds several nice-to-have features, and allows salt-to-taste customizability.</p>
<p>This code has been compiled and tested on:</p>
<ul>
<li>OSX-10.11, gcc 4.2.1 and clang 3.0, -O0 and -O3</li>
<li>X86-Linux, gcc 4.1.2 and 4.8.4, -O0 and -O3</li>
<li>ARM-QEMU, gcc 4.8.4, -O0 and -O3</li>
<li>X86-FreeBSD 10.3, clang 3.4.1, -O0 and -O3</li>
<li>TCC 0.9.26 (x86-64), used as a proxy for <a href="../../2001/bellard/index.html">2001/bellard</a></li>
<li>UNIX V7 pcc (Johnson’s C compiler) on a <a href="http://simh.trailing-edge.com/">simulated PDP-11/45</a>
(see the “<strong>SPOILER</strong> section below for further detail)</li>
</ul>
<h3 id="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge:</h3>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program via the source.</p>
<p>If you get stuck, come back and read below for additional hints and information.</p>
<h3 id="how-this-entry-works">How this entry works:</h3>
<p>This started life as a personal challenge: write the shortest hex dump utility
in C.</p>
<p>The self-imposed ground rules in the hunt for shortest:</p>
<ul>
<li>The code has to output correctly.</li>
<li>No extraneous newlines, the code must be portable,
and without bypassing the solution using <code>execve(2)</code>, or functions built upon it
(<code>system(3)</code>, <code>popen(3)</code>, etc).</li>
</ul>
<p>E.g:</p>
<pre><code> main(){system(&quot;hd&quot;);} // it&#39;s turtles all the way down!</code></pre>
<p>is not acceptable.</p>
<p>And, “output correctly” is the output format of this entry. QED.</p>
<p>Early attempts ended up at a reasonably short 157 characters.
This was too long for a one-liner, so it had to be formatted as something more interesting.
This solution is pleasing, but a true one-liner was the hoped-for goal.
Here is the 157 character version in it’s entirety:</p>
<pre><code> char O,o[ 20];L(O){
putchar ( O+ 48+39 *(9&lt;
O));} I(O) {L(~ 15);
O|| puts(o);} main (l){
for(;~(l=getchar()) ;I(O
&amp;=15 ))o[ O++ ]=4&lt;
(4^l &gt;&gt;5) ?l: 46,L
(l&gt;&gt; 4),L (l&amp;15);O&amp;&amp;
I(o[ O]=0 );}//157c</code></pre>
<p>While thinking about this in the shower (you are not the only one that does this!)
came the idea which reduced the code to just 119 chars.
This dramatic reduction started to feel close to minimal, and the hunt resumed.
The progression to the present size is interesting,
and it is interesting that the same algorithm can be expressed so differently
by slight rearrangement of its parts.</p>
<pre><code> // 119
char O,o[20];main(l){for(;~(l=getchar());O||puts(o))o[O++]=isprint(l)?l:46,O&amp;=15,printf(&quot;%02x &quot;,l);O[o]=0;O&amp;&amp;puts(o);}
// 116
char O,o[20];main(l){for(;O++[o]=~(l=getchar())?4&lt;(4^l&gt;&gt;5)?l:46:0;(O&amp;=15)||puts(o))printf(&quot;%02x &quot;,l);O&gt;1&amp;&amp;puts(o);}
// 115
char O,o[20];main(l){for(;O[o]=~(l=getchar())?4&lt;(4^l&gt;&gt;5)?l:46:0;(O=-~O&amp;15)||puts(o))printf(&quot;%02x &quot;,l);O&amp;&amp;puts(o);}
// 113
char O,o[20];main(l){for(;~l;(O=~l?printf(&quot;%02x &quot;,l),-~O&amp;15:!O)||puts(o))O[o]=~(l=getchar())?4&lt;(4^l&gt;&gt;5)?l:46:0;}
// 112
char O,o[20];main(l){for(;~l;(O=~l?-~O&amp;printf(&quot;%02x &quot;,l)*5:!O)||puts(o))O[o]=~(l=getchar())?4&lt;(4^l&gt;&gt;5)?l:46:0;}
// 111
char O,o[20];main(l){for(;~l;O||puts(o))O=(O[o]=~(l=getchar())?4&lt;(4^l&gt;&gt;5)?l:46:0)?-~O&amp;printf(&quot;%02x &quot;,l)*5:!O;}
// 110
char O,o[0];main(l){for(;~l;O||puts(o))O=(O[o]=~(l=getchar())?4&lt;(4^l&gt;&gt;5)?l:46:0)?-~O&amp;printf(&quot;%02x &quot;,l)*5:!O;}
// 109
char O,o[];main(l){for(;~l;O||puts(o))O=(O[o]=~(l=getchar())?4&lt;(4^l&gt;&gt;5)?l:46:0)?-~O&amp;printf(&quot;%02x &quot;,l)*5:!O;}</code></pre>
<p>There are solutions without the ASCII sidebar that are significantly shorter.
These do not compete in the same category, since their output is materially different.
They are derived from the solutions above, but are still fascinating as concise utilities,
so here is their progression, for the curious:</p>
<pre><code> // 102
I;O(O){putchar(O+48+39*(9&lt;O));}main(l){for(;~(l=getchar());O(++I&amp;15?~15:~37))O(l&gt;&gt;4),O(l&amp;15);O(-38);}
// 80
O;main(l){while(~(l=getchar()))printf(&quot;%02x%c&quot;,l,++O&amp;15?32:10);O&amp;15&amp;&amp;puts(&quot;&quot;);}
// 78
O;main(l){for(;~l;(O=~(l=getchar())?printf(&quot;%02x &quot;,l),-~O&amp;15:!O)||puts(&quot;&quot;));}
// 77
O;main(l){for(;~l;(O=~(l=getchar())?-~O&amp;printf(&quot;%02x &quot;,l)*5:!O)||puts(&quot;&quot;));}
// 76
O;main(l){for(;~l;O||puts(&amp;O))O=~(l=getchar())?-~O&amp;printf(&quot;%02x &quot;,l)*5:!O;}</code></pre>
<p>It is possible to reduce the size of each of these by one by eliding the trailing newline.
This was not reported above since the newline kept getting appended by processing software,
and it is more interesting to remove characters by changing code than by filtering:</p>
<pre><code> $ tr -d &#39;\012&#39; &lt; 109.c | wc -c
108
$ tr -d &#39;\012&#39; &lt; 76.c | wc -c
75
$ tr -d &#39;\012&#39; &lt; 109.c | cc -o 108 -xc -
$ verify 108
$</code></pre>
<p>An obfuscated hex dump has been done before:
<a href="../../1986/bright/index.html">1986/bright</a> is similar in function,
but it uses more characters in just setting up its obfuscation than this entire
solution!</p>
<h3 id="bigger-spoiler">BIGGER SPOILER:</h3>
<p>If you are unhappy with the way DEL (character 127) is handled,
replace the cryptic expression <code>4&lt;(4^l&gt;&gt;5)?l:46</code> with <code>32&gt;l|l&gt;126?46:l</code>.
Both take the same number of characters, but the former is a bit more interesting.
Bonus question: how does the first expression work?</p>
<h3 id="biggest-spoiler-and-some-history">BIGGEST SPOILER (and some history):</h3>
<p>Technically, <code>char o[0];</code> is illegal (SS 6.7.6.2) according to ISO (N1570). And
<code>char o[];</code> is a conditionally supported feature (SS 6.7.6.2, 6.10.8.3).
However, it works in modern C implementations as an extension, including GCC,
Clang and TCC, for X86 and ARM, on multiple operating systems (Linux, OSX/macOS,
FreeBSD), so it is <em>functionally</em> correct. MicroSoft Visual C++ does not allow
<code>char o[]</code> or <code>char o[0]</code>, and implements its close relative <code>char o[1]</code> such
that writing more than a single char will cause a fault, which is <em>technically</em>
correct.</p>
<p>But how does this work at all, even as an extension? <code>o[]</code> allocates one(!)
byte in a zero-filled data area (formerly
<a href="https://en.wikipedia.org/wiki/.bss">.bss</a> language). The UNIX-derived systems this code
was run upon all place the storage of <code>O</code> and <code>o</code> into a zero-filled VM page
with nothing following: thus, there are plenty of available and unused zero
bytes following <code>O</code>, addressed via <code>o</code>, and this code only needs 17. This is
<em>undefined</em> behavior, but as shown, it is widely available.</p>
<p>The <a href="http://minnie.tuhs.org/cgi-bin/utree.pl">1979 Seventh Edition UNIX</a> (v7) system pre-dates the IOCCC by several years,
and the source code to <code>sh</code>(1) was a <strong>significant inspiration for this contest</strong>.
See the
FAQ on “<a href="../../faq.html#ioccc_start">IOCCC beginnings</a>”.
There are two C compilers present: <code>cc</code> written by Dennis Ritchie, and <code>pcc</code> written by Steven Johnson.
The nested conditional expressions in 116 and smaller are too complex for <code>cc</code> (“Illegal conditional”)
but <code>pcc</code> handles them correctly, and neither compiler accepts <code>char o[]</code> or
<code>char o[0]</code> and neither put the bytes in a zero-filled page (as a paged VM was
not yet written for UNIX).</p>
<p>More significant is that v7 <code>printf(3)</code> does not report the number of characters
written, and therefore 111 compiles but does not work correctly; 113 is the
shortest code that compiles and runs correctly in Ancient UNIX.</p>
<p>Interesting digression: v7 <code>printf</code> (<code>_doprnt</code>) was written in PDP-11 assembly.
It pre-dates <code>varargs.h</code>, and assembly was the only way to gain access to the
variable argument types. The first edition <em>The C Programming Language</em>, 1978,
page 71, remarks:</p>
<blockquote>
<p>By the way, there is no entirely satisfactory way to write a portable function
that accepts a variable number of arguments, because there is no portable way
for the called function to determine how many arguments where actually passed to
it in a given call. … <code>printf</code>, the most common C function with a variable
number of arguments, … is also non-portable and must be modified for different
environments.</p>
</blockquote>
<p>It is fascinating to explore the roots of C through the history of the operating
system it was birthed within. C is often criticized as a difficult, inscrutable
language, but as this contest demonstrates, this is in parody. <em>Shell-gol</em> is
one of those instances where someone <a href="https://web.archive.org/web/20180521074522/http://www.computerworld.com.au/article/279011/a-z_programming_languages_bourne_shell_sh/?pp=4">preferred a different language</a>, and
(ab)used the preprocessor to re-mold C into something they found comfortable.
Most of the rest of the system, especially in the kernel, are models of clarity
and efficient expression.</p>
<h3 id="tldr">TL;DR:</h3>
<p>So which version is the shortest, portable hex dump?</p>
<ul>
<li>109 works with (most?) modern Unix-like systems and compilers, see example list above.</li>
<li>111 works adds Microsoft, is standards-approved, and does not exploit undefined behavior.</li>
<li>113 works on Ancient UNIX and the portable C compiler.</li>
<li>119 works on all platforms, including the original Ritchie PDP-11 C compiler.</li>
</ul>
<h3 id="final-remarks">Final remarks:</h3>
<p>Clearly, the smallest possible program violates modern best practice.
It is not even possible to compile cleanly, but it will compile correctly.</p>
<p>Included is <a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/prog.alt.c">prog.alt.c</a>, a modern C implementation that is –
perhaps – the smallest, clean-compiling version using <code>clang</code> or <code>gcc</code> with
<code>-Wall -pedantic</code>. Note that while this is larger than all but the original
attempt, it will <em>not</em> work with the original Ritchie PDP-11 C compiler, since
the expression within the ternary remains too complex.</p>
<p>Try:</p>
<pre><code> cat prog.c prog.alt.c</code></pre>
<p>or</p>
<pre><code> cmp -b prog.c prog.alt.c</code></pre>
<p>to compare the differences (<code>diff</code> is not helpful on a one-liner).</p>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<!-- AFTER: last line of markdown file: 2018/burton1/README.md -->
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
<div id="inventory">
<h1 id="inventory-for-2018burton1">Inventory for 2018/burton1</h1>
</div>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/prog.c">prog.c</a> - entry source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/Makefile">Makefile</a> - entry Makefile</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/prog.alt.c">prog.alt.c</a> - alternate source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/prog.orig.c">prog.orig.c</a> - original source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/scripthd.sh">scripthd.sh</a> - driver program - adds several nice-to-have features</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/try.sh">try.sh</a> - script to try entry</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="2018_burton1.tar.bz2">2018_burton1.tar.bz2</a> - download entry tarball</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/README.md">README.md</a> - markdown source for this web page</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton1/.path">.path</a> - directory path from top level directory</li>
<li><a href="index.html">index.html</a> - this web page</li>
</ul>
<hr style="width:10%;text-align:left;margin-left:0">
<h4>
Jump to: <a href="#">top</a>
</h4>
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
</div>
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/footer.inventory.html -->
<!--
Copyright © 1984-2025 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<div class="footer">
<div id="copyright"><h3>Copyright &copy; 1984-2025 by Landon Curt Noll:
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
target="_blank"
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
<p>
This work is <b>licensed by Landon Curt Noll</b> under
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
target="_blank"
rel="license noopener noreferrer"
style="display:inline-block;">CC BY-SA 4.0</a></b>.
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/cc.png"
alt="cc inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/by.png"
alt="person inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/sa.png"
alt="arrow looping back on itself inside circle symbol"><br>
You should <b>carefully review</b> the
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
target="_blank"
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
before using the licensed material.<br>
You may wish to review the
<b><a href="../../license.html"
target="_blank"
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
of <b>CC BY-SA 4.0</b>.<br>
</p>
</div>
<div id="coda"><h3>Coda</h3>
<p>
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2018%2Fburton1%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
</p>
</div>
</div>
<!-- END: this line ends content from: inc/footer.inventory.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->