Add 2020 source files for real
This commit is contained in:
1 parent
a3c1748648
commit
9d61fc0fb4
147 files changed
+32101
No files matched your search
@@ -0,0 +1,122 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Best one-liner</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Best one-liner</h1>
|
||||
|
||||
<p>Dave Burton<br/>
|
||||
<a href="http://snox.net/ioccc">http://snox.net/ioccc</a><br/>
|
||||
Twitter: @lv2jmp</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog 128
|
||||
|
||||
./prog_be 128
|
||||
|
||||
./prog 170
|
||||
|
||||
./prog 85
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This tiny one-liner is a bit-twiddlers delight! It does all of the work
|
||||
without looping.</p>
|
||||
|
||||
<p>To understand how it works, a good place to start is to look at the hex
|
||||
value that results when the two magic constants are XOR'ed.</p>
|
||||
|
||||
<p>Once you’ve figured out what happens with one set of constants, how can
|
||||
choosing new constants, but using the same computation generate a reversed
|
||||
result?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>Invoke this with a single non-negative integer less than 256, and a useful transformation occurs.</p>
|
||||
|
||||
<h3>Rule 2-ish</h3>
|
||||
|
||||
<p>Exporting the constants B,I,T,S to the makefile allows the code
|
||||
to be compiled for either LE (little-endian) or BE (big-endian) machines(!!),
|
||||
so they are truly configuration parameters, not logic.</p>
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p>One <strike>ping</strike> argument only. It will SEGV on zero arguments, and
|
||||
display strange results if more than one argument.</p>
|
||||
|
||||
<p>Small, non-negative integers only. Useful range is 0 .. 511, sorta, for LE; 0 .. 255 for BE.
|
||||
Bonus points if you can explain why the limits work this way.</p>
|
||||
|
||||
<p>ASCII character set, 64-bit long longs are required.</p>
|
||||
|
||||
<p>v,a,r,i,a,b,l,e,s_NAME the operation.</p>
|
||||
|
||||
<p>No loops, no branches?!?</p>
|
||||
|
||||
<h3>Compilation</h3>
|
||||
|
||||
<p>Compiles cleanly under <code>clang -Wall -Weverything -pedantic</code>,
|
||||
but you need to add <code>--include stdio.h --include stdlib.h</code> for the <code>printf</code>(3) and <code>atoi</code>(3).</p>
|
||||
|
||||
<p>On a little-endian machine:</p>
|
||||
|
||||
<pre><code>clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=6945503773712347754LL -DI=5859838231191962459LL -DT=0 -DS=7 -o prog prog.c
|
||||
</code></pre>
|
||||
|
||||
<p>On a big-endian machine:</p>
|
||||
|
||||
<pre><code>clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=7091606191627001958LL -DI=6006468689561538903LL -DT=1 -DS=0 -o prog.be prog.c
|
||||
</code></pre>
|
||||
|
||||
<p>You might be interested to compile it both ways on the same host, and try:</p>
|
||||
|
||||
<pre><code>./prog 1; ./prog.be 1
|
||||
</code></pre>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user