Remove hint.html and index.html
As per discussions on GitHub the index.html and hint.html files should be deleted in favour of README.md files (from any .text/.txt/.markdown/.md files which will be turned into README.md in an upcoming commit).
This commit is contained in:
1 parent
ee8a36310f
commit
77fb0f11a2
143 files changed
-28606
No files matched your search
@@ -1,183 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="dishonorable-mention">Dishonorable mention</h1>
|
|
||||||
<p>Anonymous</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code>make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>The author was too embarrassed that he/she could write such trash, so
|
|
||||||
I promised to protect their identity. I will say that the author of this
|
|
||||||
program has a well known connection with the C programming language.</p>
|
|
||||||
<p>This program is a unique variation on the age old “Hello, world”
|
|
||||||
program. What reads like a read may be written like a write!</p>
|
|
||||||
<p>Copyright (c) 1984, Landon Curt Noll. All Rights Reserved. Permission
|
|
||||||
for personal, educational or non-profit use is granted provided this
|
|
||||||
this copyright and notice are included in its entirety and remains
|
|
||||||
unaltered. All other uses must receive prior permission in writing from
|
|
||||||
both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="second-place-award">Second place award</h1>
|
|
||||||
<p>Dave Decot</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: This entry uses non-standard args to main() that do not work
|
|
||||||
with modern compilers.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>Some new compilers disliked line 15 of the source, so we changed it
|
|
||||||
from:</p>
|
|
||||||
<pre><code>for(signal=0;*k * x * __FILE__ *i;) do {</code></pre>
|
|
||||||
<p>to:</p>
|
|
||||||
<pre><code>for(signal=0;*k *x * __FILE__ *i;) do {</code></pre>
|
|
||||||
<p>This program prints out a string of garbage.</p>
|
|
||||||
<p>The judges also offer this one comment: understand comments!</p>
|
|
||||||
<p>Copyright (c) 1984, Landon Curt Noll. All Rights Reserved. Permission
|
|
||||||
for personal, educational or non-profit use is granted provided this
|
|
||||||
this copyright and notice are included in its entirety and remains
|
|
||||||
unaltered. All other uses must receive prior permission in writing from
|
|
||||||
both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
-178
@@ -1,178 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>README</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>In 1984, the first contest was held. The name of the contest was
|
|
||||||
simply ``Obfuscated C Code Contest’’.</p>
|
|
||||||
<p>Restrictions against machine dependent code were not in the rules in
|
|
||||||
1984. The source file size restriction was only 512 bytes. Rules and
|
|
||||||
results were posted to net.lang.c and net.unix-wizards.</p>
|
|
||||||
<p>Copyright (c) 1984, Landon Curt Noll. All Rights Reserved. Permission
|
|
||||||
for personal, educational or non-profit use is granted provided this
|
|
||||||
this copyright and notice are included in its entirety and remains
|
|
||||||
unaltered. All other uses must receive prior permission in writing from
|
|
||||||
both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="third-place">Third place</h1>
|
|
||||||
<p>Mike Laman</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>Some new compilers dislike lines 6 and 10 of the source, so we
|
|
||||||
changed them from:</p>
|
|
||||||
<pre><code>;++f)a[ b<<5|c] =d++,b+ =e;for( f=0;f<O
|
|
||||||
<<5|c]^ =a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]</code></pre>
|
|
||||||
<p>to:</p>
|
|
||||||
<pre><code>;++f)a[ b<<5|c] =d++,b+= e;for( f=0;f<O
|
|
||||||
<<5|c]^= a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]</code></pre>
|
|
||||||
<p>I hope you have the C beautifier! The program accepts ONE positive
|
|
||||||
argument. Seeing is believing, so try things like:</p>
|
|
||||||
<pre><code>laman 4
|
|
||||||
laman 9
|
|
||||||
laman 16</code></pre>
|
|
||||||
<p>This code should run you in circles.</p>
|
|
||||||
<p>Copyright (c) 1984, Landon Curt Noll. All Rights Reserved. Permission
|
|
||||||
for personal, educational or non-profit use is granted provided this
|
|
||||||
this copyright and notice are included in its entirety and remains
|
|
||||||
unaltered. All other uses must receive prior permission in writing from
|
|
||||||
both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="the-grand-prize">The Grand Prize</h1>
|
|
||||||
<p>Sjoerd Mullender</p>
|
|
||||||
<p>Robbert van Renesse</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>NOTE: This entry is likely to fail and/or dump core on modern
|
|
||||||
computers.</p>
|
|
||||||
<p>Without question, this C program is the one of the most obfuscated C
|
|
||||||
program that has ever been received! Like all great contest entries,
|
|
||||||
they result in a change of rules for the following year. To prevent a
|
|
||||||
flood of similar programs, we requested that programs be non machine
|
|
||||||
specific.</p>
|
|
||||||
<p>This program was selected for the 1987 t-shirt collection.</p>
|
|
||||||
<blockquote>
|
|
||||||
<p>NOTE: If your machine is not a Vax-11 or pdp-11, this program will
|
|
||||||
not execute correctly. In later years, machine dependent code was
|
|
||||||
discouraged.</p>
|
|
||||||
</blockquote>
|
|
||||||
<p>The C startup routine (via crt0.o) transfers control to a location
|
|
||||||
named main. In this case, main just happens to be in the data area. The
|
|
||||||
array of shorts, which has been further obfuscated by use of different
|
|
||||||
data types, just happens to form a meaningful set of PDP-11 and Vax
|
|
||||||
instructions. The first word is a PDP-11 branch instruction that
|
|
||||||
branches to the rest of the PDP code. On the Vax main is called with the
|
|
||||||
calls instruction which uses the first word of the subroutine as a mask
|
|
||||||
of registers to be saved. So on the Vax the first word can be anything.
|
|
||||||
The real Vax code starts with the second word. This small program makes
|
|
||||||
direct calls to the write() Unix system call to produce a message on the
|
|
||||||
screen. Can you guess what is printed? We knew you couldn’t! :-)</p>
|
|
||||||
<p>Copyright (c) 1984, Landon Curt Noll. All Rights Reserved. Permission
|
|
||||||
for personal, educational or non-profit use is granted provided this
|
|
||||||
this copyright and notice are included in its entirety and remains
|
|
||||||
unaltered. All other uses must receive prior permission in writing from
|
|
||||||
both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,180 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-one-liner">Best one liner</h1>
|
|
||||||
<p>Jack Applin [with help from Robert Heckendorn]</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>One liner programs are short but twisted. This “Hello, World” version
|
|
||||||
certainly takes its time saying hello.</p>
|
|
||||||
<p>Copyright (c) 1985, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="the-most-obscure-program">The most obscure program</h1>
|
|
||||||
<p>Lennart Augustsson <chalmers!augustss></p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>An interesting use of a recursive call to main. Compile and execute
|
|
||||||
without args. What is the initial value of b, and does it alter the
|
|
||||||
action of the program?</p>
|
|
||||||
<p>If you let it, the program will continue to print a numerical
|
|
||||||
sequence (can you guess in what base it is printed?) until you run out
|
|
||||||
of memory or until they sell your computer, which ever comes first.</p>
|
|
||||||
<p>Copyright (c) 1985, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
-179
@@ -1,179 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>README</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>185 marked the second year of the Obfuscated C Code Contest.</p>
|
|
||||||
<p>Hints against machine dependent code were added to the rules to avoid
|
|
||||||
another 1984 style winner. Rules and results were posted to net.lang.c
|
|
||||||
and net.unix-wizards. Larry Bassel was invited to help in the judging.
|
|
||||||
Awards were given to 5 classes of programs since we were unable to
|
|
||||||
select only the best 4.</p>
|
|
||||||
<p>Copyright (c) 1985, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="the-strangest-appearing-program">The strangest appearing
|
|
||||||
program</h1>
|
|
||||||
<p>Ed Lycklama</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: This entry uses non-standard args to main() that do not work
|
|
||||||
with modern compilers.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>Run the program without any arguments. Type in some very long lines
|
|
||||||
and notice how it redisplays it.</p>
|
|
||||||
<p>The program itself looks like tty noise. Notice that even ‘define’ in
|
|
||||||
#define can be defined.</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1985, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,185 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="grand-prize-for-most-well-rounded-in-confusion">Grand prize for
|
|
||||||
most well-rounded in confusion</h1>
|
|
||||||
<p>Carl Shapiro</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>As submitted, this program was 3 lines (2 of defines and 1 of code).
|
|
||||||
To make news & mail happy we split the last line into 7. Join them
|
|
||||||
back without the newlines to get the original version.</p>
|
|
||||||
<p>This program was selected for the 1987 t-shirt collection.</p>
|
|
||||||
<p>We found this program is be simply a<strong>maze</strong>ing! Run
|
|
||||||
this program without arguments and notice the output.</p>
|
|
||||||
<p>Copyright (c) 1985, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="the-worst-abuse-of-the-c-preprocessor">The worst abuse of the C
|
|
||||||
preprocessor</h1>
|
|
||||||
<p>Col. G. L. Sicherman</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: This entry uses non-standard args to main() that do not work
|
|
||||||
with modern compilers.</p>
|
|
||||||
<p>NOTE: This entry uses non-standard args to main() that do not work
|
|
||||||
with modern compilers.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>This program abuses the C preprocessor so much that some /lib/cpp’s
|
|
||||||
fail to strip out all of the comments on the first pass! If you were
|
|
||||||
able to understand Decot’s entry in 1984, you will have a head start on
|
|
||||||
this one.</p>
|
|
||||||
<p>Be sure to run this program through lint! If your lint works
|
|
||||||
correctly, it should warn you that the argument ‘Manual’ isn’t used.
|
|
||||||
Like the program says, what’s that mean?</p>
|
|
||||||
<p>Run the program without arguments and enter the letters ‘a’ thru ‘m’
|
|
||||||
on a line. Now enter the letters ‘n’ thru ‘z’. But to borrow a quote
|
|
||||||
from Richard Stallman: If you think you understand what this code does,
|
|
||||||
then you don’t, so read it again! Explain why:</p>
|
|
||||||
<pre><code>sicherman < sicherman.c | sicherman | diff - sicherman.c</code></pre>
|
|
||||||
<p>results in diff reporting a difference on some machines.</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1985, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="most-adaptable-program">Most adaptable program</h1>
|
|
||||||
<p>Jack Applin<br />
|
|
||||||
Hewlett-Packard<br />
|
|
||||||
Ft. Collins<br />
|
|
||||||
Colorado<br />
|
|
||||||
USA</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>Compile and/or execute as directed by the documentation.</p>
|
|
||||||
<p>The judges were so amused by this little program that we created an
|
|
||||||
award just for it. This program is portable to the C and Fortran 77
|
|
||||||
compilers as well as executable by the bourne shell!</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,189 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-complex-task-done-in-a-complex-way">Best complex task done
|
|
||||||
in a complex way</h1>
|
|
||||||
<p>Lennart Augustsson<br />
|
|
||||||
Dept. of Comp. Sci.<br />
|
|
||||||
Chalmers University of Technology,<br />
|
|
||||||
412 96 Gothenburg<br />
|
|
||||||
Sweden</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>This program computes a specific mathematical value. Simply compile
|
|
||||||
and give it an infinite amount of stack space and cpu time. Otherwise
|
|
||||||
just be satisfied with the approximation displayed just before the core
|
|
||||||
dump.</p>
|
|
||||||
<p>This program will pass lint on your system assuming your lint is
|
|
||||||
brave enough to try and parse it correctly.</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,189 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="most-useful-obfuscation">Most useful obfuscation</h1>
|
|
||||||
<p>Walter Bright</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: The original entry may be built with “make alt”.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>Compile this program and give filenames as arguments. For example
|
|
||||||
try:</p>
|
|
||||||
<pre><code>bright bright.c
|
|
||||||
bright bright</code></pre>
|
|
||||||
<p>Mr. Bright exploits the c pre-processor, similar variables and
|
|
||||||
excessive shifting to obfuscate an otherwise useful binary display
|
|
||||||
program. This gives you a small example of what it is like to maintain
|
|
||||||
the Bourne shell! :-}</p>
|
|
||||||
<p>NOTE: To compile with modern compilers, you make need to: make
|
|
||||||
alt.</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="worst-abuse-of-the-c-preprocessor">Worst abuse of the C
|
|
||||||
preprocessor</h1>
|
|
||||||
<p>Jim Hague<br />
|
|
||||||
University of Kent at Canterbury<br />
|
|
||||||
Canterbury, Kent<br />
|
|
||||||
UK</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>Compile this program and feed ascii text into standard input. This
|
|
||||||
program is known to pass lint on some systems and abort lint on
|
|
||||||
others.</p>
|
|
||||||
<p>This program was selected for the 1987 t-shirt collection.</p>
|
|
||||||
<p>Think morse code when you ponder this program. Note how use of
|
|
||||||
similar variables can be obfuscating! The author notes that this program
|
|
||||||
implements the international morse standard. Now for extra credit, what
|
|
||||||
morse message does the program spell out?</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-simple-task-performed-in-a-complex-way">Best simple task
|
|
||||||
performed in a complex way</h1>
|
|
||||||
<p>Bruce Holloway<br />
|
|
||||||
Digital Research, Inc.<br />
|
|
||||||
Monterey, CA<br />
|
|
||||||
USA</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: This entry uses non-standard args to main() that do not work
|
|
||||||
with modern compilers.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>Believe it or not, this is the old standard “Hello, world” program
|
|
||||||
performed in a very complex way. The judges and the author defy you do
|
|
||||||
determine how it does it. It is a good thing that K&R didn’t use
|
|
||||||
this version as the first C program!</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
-186
@@ -1,186 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>README</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>The 1986 contest was named: “The Third International Obfuscated C
|
|
||||||
Code Contest”</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
<p>The rules for 1986 suggested categories due to the success of the
|
|
||||||
1985 judging method. The maximum size was increased from 512 to 1024
|
|
||||||
bytes. Larry Bassel joined as the second official judge.</p>
|
|
||||||
<p>A poll was taken for the worst code for BSD and System V program. The
|
|
||||||
Bourne Shell (/bin/sh) won for both systems. The BSD finger program took
|
|
||||||
third place.</p>
|
|
||||||
<p>Rules and results were posted to net.lang.c and net.unix-wizards.
|
|
||||||
Micro/Systems Journal published started regular publishing of the
|
|
||||||
winners. The practice of making first announcement of the winners at the
|
|
||||||
Summer Usenix BOF started this year. A notice was posted to
|
|
||||||
net.announce.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-layout">Best layout</h1>
|
|
||||||
<p>Eric Marshall<br />
|
|
||||||
System Development Corporation, a Burroughs Company<br />
|
|
||||||
P.O. Box 517<br />
|
|
||||||
Paoli, PA.<br />
|
|
||||||
19301</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: This entry uses non-standard args to main() that do not work
|
|
||||||
with modern compilers.</p>
|
|
||||||
<h1 id="judges-comments">Judges’ comments:</h1>
|
|
||||||
<p>This program prints the name of the picture. The layout is somewhat
|
|
||||||
pretty through it is not the usual sort of output one would expect from
|
|
||||||
printing a program!</p>
|
|
||||||
<p>This program was selected for the 1987 t-shirt collection.</p>
|
|
||||||
<p>This program is known to give some C compilers a problems.</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="most-illegible-code">Most illegible code</h1>
|
|
||||||
<p>Michael H. Pawka<br />
|
|
||||||
Naval Ocean Systems Center<br />
|
|
||||||
San Diego, Ca<br />
|
|
||||||
92152</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>The judges found this entry to be one of hardest to read without the
|
|
||||||
aid of <code>/lib/cpp</code> and a good editor. When run, the program
|
|
||||||
asks if it is obfuscated, of all things!</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-one-liner">Best one liner</h1>
|
|
||||||
<p>Jan Stein</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: The original entry may be built with “make alt”.</p>
|
|
||||||
<p>Judges’ comments:</p>
|
|
||||||
<blockquote>
|
|
||||||
<p>NOTE: to avoid problems with news and mail, the single line was split
|
|
||||||
into 3 lines. Join all lines into a single line to recreate the original
|
|
||||||
file.</p>
|
|
||||||
</blockquote>
|
|
||||||
<p>Compile and link to a filename called ‘a.out’. Try the program with
|
|
||||||
the following argument:</p>
|
|
||||||
<pre><code>a.out ^N^N</code></pre>
|
|
||||||
<p>(^N is ASCII control-N). One some machines, <sup>M</sup>L is needed
|
|
||||||
to get it to output cleanly. Your system may require another set of
|
|
||||||
characters. In time, you will figure out what it does. :-)</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="the-grand-prize-in-most-well-rounded-in-confusion">The grand
|
|
||||||
prize in most well-rounded in confusion</h1>
|
|
||||||
<p>Larry Wall<br />
|
|
||||||
System Development Corporation<br />
|
|
||||||
Santa Monica<br />
|
|
||||||
California<br />
|
|
||||||
US of A</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: This entry uses non-standard args to main() that do not work
|
|
||||||
with modern compilers.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>The original version did not have a ‘;’ character in the first line.
|
|
||||||
This caused a number of System V C pre-preprocessors to gripe about a
|
|
||||||
syntax error.</p>
|
|
||||||
<p>This program is a masterpiece of obfuscation and humor. Larry Wall
|
|
||||||
(the hacker who gave us rn and patch) asks you to compile and consider
|
|
||||||
the warning message generated by the C compiler. Then execute the
|
|
||||||
program and type charters into its standard input. You will see why the
|
|
||||||
compiler documents the program.</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1986, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,203 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-abuse-of-the-rules">Best Abuse of the Rules</h1>
|
|
||||||
<p>Mark Biggar<br />
|
|
||||||
UNiSYS - System Development Group, Santa Monica<br />
|
|
||||||
2525 Colorado AV MD 91-01<br />
|
|
||||||
Santa Monica, CA<br />
|
|
||||||
90406</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<h3 id="to-build-1">To build:</h3>
|
|
||||||
<pre><code>cc -DC="R>0" -DI="if(T)O" -DO="c=write(1,&c,1);" -DP="main(){X}"\
|
|
||||||
-DR="read(0,&c,1)" -DT="c!=015" -DW="while(C)I" -DX="char c;W" markb.c</code></pre>
|
|
||||||
<p>Passes BSD and UTS lint. At least one version of lint is thrown into
|
|
||||||
an infinite loop by this entry.</p>
|
|
||||||
<h3 id="try">Try:</h3>
|
|
||||||
<pre><code>... | markb | od -c (remember to compile as indicated above)</code></pre>
|
|
||||||
<p>By changing the compile line you can make this program do anything
|
|
||||||
you want. This is a very efficient way to transfer source, though it
|
|
||||||
increases the size of Makefiles.</p>
|
|
||||||
<p>With only slight variations, this program can be set to many uses.
|
|
||||||
Consider how easy it would be to release Un*x source in this form; so
|
|
||||||
what if the make files grow a little! :-)</p>
|
|
||||||
<p>One vendor’s lint got hung in an infinite loop over this entry!</p>
|
|
||||||
<blockquote>
|
|
||||||
<p>FYI: We will let Mark get away with this truly sick entry this time,
|
|
||||||
but for the future on we have placed a limit on the size of a compile
|
|
||||||
line.</p>
|
|
||||||
</blockquote>
|
|
||||||
<p>Also see our comment in Larry Wall’s entry regarding Mark’s
|
|
||||||
contribution.</p>
|
|
||||||
<p>Copyright (c) 1987, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-obfuscator-of-programs">Best Obfuscator of Programs</h1>
|
|
||||||
<p>Paul Heckbert<br />
|
|
||||||
Pixar</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: The original entry may be built with “make alt”.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<h3 id="try">Try:</h3>
|
|
||||||
<pre><code>ph 40 < ph.c > foo.c; cc foo.c -o ph
|
|
||||||
ph 20 < a_C_prog.c > bar.c; cc bar.c</code></pre>
|
|
||||||
<p>The judges used this program to fold up very long lines which the BSD
|
|
||||||
fold(1) was unable to process. This program has been added to the
|
|
||||||
contest tool chest.</p>
|
|
||||||
<p>On System V systems, compile with: <code>-Dindex=strchr</code> To
|
|
||||||
compile on a 16 bit machine, change 300000’s to 30000.</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1987, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="worst-style">Worst Style</h1>
|
|
||||||
<p>Spencer Hines<br />
|
|
||||||
OnLine Computer Systems<br />
|
|
||||||
4200 Farragut Street<br />
|
|
||||||
Hyattsville, MD<br />
|
|
||||||
20781<br />
|
|
||||||
USA</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: The original entry may be built with “make alt”.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<h3 id="try">Try:</h3>
|
|
||||||
<pre><code>hines hines.c</code></pre>
|
|
||||||
<p>This program was designed to maximize the bother function for
|
|
||||||
structured programmers. This program takes goto statements to their
|
|
||||||
logical conclusion. The layout and choice of names are classic.</p>
|
|
||||||
<p>We consider this to be a beautiful counter-example for Frank Rubin’s
|
|
||||||
letter to ACM form titled: <em>“GOTO Considered Harmful” Considered
|
|
||||||
Harmful</em>. See the Communications of the ACM, March 1987, Page
|
|
||||||
195-196.</p>
|
|
||||||
<p>NOTE: To compile with modern compilers, you make need to: make
|
|
||||||
alt.</p>
|
|
||||||
<p>Copyright (c) 1987, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
-187
@@ -1,187 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>README</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>1987 marked the “The Fourth International Obfuscated C Code
|
|
||||||
Contest”</p>
|
|
||||||
<p>Copyright (c) 1987, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
<p>The rules for 1987 suggested even more categories than in 1986. Hints
|
|
||||||
for what to do and not to do were also given in the rules. For example,
|
|
||||||
a simple excessive abuse of /lib/cpp was discouraged unless the abuse
|
|
||||||
was unusual. The mailboxes for the contest were moved from nsc to
|
|
||||||
amdahl. The practice of posting a preliminary set of rules for the next
|
|
||||||
year was started this year.</p>
|
|
||||||
<p>Rules and results were posted to comp.lang.c, comp.unix.wizards with
|
|
||||||
an announcement in news.announce.important. Micro/Systems Journal
|
|
||||||
published the 1987 winners. Mark Horton included a version of the 1987
|
|
||||||
winners in an appendix of his C book. The first announcement of winners
|
|
||||||
at the Summer 87 Usenix was helped by a small fly that danced all over
|
|
||||||
the foils.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-one-liner">Best One Liner</h1>
|
|
||||||
<p>David Korn<br />
|
|
||||||
AT&T Bell Labs<br />
|
|
||||||
MH 3C-526B, AT&T Bell Labs<br />
|
|
||||||
Murray Hill, NJ<br />
|
|
||||||
07974<br />
|
|
||||||
USA</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>The Judges believe that this is the best one line entry ever
|
|
||||||
received. Compile on a UN*X system, or at least using a C implementation
|
|
||||||
that fakes it. Very few people are able to determine what this program
|
|
||||||
does by visual inspection. I suggest that you stop reading this section
|
|
||||||
right now and see if you are one of the few people who can.</p>
|
|
||||||
<p>Several points are important to understand in this program:</p>
|
|
||||||
<ol type="1">
|
|
||||||
<li><p>What is the symbol ‘unix’ and what is its value in the program?
|
|
||||||
Clearly ‘unix’ is not a function, and since ‘unix’ is not declared to be
|
|
||||||
a data type (such as int, char, struct foo, enum, …) what must ‘unix’
|
|
||||||
be?</p></li>
|
|
||||||
<li><p>What is the value of the symbol “have”? (hint: the value is NOT 4
|
|
||||||
characters, or ‘h’, or a string) Consider the fact that:</p>
|
|
||||||
<pre><code> char *x;</code></pre></li>
|
|
||||||
</ol>
|
|
||||||
<p>defines a pointer to a character (i.e. an address), and that the ‘=’
|
|
||||||
assigns things is compatible types. Since:</p>
|
|
||||||
<pre><code> x = "have";</code></pre>
|
|
||||||
<p>is legal C, what type of value is “have”?</p>
|
|
||||||
<ol start="3" type="1">
|
|
||||||
<li><p>Note that the following expressions yield the same value:</p>
|
|
||||||
<pre><code> x[3] *(x+3) *(3+x)</code></pre>
|
|
||||||
<p>since addition is communitive. What can be said about the value:</p>
|
|
||||||
<pre><code> 3[x]</code></pre></li>
|
|
||||||
</ol>
|
|
||||||
<p>David Korn’s /bin/ksh provides us with a greatly improved version of
|
|
||||||
the /bin/sh. The source for v7’s /bin/sh greatly inspired this
|
|
||||||
contest.</p>
|
|
||||||
<p>Copyright (c) 1987, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="grand-prize">Grand Prize</h1>
|
|
||||||
<p>Roemer B. Lievaart<br />
|
|
||||||
VU Informatica<br />
|
|
||||||
Churchilllaan 173-IV<br />
|
|
||||||
Amsterdam, The Netherlands</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: The original entry may be built with “make alt”.</p>
|
|
||||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
|
||||||
<p>We believe that you too will be amazed at just how much power
|
|
||||||
Mr. Lievaart packed into 1024 bytes!</p>
|
|
||||||
<p>This Plays the game of reversi (Othello)! Compile and run. It then
|
|
||||||
asks for a playing level. Enter 0-10 (easy-hard). It then asks for your
|
|
||||||
move. A move is a number within 11-88, or a 99 to pass. Illegal moves
|
|
||||||
(except for an illegal pass) are rejected. Then the computer does its
|
|
||||||
move (or a 0 to pass), until the board is full.</p>
|
|
||||||
<p>It plays rather well, for such a small program! Lievaart had to leave
|
|
||||||
out the board printing routine, so you’ll have to take a real game board
|
|
||||||
to play it. … Also due to space-limitations (the rules for 1987 had a
|
|
||||||
limit of 1024 byes), Lievaart took out the passing-handler, which makes
|
|
||||||
its ending-game rather poor. But further it knows all the rules, uses
|
|
||||||
alpha-beta pruning, and it plays f.i. on mobility(!). Most important: it
|
|
||||||
can play a pretty good game of Reversi!</p>
|
|
||||||
<p>The Author was kind enough to supply the fully functional version of
|
|
||||||
the program. The file lievaart2.c contains what the program would have
|
|
||||||
been without the size restriction. This version has the full end game
|
|
||||||
logic and displays the board after each move!</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1987, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="most-useful-obfuscation">Most Useful Obfuscation</h1>
|
|
||||||
<p>Larry Wall<br />
|
|
||||||
Unisys - System Development Group Santa Monica<br />
|
|
||||||
9132 Kester Ave<br />
|
|
||||||
Panorama City, CA 91402 USA</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<h3 id="try">Try:</h3>
|
|
||||||
<pre><code>lwall | bc | lwall
|
|
||||||
input: x*x
|
|
||||||
input: c^2</code></pre>
|
|
||||||
<h3 id="also-try">Also try:</h3>
|
|
||||||
<pre><code>lwall | bc and lwall | cat</code></pre>
|
|
||||||
<p>What we found amazing was how the flow of control was transferred
|
|
||||||
between subroutines. Careful inspection will show that the array of
|
|
||||||
pointers to functions named ‘vi’ refers to functions which seem to not
|
|
||||||
be directly called. Even so, these pointers to functions are being used
|
|
||||||
as an argument to signal. Can you determine why this is being done and
|
|
||||||
how it is being exploited?</p>
|
|
||||||
<p>Some compilers complained about this file, so we changed: ‘=++I’ to
|
|
||||||
‘= ++I’.</p>
|
|
||||||
<p>Copyright (c) 1987, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="generator" content="pandoc" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
||||||
<title>hint</title>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #1a1a1a;
|
|
||||||
background-color: #fdfdfd;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 36em;
|
|
||||||
padding-left: 50px;
|
|
||||||
padding-right: 50px;
|
|
||||||
padding-top: 50px;
|
|
||||||
padding-bottom: 50px;
|
|
||||||
hyphens: auto;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
font-kerning: normal;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
body {
|
|
||||||
font-size: 0.9em;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
background-color: transparent;
|
|
||||||
color: black;
|
|
||||||
font-size: 12pt;
|
|
||||||
}
|
|
||||||
p, h2, h3 {
|
|
||||||
orphans: 3;
|
|
||||||
widows: 3;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
page-break-after: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #1a1a1a;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 1.4em;
|
|
||||||
}
|
|
||||||
h5, h6 {
|
|
||||||
font-size: 1em;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
h6 {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
ol, ul {
|
|
||||||
padding-left: 1.7em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
li > ol, li > ul {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
margin: 1em 0 1em 1.7em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-left: 2px solid #e6e6e6;
|
|
||||||
color: #606060;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
|
||||||
font-size: 85%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
pre {
|
|
||||||
margin: 1em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
pre code {
|
|
||||||
padding: 0;
|
|
||||||
overflow: visible;
|
|
||||||
overflow-wrap: normal;
|
|
||||||
}
|
|
||||||
.sourceCode {
|
|
||||||
background-color: transparent;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
border: none;
|
|
||||||
height: 1px;
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 1em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
display: block;
|
|
||||||
font-variant-numeric: lining-nums tabular-nums;
|
|
||||||
}
|
|
||||||
table caption {
|
|
||||||
margin-bottom: 0.75em;
|
|
||||||
}
|
|
||||||
tbody {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
border-bottom: 1px solid #1a1a1a;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
border-top: 1px solid #1a1a1a;
|
|
||||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
margin-bottom: 4em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#TOC li {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
#TOC ul {
|
|
||||||
padding-left: 1.3em;
|
|
||||||
}
|
|
||||||
#TOC > ul {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#TOC a:not(:hover) {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
code{white-space: pre-wrap;}
|
|
||||||
span.smallcaps{font-variant: small-caps;}
|
|
||||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
||||||
div.column{flex: auto; overflow-x: auto;}
|
|
||||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
||||||
ul.task-list{list-style: none;}
|
|
||||||
ul.task-list li input[type="checkbox"] {
|
|
||||||
width: 0.8em;
|
|
||||||
margin: 0 0.8em 0.2em -1.6em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
|
||||||
</style>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="best-layout">Best Layout</h1>
|
|
||||||
<p>Brian Westley (aka Merlyn Leroy on usenet)<br />
|
|
||||||
Starfire Consulting<br />
|
|
||||||
1121 Hamline Ave. N. #17<br />
|
|
||||||
St. Paul, MN<br />
|
|
||||||
55108<br />
|
|
||||||
USA</p>
|
|
||||||
<h2 id="to-build">To build:</h2>
|
|
||||||
<pre><code> make all</code></pre>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
|
||||||
<p>Putchar must exist in the C library and not just as a macro. If it
|
|
||||||
fails to compile, add the line: <code>#include <stdio.h></code> at
|
|
||||||
the top of the program.</p>
|
|
||||||
<p>Line by line symmetry performed better than any C beautifier. Think
|
|
||||||
of if it as a C ink blot. :-)</p>
|
|
||||||
<p>NOTE: This entry requires a non-standard K&R C compiler to
|
|
||||||
compile.</p>
|
|
||||||
<p>Copyright (c) 1987, Landon Curt Noll & Larry Bassel. All Rights
|
|
||||||
Reserved. Permission for personal, educational or non-profit use is
|
|
||||||
granted provided this this copyright and notice are included in its
|
|
||||||
entirety and remains unaltered. All other uses must receive prior
|
|
||||||
permission in writing from both Landon Curt Noll and Larry Bassel.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best of Show - Most Shrinkable</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best of Show - Most Shrinkable</h1>
|
|
||||||
|
|
||||||
<p>Don Yang<br>
|
|
||||||
<a href="mailto:omoikane@uguu.org">omoikane@uguu.org</a><br>
|
|
||||||
<a href="http://uguu.org/">http://uguu.org/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make akari
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./akari [input_file_or_- [output_file_or_- [even]]]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./akari < example.ppm > odd_output.ppm
|
|
||||||
./akari - - even < example.ppm > even_output.ppm
|
|
||||||
./akari example.ppm odd_output.ppm
|
|
||||||
|
|
||||||
make akari2.c
|
|
||||||
cat akari2.c
|
|
||||||
|
|
||||||
make akari2
|
|
||||||
|
|
||||||
./akari2 < akari2.c
|
|
||||||
./akari2 rot13 < akari2.c
|
|
||||||
|
|
||||||
make akari3.c
|
|
||||||
cat akari3.c
|
|
||||||
|
|
||||||
make akari3
|
|
||||||
|
|
||||||
./akari3
|
|
||||||
|
|
||||||
make akari4.c
|
|
||||||
cat akari4.c
|
|
||||||
|
|
||||||
./akari4
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Akari is an image downsampling utility that accepts 3 inout formats:</p>
|
|
||||||
|
|
||||||
<pre><code>* PGM (netpbm grayscale image). Akari only accept PGM files with this
|
|
||||||
header: P5 <width> <height> 255. Images with extra comments such as
|
|
||||||
the ones produced by GIMP will not be parsed properly.
|
|
||||||
|
|
||||||
* PPM (netpbm RGB image). Only PPM files with this header are
|
|
||||||
accepted: P6 <width> <height> 255.
|
|
||||||
|
|
||||||
* ASCII art (with end of lines in LF bytes only, not CR-LF)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Anything that is not parseable as PGM or PPM will be downsampled as ASCII art.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>Akari is an image downsampling utility. She accepts up to 3 arguments:</p>
|
|
||||||
|
|
||||||
<p>First argument is the input image. If it’s “-” or unspecified, Akari
|
|
||||||
will read from stdin.</p>
|
|
||||||
|
|
||||||
<p>Second argument is the output image. If it’s “-” or unspecified,
|
|
||||||
Akari will write to stdout.</p>
|
|
||||||
|
|
||||||
<p>Third argument, if specified, causes Akari to keep even pixels on even
|
|
||||||
scanlines. By default Akari will keep odd pixels on odd scanlines.</p>
|
|
||||||
|
|
||||||
<p>Examples:</p>
|
|
||||||
|
|
||||||
<pre><code>gcc akari.c -o akari
|
|
||||||
./akari < example.ppm > odd_output.ppm
|
|
||||||
./akari - - even < example.ppm > even_output.ppm
|
|
||||||
./akari example.ppm odd_output.ppm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Akari accepts 3 input formats:
|
|
||||||
* PGM (netpbm grayscale image). Akari only accept PGM files with this
|
|
||||||
header: P5 <width> <height> 255. Images with extra comments such as
|
|
||||||
the ones produced by GIMP will not be parsed properly.
|
|
||||||
* PPM (netpbm RGB image). Only PPM files with this header are
|
|
||||||
accepted: P6 <width> <height> 255.
|
|
||||||
* ASCII art (with end of lines in LF bytes only, not CR-LF)</p>
|
|
||||||
|
|
||||||
<p>This is useful for decoding some curiously interlaced images, such as
|
|
||||||
the included example.ppm</p>
|
|
||||||
|
|
||||||
<p>Anything that is not parseable as PGM or PPM will be downsampled as
|
|
||||||
ASCII art. Since the source code is formatted as ASCII art, it’s only
|
|
||||||
natural to try:</p>
|
|
||||||
|
|
||||||
<pre><code>./akari akari.c akari2.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>akari2.c is also a valid C program, and accepts up to 1 argument.
|
|
||||||
By default, this second program reads text from stdin and writes
|
|
||||||
expanded output to stdout. If the extra argument is specified, the
|
|
||||||
output text will also pass through a rot13 filter.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc akari2.c -o akari2
|
|
||||||
./akari2 < input.txt > expanded_output.txt
|
|
||||||
./akari2 rot13 < input.txt > expanded_and_rot13_output.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>You can combine the two programs together to have just a regular rot13
|
|
||||||
filter:</p>
|
|
||||||
|
|
||||||
<pre><code>./akari2 rot13 < input.txt | ./akari > rot13.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Of course, we wouldn’t stop with just 2 programs, you can downsample
|
|
||||||
the source <em>again</em> and get yet another C program:</p>
|
|
||||||
|
|
||||||
<pre><code>./akari < akari.c | ./akari > akari3.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>We must go deeper:</p>
|
|
||||||
|
|
||||||
<pre><code>./akari < akari.c | ./akari | ./akari > akari4.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>akari3.c and akari4.c are still (mostly valid) C programs.
|
|
||||||
“gcc -Wall” will output a few warnings, but still produce output
|
|
||||||
executables. The output executables each print a message to stdout.</p>
|
|
||||||
|
|
||||||
<p>It takes quite a bit of skill and obfuscation to interleave a
|
|
||||||
C program 4 levels deep, it’s much easier to interleave something like
|
|
||||||
a brainf#$% program in a C program, for example. For comparison, a
|
|
||||||
brainf#$% program is embedded inside akari.c</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,246 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most devolving</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most devolving</h1>
|
|
||||||
|
|
||||||
<p>Philip Blakely<br>
|
|
||||||
Cambridge, UK<br>
|
|
||||||
<a href="mailto:pmblakely@gmail.com">pmblakely@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make blakely
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code># Zoom out and make your terminal window 53 or more lines deep
|
|
||||||
./blakely < blakely.c | head -300
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./blakely < 3.dat | head -100
|
|
||||||
./blakely - < 3.dat | head -40
|
|
||||||
./blakely < evolve_to_3.dat | head -55
|
|
||||||
./blakely < t0_3.dat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This program plays Life, computes Pi to 16 digits
|
|
||||||
if given its own source as input, and allows to check if your garden
|
|
||||||
is a <a href="http://en.wikipedia.org/wiki/Garden_of_Eden_%28cellular_automaton%29">Garden of Eden</a>, all in one source.</p>
|
|
||||||
|
|
||||||
<p>If you have enough time to spare, put the plan of your garden in a text file,
|
|
||||||
and run:</p>
|
|
||||||
|
|
||||||
<pre><code>./blakely - < garden.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>Remarks</h2>
|
|
||||||
|
|
||||||
<p>This program uses a well-known algorithm in order to display pi to
|
|
||||||
fifteen decimal places. The source-layout itself demonstrates the importance of
|
|
||||||
using the correct amount of whitespace in code and the clear superiority of spaces over tabs.</p>
|
|
||||||
|
|
||||||
<p>In order to see the main feature of the code, type:</p>
|
|
||||||
|
|
||||||
<pre><code>./blakely < blakely.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>and wait for about four seconds before using Ctrl-C (or whatever) to end the program. The
|
|
||||||
results are best viewed in a terminal window at least 60 characters
|
|
||||||
high and wide. Alternatively, redirect the output to a separate file
|
|
||||||
(killing when necessary).</p>
|
|
||||||
|
|
||||||
<h2>Overview</h2>
|
|
||||||
|
|
||||||
<p>The program emulates John Conway’s ceullular automaton known as “The
|
|
||||||
Game of Life”, using standard input as a starting grid. The layout of
|
|
||||||
the source-code is such that it evolves to a digital representation of
|
|
||||||
the first 15 decimal places of pi after 4 time steps. This was setup
|
|
||||||
using the other feature of the program which can be demonstrated as follows:</p>
|
|
||||||
|
|
||||||
<pre><code>./blakely - < 3.dat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The program will first display the grid given in 3.dat, and then three
|
|
||||||
more grids (taking a few minutes to display the last). Waiting for any more grids will
|
|
||||||
take a substantial amount of time. The final grid has been put into
|
|
||||||
evolve_to_3.dat, and if you type</p>
|
|
||||||
|
|
||||||
<pre><code>./blakely < evolve_to_3.dat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>then the 3 will reappear after three time steps.</p>
|
|
||||||
|
|
||||||
<p>As should now be clear, this use of program will attempt to evolve a given setup backwards in
|
|
||||||
time according to the Life rules. The resulting grid is clearly not
|
|
||||||
necessarily unique. The program will evolve backwards given <em>any</em> single
|
|
||||||
command line option.</p>
|
|
||||||
|
|
||||||
<p>When evolving forwards, the code can only be stopped by killing the
|
|
||||||
program. In the reverse direction, the code can either be killed, or
|
|
||||||
will stop if it is unable to find a grid that will evolve to the
|
|
||||||
current layout correctly. This can be seen with the sample grid
|
|
||||||
t0_3.dat, which evolves backwards by only two time-steps.</p>
|
|
||||||
|
|
||||||
<h2>Input file format</h2>
|
|
||||||
|
|
||||||
<p>The input files must encode a square grid, where a space is a dead
|
|
||||||
cell, and any other character (except a newline) is a living cell. Each line must be the same
|
|
||||||
length, and end with a single newline character \n (ASCII 10), including the last line. When
|
|
||||||
designing grids, it may help to type full-stops in place of spaces,
|
|
||||||
and do a global replace afterwards. Any deviation from this format will
|
|
||||||
cause errors in the output.</p>
|
|
||||||
|
|
||||||
<h2>Limitations</h2>
|
|
||||||
|
|
||||||
<p>This is only an approximation to the original Life, as it takes place
|
|
||||||
on a finite grid, with borders that are automatically killed off
|
|
||||||
before each time step. However, when evolving backwards, the resulting
|
|
||||||
grids will not cause any cells on the boundaries to come alive.
|
|
||||||
As the display is performed before killing off the borders, some
|
|
||||||
boundary cells may sometimes appear to be alive, but not be treated as
|
|
||||||
such for the following time-step, although any living cells on the
|
|
||||||
right border will never be displayed.</p>
|
|
||||||
|
|
||||||
<p>The maximum grid size is currently 99 by 99 (exceeding this will cause a
|
|
||||||
seg-fault), but changing the two 9802s to MAX_SIZE*MAX_SIZE+1 will
|
|
||||||
solve this, although some reformatting of the
|
|
||||||
code may have to be done to allow larger numbers.</p>
|
|
||||||
|
|
||||||
<h2>Compiler warnings/assumptions</h2>
|
|
||||||
|
|
||||||
<p>When compiled with the -Wall -pedantic -ansi options of gcc, some
|
|
||||||
warnings suggesting extra parentheses occur (not necessary for anyone
|
|
||||||
fully conversant with operator precedence). There is one unused
|
|
||||||
variable, v, but unnamed function parameters are not permitted in ANSI
|
|
||||||
C, so naming it is necessary, and gcc no longer warns about its
|
|
||||||
existence, although earlier versions did.</p>
|
|
||||||
|
|
||||||
<p>Since the program calculates ASCII character values for display, an
|
|
||||||
ASCII based system is required to run it. Also, as mentioned above,
|
|
||||||
any system that uses anything other than a plain ‘\n’ to end a line will cause
|
|
||||||
problems when reading in files.</p>
|
|
||||||
|
|
||||||
<h2>Obfuscations</h2>
|
|
||||||
|
|
||||||
<p>Given the finely-tuned layout required to evolve into pi, this is one of the
|
|
||||||
main obfuscations used in the code. However, running the code through the
|
|
||||||
preprocessor, expanding the defines, and applying GNU’s indent, although
|
|
||||||
making the location of functions and statements clear, by no means makes the
|
|
||||||
code entirely clear. Note that expanding out the #defines does not take the
|
|
||||||
program over the character limit. The main reason for these is to do with the
|
|
||||||
layout, since there are few places that keywords or tokens of over 2
|
|
||||||
characters can be fitted, and requiring the first few lines to be #includes
|
|
||||||
would cause similar problems.</p>
|
|
||||||
|
|
||||||
<p>Other obfuscations used are:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Use of the classic 2[a] syntax to access the third element of the
|
|
||||||
array a</li>
|
|
||||||
<li>Nested ternary operators, combined with shortcut evaluation being
|
|
||||||
required for correct operation</li>
|
|
||||||
<li>Use of the comma operator to embed operations inside one another</li>
|
|
||||||
<li>Calculation of ASCII codes</li>
|
|
||||||
<li>Needlessly recursive functions</li>
|
|
||||||
<li>Use of bitwise-operations.</li>
|
|
||||||
<li>Storing a variable whose value could easily be found from another</li>
|
|
||||||
<li>Use of gotos to emulate a for loop</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Algorithm</h2>
|
|
||||||
|
|
||||||
<p>The forwards evolution of the grid is straightforward.</p>
|
|
||||||
|
|
||||||
<p>The reverse evolution is done using a brute-force method. As far as I
|
|
||||||
know, a brute-force method is the only viable automatic approach for
|
|
||||||
general grids, although more intelligent algorithms would be possible
|
|
||||||
given more space.</p>
|
|
||||||
|
|
||||||
<p>The program starts with an empty “trial” grid and, starting from the
|
|
||||||
top-left, tries all possibilities for the neighbours of the current
|
|
||||||
cell that will cause the cell to evolve to the required state. It then
|
|
||||||
proceeds to the right and down. Thus, it only ever needs to look at
|
|
||||||
the cells below and to the right when testing. However, the already
|
|
||||||
defined cells above and/or to the left of the cell may mean that there
|
|
||||||
are no possibilities that will give the correct state, in which case
|
|
||||||
the code backtracks and tries other possibilities on previous
|
|
||||||
cells. The program knows it has a valid grid if it gets to the last
|
|
||||||
cell. If it cannot find a valid grid, the program exits.</p>
|
|
||||||
|
|
||||||
<p>Since this uses brute-force, it can be very slow. (In fact, the
|
|
||||||
various obfuscations have, at least for the gcc compiler,
|
|
||||||
caused a substantial slowdown.)</p>
|
|
||||||
|
|
||||||
<h2>Program layout</h2>
|
|
||||||
|
|
||||||
<p>The “calculation” of pi was chosen purely because algorithms to find
|
|
||||||
pi are numerous, but the Game of Life is rarely (if ever?) used for
|
|
||||||
this purpose. Also, separate digits made determining the layout somewhat easier.</p>
|
|
||||||
|
|
||||||
<p>Deriving the layout was the most complicated part of the program. As is clear from
|
|
||||||
the final layout featuring pi, the grid was divided into sixteen squares,
|
|
||||||
and layouts that would evolve to each of the nine digits required were
|
|
||||||
found. (This used the three-by-five digit-layout embedded in, at first, a
|
|
||||||
nine-by-nine grid, then in larger grids, until fifteen-by-fifteen was
|
|
||||||
reached.) The fifteen-by-fifteen grids give enough blank cells around
|
|
||||||
them that the digits will not collide when evolving.</p>
|
|
||||||
|
|
||||||
<p>However, this did not allow for sufficient characters to fit the code
|
|
||||||
into. Therefore it was necessary to add some regions that would quickly die off
|
|
||||||
without expanding to collide with the digits' evolution.
|
|
||||||
Groups of cells such as singletons, pairs, and larger groups like</p>
|
|
||||||
|
|
||||||
<pre><code>* * * * * * * * * *
|
|
||||||
*****************
|
|
||||||
* * * * * * * * * *
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>were useful in this regard.</p>
|
|
||||||
|
|
||||||
<p>Other problems were given by keywords which need to be all in one
|
|
||||||
string, keywords requiring space after them, and
|
|
||||||
multi-character tokens. Some of these problems were dealt with by
|
|
||||||
using the #defines and #includes given in the build-script, as there
|
|
||||||
was no way to have sufficient separate lines in the code to do this
|
|
||||||
without causing many difficulties. Some rejigging of the grid’s layout
|
|
||||||
as the code was fitted into its format was also done, resorting to
|
|
||||||
trial-and-improvement in some cases. Occasional use of constructs such
|
|
||||||
as f -= -3 was made as f += 3 could not be fitted into the required format.
|
|
||||||
The fact that the borders would be killed off immediately was also helpful.</p>
|
|
||||||
|
|
||||||
<p>It should be noted that evolving a full 60-by-60 grid backwards using
|
|
||||||
this code would probably take us at least up to the heat-death of the
|
|
||||||
universe.</p>
|
|
||||||
|
|
||||||
<p>The command ./blakely - < blakely.c is therefore <em>not</em> recommended.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best data utility</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best data utility</h1>
|
|
||||||
|
|
||||||
<p>Szabolcs Borsanyi<br>
|
|
||||||
Theoretische Physik<br>
|
|
||||||
Gaussstraße 20<br>
|
|
||||||
42097 Wuppertal<br>
|
|
||||||
Germany<br>
|
|
||||||
<a href="mailto:borsanyi@uni-wuppertal.de">borsanyi@uni-wuppertal.de</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make borsanyi
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./borsanyi < some_data_file
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./borsanyi < data.1
|
|
||||||
./borsanyi < data.2
|
|
||||||
./borsanyi < data.3
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This is a nice quick histogram plotter. A useful utility when you need to
|
|
||||||
look at the distribution of some data.</p>
|
|
||||||
|
|
||||||
<p>Here are some challenges:</p>
|
|
||||||
|
|
||||||
<p>You can modify the number of histogram bins and the scaling of the histogram
|
|
||||||
by editing the source. Try to find them!</p>
|
|
||||||
|
|
||||||
<p>If you look at the source you will notice that the usual array of
|
|
||||||
histogram bins is missing. The source contains no arrays and it does not
|
|
||||||
use malloc or alloca. How does it build the histogram?</p>
|
|
||||||
|
|
||||||
<p>While the input does not need to be sorted, the histogram output is sorted.
|
|
||||||
How does it put the data into buckets? Why does it fork 22 times?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This small piece of program is meant to be a useful tool, when
|
|
||||||
there are some data around and you need a quick glance at the
|
|
||||||
histogram. I am all too often logged in to a remote machine with
|
|
||||||
slow X connection, and a terminal-based program would be of
|
|
||||||
great help.</p>
|
|
||||||
|
|
||||||
<h1>Limitations:</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>I optimized the output for the data I had around, you might want to adjust
|
|
||||||
for your needs. For a great excess of data points the program will crash
|
|
||||||
(depending on the available stack).</li>
|
|
||||||
<li>Giving too few (distinct) points can also cause crash (or division by zero).</li>
|
|
||||||
<li>The program expects plain numbers separated by white spaces.</li>
|
|
||||||
<li>ASCII is assumed.</li>
|
|
||||||
<li>Some POSIX-like system is assumed (fork and wait(NULL) are used)</li>
|
|
||||||
<li>Do not give any arguments to the program.</li>
|
|
||||||
<li>Could rounding errors cause the omission of the highest bin? There might be
|
|
||||||
empty bins at the edges.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Obfuscation:</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The program follows a rather unconventional approach to the task
|
|
||||||
of histogram building. The usual array of integers (for the histogram
|
|
||||||
bins) is missing entirely. The data are read once, the range is determined,
|
|
||||||
but the data points are not put in any array. Yet they are remembered,
|
|
||||||
and each of them is put into its own bin afterwards. But where are the bins?</li>
|
|
||||||
<li>I tried to use as few keywords as possible, hence there are no loops.</li>
|
|
||||||
<li>Multi-process approach for optimal use of resources.</li>
|
|
||||||
<li>Some bin size obfuscation.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,329 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most self deprecating</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most self deprecating</h1>
|
|
||||||
|
|
||||||
<p>David Lowe<br>
|
|
||||||
434 Tenney Drive<br>
|
|
||||||
Rogue River, OR<br>
|
|
||||||
97537<br>
|
|
||||||
<a href="mailto:j.david.lowe@gmail.com">j.david.lowe@gmail.com</a><br>
|
|
||||||
<a href="http://www.pootpoot.net/">http://www.pootpoot.net/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make dlowe
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./dlowe -<n_iterations> corpus1/ [...] corpus0/ < start.net > end.net
|
|
||||||
|
|
||||||
NOTE: The directory entries MUST end in a /
|
|
||||||
|
|
||||||
./dlowe file [file ...] < trained.net
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
Download the
|
|
||||||
<a href="/2011/dlowe/dlowe-aux-data.tar.bz2">2011 dlowe entry dlowe-aux-data.tar.bz2</a>
|
|
||||||
file and then:
|
|
||||||
<pre><code>
|
|
||||||
|
|
||||||
tar -jxf dlowe-aux-data.tar.bz2
|
|
||||||
|
|
||||||
./dlowe dlowe.c < ioccc-winlose-trained.net
|
|
||||||
./dlowe dlowe < ioccc-winlose-trained.net
|
|
||||||
|
|
||||||
./dlowe xor-0/00 < xor-trained.net
|
|
||||||
./dlowe xor-0/11 < xor-trained.net
|
|
||||||
./dlowe xor-1/01 < xor-trained.net
|
|
||||||
./dlowe xor-1/10 < xor-trained.net
|
|
||||||
|
|
||||||
./dlowe hint.html < english-trained.net
|
|
||||||
|
|
||||||
./dlowe dlowe-aux-data.tar.bz2 < png-trained.net
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This entry is a ghoulish example of a brain (dead?) neural network classifier.
|
|
||||||
It comes with a set of corpora for you to try.</p>
|
|
||||||
|
|
||||||
<h4>ioccc-winlose-trained.net</h4>
|
|
||||||
|
|
||||||
<p>You can create your own trained networks. For example, we trained a network
|
|
||||||
on the C code of entries that were supplied to the 20Th IOCCC.</p>
|
|
||||||
|
|
||||||
<p>The ioccc-winlose-trained.net was trained using the earlystop.pl tool:</p>
|
|
||||||
|
|
||||||
<pre><code>rm -f ioccc-winlose-trained.net
|
|
||||||
./earlystop.pl ioccc-winlose-trained.net ioccc_won_training/ ioccc_lost_training/ ioccc_won_test/ ioccc_lost_test/
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>where:</p>
|
|
||||||
|
|
||||||
<pre><code>ioccc_won_training/
|
|
||||||
1/2 of C code of the 20th IOCCC winners (except for dlowe.c from 2011)
|
|
||||||
plus 1/2 of the C code winners from prior IOCCC contests
|
|
||||||
|
|
||||||
ioccc_won_test/
|
|
||||||
1/2 of C code of the 20th IOCCC winners (except for dlowe.c from 2011)
|
|
||||||
plus 1/2 of the C code winners from prior IOCCC contests
|
|
||||||
|
|
||||||
ioccc_lost_training/
|
|
||||||
1/2 of C code from entries that that did not win
|
|
||||||
|
|
||||||
ioccc_lost_test/
|
|
||||||
1/2 of C code from entries that that did not win
|
|
||||||
|
|
||||||
NOTE: The above directies were not shipped and the C code from
|
|
||||||
entries that that did not win was flushed to /dev/null.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The earlystop.pl tool wrote:</p>
|
|
||||||
|
|
||||||
<pre><code>training 1 to 1001...
|
|
||||||
training 1001 to 2001...
|
|
||||||
prior error = 56.746974766043; current error = 58.095691135305
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The resulting ioccc-winlose-trained.net file was included in the
|
|
||||||
dlowe-aux-data.tar.bz2 file in the above mentioned URL.</p>
|
|
||||||
|
|
||||||
<p>The dlowe.c was explicitly excluded from this trailing set. So this test is interesting:</p>
|
|
||||||
|
|
||||||
<pre><code>./dlowe dlowe.c < ioccc-winlose-trained.net
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The match of dlowe.c to the lose/win trailed network was:</p>
|
|
||||||
|
|
||||||
<pre><code>dlowe.c 0.125108
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>NOTE: The non-artificially intelligent decisions of the IOCCC judges include random
|
|
||||||
quirks and their non-linear judgment calls not found in the ioccc trained network.
|
|
||||||
Just because C code is or isn’t scored highly by this network does not
|
|
||||||
mean it will win or lose a future IOCCC. On the other hand … it just might!</p>
|
|
||||||
|
|
||||||
<h4>other data sets to try</h4>
|
|
||||||
|
|
||||||
<p>While we cannot supply you with the losing IOCCC source code, the author did supply a number
|
|
||||||
data sets on which to test:</p>
|
|
||||||
|
|
||||||
<p>We created the english-trained.net as follows:</p>
|
|
||||||
|
|
||||||
<pre><code>./dlowe -8000 english-1/ english-0/ < /dev/null > english-trained.net
|
|
||||||
|
|
||||||
english-0/
|
|
||||||
Non-English (French) text
|
|
||||||
english-1/
|
|
||||||
English (non-French) text
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>We created the png-trained.net as follows:</p>
|
|
||||||
|
|
||||||
<pre><code>./dlowe -8000 png-1/ png-0/ < /dev/null > png-trained.net
|
|
||||||
|
|
||||||
png-0/
|
|
||||||
Non-png (gif) images
|
|
||||||
png-1/
|
|
||||||
png (non-gif) images
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>We created the xor-trained.net as follows:</p>
|
|
||||||
|
|
||||||
<pre><code>./dlowe -8000 xor-1/ xor-0/ < /dev/null > xor-trained.net
|
|
||||||
|
|
||||||
xor-0/
|
|
||||||
Data that XORs to 0
|
|
||||||
xor-1/
|
|
||||||
Data that XORs to 1
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Synopsis:</h1>
|
|
||||||
|
|
||||||
<p>This is an artificially intelligent judging tool to help the IOCCC judges.
|
|
||||||
Here’s to shorter, more frequent contests!</p>
|
|
||||||
|
|
||||||
<h1>Description:</h1>
|
|
||||||
|
|
||||||
<p>This is a multilayer perceptron (a feedforward artificial neural network)
|
|
||||||
which can be trained, using on-line backpropagation, to classify input files.</p>
|
|
||||||
|
|
||||||
<p>It has a fixed topology of 2<sup>16</sup> input neurons, 6 hidden neurons and 1 output
|
|
||||||
neuron.</p>
|
|
||||||
|
|
||||||
<p>The neurons' activation function is the logistic function 1 / (1 + e ^ -x).</p>
|
|
||||||
|
|
||||||
<h2>Classifying</h2>
|
|
||||||
|
|
||||||
<pre><code>./dlowe file [file ...] < trained.net
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>To classify files, one specifies a trained network (on stdin) and one or more
|
|
||||||
files to classify. The program will output one line per successfully-classified
|
|
||||||
file to stderr, with the filename and the classification: a number between 0
|
|
||||||
and 1.</p>
|
|
||||||
|
|
||||||
<p>The interpretation of the classification number depends on how the network was
|
|
||||||
trained, but it’s geared toward interpretation as a <em>probability</em> or a
|
|
||||||
<em>confidence</em>.</p>
|
|
||||||
|
|
||||||
<h2>Training</h2>
|
|
||||||
|
|
||||||
<pre><code>./dlowe -<n_iterations> corpus1/ [...] corpus0/ < start.net > end.net
|
|
||||||
|
|
||||||
NOTE: The directory args must end in a / for them to work.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>To train a network, one specifies a starting network (on stdin), two or more
|
|
||||||
corpora (directories containing training data), and the number of training
|
|
||||||
iterations to run. The program will write some progress data to stderr and,
|
|
||||||
when it’s done, will serialize the updated network to stdout.</p>
|
|
||||||
|
|
||||||
<p>If no input network is given, a random new network will be generated as a
|
|
||||||
starting point (i.e. provide an empty stdin).</p>
|
|
||||||
|
|
||||||
<p>The first corpus will be assigned a target value of 1. The last will be
|
|
||||||
assigned a target value of 0. Intervening directories (if any) will be assigned
|
|
||||||
intermediate target values.</p>
|
|
||||||
|
|
||||||
<p>The learning rate is hard-coded as 0.3. No momentum factor is used.</p>
|
|
||||||
|
|
||||||
<h3>png corpora</h3>
|
|
||||||
|
|
||||||
<p>The png-1 corpus was obtained by manually scraping the first results from an
|
|
||||||
https://images.google.com search for “obfuscate filetype:png”.</p>
|
|
||||||
|
|
||||||
<p>The png-0 corpus was obtained by manually scraping the first results from an
|
|
||||||
https://images.google.com search for “obfuscate filetype:gif”.</p>
|
|
||||||
|
|
||||||
<p>Results:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>using these corpora as a training set</li>
|
|
||||||
<li>using several hundred random <em>.gif and </em>.png files from my home computer as
|
|
||||||
a test set</li>
|
|
||||||
<li>using the included “earlystop.pl” script, which stopped after 67000 iterations.</li>
|
|
||||||
<li>interpreting output of “> 0.5” as “probably a .png” and “< 0.5” as “probably
|
|
||||||
a .gif”</li>
|
|
||||||
<li>produced a network with about 87% accuracy</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>english corpora</h3>
|
|
||||||
|
|
||||||
<p>The english-1 corpus was obtained by manually scraping the first results from
|
|
||||||
a https://www.google.com/webhp?lr=lang_en search for “paris filetype:txt”.</p>
|
|
||||||
|
|
||||||
<p>The english-0 corpus was obtained by manually scraping the first results from
|
|
||||||
a https://www.google.com/webhp?lr=lang_fr search for “paris filetype:txt”.</p>
|
|
||||||
|
|
||||||
<p>Results:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>using these corpora as a training set</li>
|
|
||||||
<li>using several dozen additional text files (obtained by the same methods)
|
|
||||||
as a test set</li>
|
|
||||||
<li>using the included “earlystop.pl” script, which stopped after 10000
|
|
||||||
iterations.</li>
|
|
||||||
<li>interpreting output of “> 0.5” as “probably english” and “< 0.5” as
|
|
||||||
“probably french”</li>
|
|
||||||
<li>produced a network with 100% accuracy</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>xor corpora</h3>
|
|
||||||
|
|
||||||
<p>The xor-1 corpus consists of two files containing ‘01’ and ‘10’ respectively.</p>
|
|
||||||
|
|
||||||
<p>The xor-0 corpus consists of two files containing ‘00’ and ‘11’ respectively.</p>
|
|
||||||
|
|
||||||
<p>Results:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>using these corpora as a training set</li>
|
|
||||||
<li>takes about 8000 iterations to learn xor to within a tolerance of <0.01</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Limitations</h1>
|
|
||||||
|
|
||||||
<p>The program can’t tell you anything meaningful about files with less than two
|
|
||||||
bytes in them (I’m looking at you, smr.c!)</p>
|
|
||||||
|
|
||||||
<p>You must include the trailing directory separator on training directories
|
|
||||||
(this allows the program to be portable without wasting precious bytes on
|
|
||||||
figuring out how to concatenate directory and file names…)</p>
|
|
||||||
|
|
||||||
<p>Serialized network files are only portable between systems with the same
|
|
||||||
floating-point representation and endianness.</p>
|
|
||||||
|
|
||||||
<p>Making sure not to overfit the network to the training data is a bit of a
|
|
||||||
black art. I have enclosed ‘earlystop.pl’, a wrapper script that implements
|
|
||||||
a simple ‘early stopping’ algorithm; other techniques are possible.</p>
|
|
||||||
|
|
||||||
<p>Bad input (e.g. nonexistent files, non-numeric number of iterations, etc.)
|
|
||||||
tends to result in empty output.</p>
|
|
||||||
|
|
||||||
<p>Given exactly one corpus, the program will crash or produce garbage.</p>
|
|
||||||
|
|
||||||
<p>Leaks memory and file descriptors while processing files.</p>
|
|
||||||
|
|
||||||
<p>Will crash and die horribly if it runs out of memory.</p>
|
|
||||||
|
|
||||||
<p>The Microsoft C compiler doesn’t provide a dirent API, so to get this working
|
|
||||||
on a Windows system you’ll need cygwin+gcc (tested) or a dirent compatibility
|
|
||||||
library (untested, but they do exist).</p>
|
|
||||||
|
|
||||||
<p>Backpropagation doesn’t always converge: if you play with this long enough,
|
|
||||||
you’ll eventually have a training session that completely fails to converge.</p>
|
|
||||||
|
|
||||||
<h1>Obfuscation:</h1>
|
|
||||||
|
|
||||||
<p>Zombies! (Since neural networks are modeled after BRAINS, ya know? And
|
|
||||||
corpus sounds a lot like corpse. And I have 4- and 7-year-old kids ;)</p>
|
|
||||||
|
|
||||||
<p>Neural networks are interesting, and while the math isn’t terribly difficult,
|
|
||||||
their behavior is difficult to fully understand.</p>
|
|
||||||
|
|
||||||
<p>Had some extra space in one of the major data structures, and it seemed a
|
|
||||||
shame to waste it.</p>
|
|
||||||
|
|
||||||
<p>Similarly, I think three file pointers ought to be enough for anyone.</p>
|
|
||||||
|
|
||||||
<p>Lots of magic numbers expressed in various ways.</p>
|
|
||||||
|
|
||||||
<p>Random abuse of random C trivia.</p>
|
|
||||||
|
|
||||||
<p>Some textual changes were made to maximize the classification of this program
|
|
||||||
by a network trained to recognize ioccc winners ;)</p>
|
|
||||||
|
|
||||||
<p>… but mostly zombies!</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best ball</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best ball</h1>
|
|
||||||
|
|
||||||
<p>Peter Eastman<br>
|
|
||||||
<a href="mailto:peter.eastman@gmail.com">peter.eastman@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make eastman
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./eastman
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>Quit the program. Resize your terminal window. Run it again.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This round program will generate a classic spherical result!</p>
|
|
||||||
|
|
||||||
<p>You will need a terminal capable of displaying coloured ANSI
|
|
||||||
characters (for example an xterm or a Terminal.app window).</p>
|
|
||||||
|
|
||||||
<p>You might also want to turn off any scrollback history. The program will
|
|
||||||
size itself to the initial geometry of your terminal.</p>
|
|
||||||
|
|
||||||
<p>If you are ambitious, make the font really small and the window really
|
|
||||||
large for hi-rez graphics!</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This program uses ANSI graphics to recreate the classic Boing Ball demo from
|
|
||||||
the Commodore Amiga. See http://www.youtube.com/watch?v=-ga41edXw3A if you
|
|
||||||
aren’t familiar with it. Back in its day, this demo inspired lust and awe in
|
|
||||||
geeks around the world.</p>
|
|
||||||
|
|
||||||
<p>The graphics are raytraced, with procedural textures on the ball and the back
|
|
||||||
wall. I did cheat a little to simplify the calculations: it uses a parallel
|
|
||||||
projection, but textures the back wall to look as if there were a floor being
|
|
||||||
viewed in perspective. The shadow is also just part of the texture, not an
|
|
||||||
actual raytraced shadow.</p>
|
|
||||||
|
|
||||||
<p>This program automatically adapts to the size of the terminal it is running in,
|
|
||||||
so try enlarging the window to get higher resolution. Don’t resize while the
|
|
||||||
program is running, though. It only checks the size once, when it starts up.</p>
|
|
||||||
|
|
||||||
<p>To compile:</p>
|
|
||||||
|
|
||||||
<p>cc -lm ball.c</p>
|
|
||||||
|
|
||||||
<p>Portability:</p>
|
|
||||||
|
|
||||||
<p>It should be completely portable. I’ve tested with gcc on Mac OS X 10.7 and
|
|
||||||
Fedora 10. I would expect it to work in any Unix-like environment.</p>
|
|
||||||
|
|
||||||
<p>Obfuscation:</p>
|
|
||||||
|
|
||||||
<p>I have merged expressions wherever possible, making extensive use of ternary
|
|
||||||
operators, commas, return values of assignment operators, etc. The entire
|
|
||||||
raytracing computation, include ray intersection tests and procedural texture
|
|
||||||
evaluations, is a single expression involving 41 operators.</p>
|
|
||||||
|
|
||||||
<p>Variables are named alphabetically in the order they are declared.</p>
|
|
||||||
|
|
||||||
<p>The third argument to ioctl() should really be a “struct winsize”, and I should
|
|
||||||
then look up the ws_row and ws_col fields, but that makes it way too obvious
|
|
||||||
what I’m doing there. Since a winsize just contains four unsigned shorts, I
|
|
||||||
replaced it with an array. And since all the values will be much less than
|
|
||||||
32767, I further simplified the type to just short[].</p>
|
|
||||||
|
|
||||||
<p>A wonderful thing about ANSI graphics is that it produces nearly unintelligible
|
|
||||||
code. Consider the printf spec to print a single space in a desired color:
|
|
||||||
“\x1B[%dm ”. I could have done something to further obfuscate it, but it’s
|
|
||||||
already indistinguishable from line noise, so why bother?</p>
|
|
||||||
|
|
||||||
<p>There are lots of other minor obfuscations to make the code less obvious. For
|
|
||||||
example, I could have written the outer loop as while(1), but why write a 1
|
|
||||||
when I can calculate it from the return value of usleep() instead? And I could
|
|
||||||
have written usleep(80000), but usleep(79383) just looks so much better. And
|
|
||||||
so on.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,307 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most useful</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most useful</h1>
|
|
||||||
|
|
||||||
<p>Kimmo Fredriksson<br>
|
|
||||||
<a href="mailto:kimmo.k.k.fredriksson@gmail.com">kimmo.k.k.fredriksson@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make fredriksson
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./fredriksson [-icvtnk#] regexp < file
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./fredriksson -k1 -i POOT < /etc/group
|
|
||||||
ulimit -s unlimited
|
|
||||||
./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>The author of this entry was making sure that it does not win the
|
|
||||||
“Best Short Program” award. On the outside, the program behaves
|
|
||||||
as an approximate grep. On the inside, it is a Burrows-Wheeler
|
|
||||||
transform decompressor that produces the source code of the actual
|
|
||||||
obfuscated approximate grep program and calls it. As an exercise,
|
|
||||||
try writing the compressor.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Approximate grep</h1>
|
|
||||||
|
|
||||||
<p>Implements a variant of grep.</p>
|
|
||||||
|
|
||||||
<h2>Usage</h2>
|
|
||||||
|
|
||||||
<p>To search regexp from file, do:</p>
|
|
||||||
|
|
||||||
<pre><code>./fredriksson [-icvtnk#] regexp < file
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Pipes may not work, see the section Limitations.
|
|
||||||
The options <code>-i -c -v</code> and <code>-n</code> are the classic ones:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p><code>-i</code> Ignore case.</p></li>
|
|
||||||
<li><p><code>-c</code> Count only, prints the number of matches, but not the matching lines.</p></li>
|
|
||||||
<li><p><code>-v</code> Invert match.</p></li>
|
|
||||||
<li><p><code>-n</code> Prefixes each printed line by its line number (only if
|
|
||||||
<code>-c</code> was not given).</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>This version of grep recognizes two more options, not present in normal
|
|
||||||
grep implementations:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p><code>-kN</code> Permit <code>N</code> insertions, deletions or mismatches of characters in the
|
|
||||||
matches (aka edit-distance). E.g. “obfuscated” matches “obfuscation”
|
|
||||||
with one deletion and two mismatches. Likewise, “obfuscate” and
|
|
||||||
“oversimplify” match with 7 edit operations. The default is <code>-k0</code>
|
|
||||||
(i.e. exact match).</p></li>
|
|
||||||
<li><p><code>-t</code> Add local transpositions to the set of allowed edit-operations.
|
|
||||||
That is, “ab” matches “ba” with one transposition (swap), and
|
|
||||||
“obfuscated” matches “bofsuact” with three swaps and two insertions,
|
|
||||||
i.e. use <code>-tk5</code> to find this.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Of course, one could construct a standard regexp that matches the same
|
|
||||||
patterns, but the problem is that such a regexp grows exponentially in
|
|
||||||
size when the number of allowed edit operations is increased.</p>
|
|
||||||
|
|
||||||
<p>This version does not recognize all regular expressions, but the
|
|
||||||
following are allowed:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>Wild card: <code>.</code> (dot) matches any character.</p></li>
|
|
||||||
<li><p>Bracket expression: list of charactres enclosed by <code>[</code> and <code>]</code>,
|
|
||||||
matches any single character in the list.</p></li>
|
|
||||||
<li><p>Range expression: two characters separated by hyphen and enclosed in
|
|
||||||
brackets, matches any character that is lexicographically between the
|
|
||||||
two characters (inclusive). E.g. <code>[a-d]</code> is the same as <code>[abcd]</code>.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The special characters must be escaped, if they are to be taken
|
|
||||||
literally (i.e. use e.g. <code>\.</code> to match period). You might want to protect
|
|
||||||
these with <code>'</code>, i.e. use <code>'foo\[bar'</code> instead of <code>foo\[bar</code>. If you want to
|
|
||||||
use the literal <code>-</code> in bracket expression, protect that too (<code>\-</code>),
|
|
||||||
otherwise this is not needed. Note that the syntax differs from standard
|
|
||||||
(?) grep a bit, i.e. in plain grep you can use <code>]</code> and <code>-</code> in bracket
|
|
||||||
expressions by putting <code>]</code> as the first character, and putting <code>-</code> last.</p>
|
|
||||||
|
|
||||||
<h3>Other uses</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>You can use this in place of cat. Just say</p>
|
|
||||||
|
|
||||||
<pre><code> ./fredriksson -k3 cat < file
|
|
||||||
</code></pre></li>
|
|
||||||
<li><p>Like with cat, you can append line numbers too:</p>
|
|
||||||
|
|
||||||
<pre><code> ./fredriksson -nk3 cat < file
|
|
||||||
</code></pre></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Other features</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>It is assumed that the user knows how to feed correct input to the
|
|
||||||
program. If undefined options are given, the result is also undefined.
|
|
||||||
This is a feature.</p></li>
|
|
||||||
<li><p>It may consume huge amounts of memory, and a stack overflow may occur.
|
|
||||||
This results in Segmentation fault (or the equivalent of your favorite
|
|
||||||
system, such as Bus error). This is a feature, that can be used to detect
|
|
||||||
overly long lines in the input file, such as checking the lenght of one
|
|
||||||
liners in IOCCC entries, just adjust your stack size to a suitable
|
|
||||||
threshold, and search for “ioccc”, with option <code>-vk5</code>.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Limitations and remarks</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>Using warning options (such as -Wall) when building gives a lot of warning,
|
|
||||||
such as <code>suggest parentheses around '&&' within '||'</code>, <code>value computed is
|
|
||||||
not used</code>, <code>implicit declaration of function 'putchar'</code>, <code>implicit
|
|
||||||
declaration of function 'getchar'</code>, <code>control reaches end of non-void
|
|
||||||
function</code> and <code>format not a string literal and no format arguments</code>.
|
|
||||||
Please ignore them all, since they just try to tell you that the source
|
|
||||||
is obfuscated.</p></li>
|
|
||||||
<li><p>Only standard input is handled. And <em>only</em> if stdin comes from a file,
|
|
||||||
i.e. pipes may or may not work. If you want to count only (<code>-c</code> option),
|
|
||||||
then this shouldn’t be an issue.</p></li>
|
|
||||||
<li><p>The total lenght of the (preprocessed) pattern is at most
|
|
||||||
<code>sizeof(long)*CHAR_BIT</code>. That does not count things like bracket expressions
|
|
||||||
or escape chars, that is, the pattern <code>'a[bcd]e\.f'</code> is 5 chars long, not
|
|
||||||
10 chars. That does not mean that the matched substring in the standard
|
|
||||||
input has this limit, as using the edit operations can make the string
|
|
||||||
longer. However, no assumptions are made for <code>sizeof(long)</code>. In fact,
|
|
||||||
you can easily use <code>long long</code> instead,</p></li>
|
|
||||||
<li><p>Depending on the file, may require a lot of stack space. If the
|
|
||||||
program segfaults (because of this), say</p>
|
|
||||||
|
|
||||||
<pre><code> ulimit -s unlimited
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>cross your fingers, hope it is enough, and try again.</p></li>
|
|
||||||
<li><p>Assumes C99 standard, because of the one very long line. Most C compilers
|
|
||||||
handle this just fine even in C89 mode, though.</p></li>
|
|
||||||
<li><p>The code should be reasonably portable, it assumes standard ASCII codes
|
|
||||||
for each char, and that a C compiler is on $PATH; the latter is hard coded
|
|
||||||
to be ‘gcc’, but any compiler would work, provided that it supports
|
|
||||||
C99, or long lines as an extension. This code has been tested on:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>GNU/Linux FC4, i386, gcc</li>
|
|
||||||
<li>GNU/Linux FC7, x86_64, gcc 4.1.2, tcc 0.9.24 and icc 10.0</li>
|
|
||||||
<li>GNU/Linux FC9, x86_64, gcc 4.?.?</li>
|
|
||||||
<li>GNU/Linux CentOS 5, gcc 4.1.2</li>
|
|
||||||
<li>GNU/Linux Ubuntu 11.04, gcc 4.5.2</li>
|
|
||||||
<li>SunOS 5.8, UltraSPARC IIIi, gcc 4.1.2</li>
|
|
||||||
<li>SunOS 5.9, UltraSPARC IIIi, gcc 4.1.1 and Sun ONE Studio 8 CC</li>
|
|
||||||
<li>AIX 5.3, IBM eServer p5-550, gcc 3.3.3 and AIX CC Version 6</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>(Btw, tcc has its roots in IOCCC…)</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Obfuscations (a.k.a. spoilers…)</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>The initialized char array includes the source code of the real program,
|
|
||||||
as well as its name and commands to build and run it, all Burrows-Wheeler
|
|
||||||
-transformed, then run-length-encoded with unary coding. The main program
|
|
||||||
extracts and builds that, and then calls it. More precicely, the command
|
|
||||||
to build is</p>
|
|
||||||
|
|
||||||
<pre><code> gcc -O3 ag.c -o ag
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>To change that you need to edit the char array <code>p[]</code> and (possibly) two
|
|
||||||
specially encoded constants, <code>-~('('*'(')</code> and <code>'C'*' '-'-'</code>.
|
|
||||||
The extracted source (<code>ag.c</code>) is obfuscated as well.</p>
|
|
||||||
|
|
||||||
<p>(The original version also deleted the generated source and the
|
|
||||||
corresponding binary after running it, but this feature was removed
|
|
||||||
from the submitted entry.)</p></li>
|
|
||||||
<li><p>The code demonstrates several useful programming paradigms, such as</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>recursion to remove all loops</li>
|
|
||||||
<li>sub routines (<code>main()</code> contains several logical sub routines,
|
|
||||||
selected by the first argument)</li>
|
|
||||||
<li>function pointers</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li><p>Algorithmically, it incorporates the following</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>(inverse) Burrows-Wheeler transform (used also e.g. in bzip2)</li>
|
|
||||||
<li>data compression (really expansion :-), run-lenght-encoding,
|
|
||||||
unary coding (this is why it is expansion rather than compression)</li>
|
|
||||||
<li>approximate string matching</li>
|
|
||||||
<li>dynamic programming to compute the edit distance</li>
|
|
||||||
<li>parallel computation in sequential computers (by packing
|
|
||||||
several objects into a single long, to speed up the dynamic
|
|
||||||
programming)</li>
|
|
||||||
<li>self extracting, compiling and running code</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li><p>As a C program, it demonstrates that</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>a C subset without reserved words is complete enough,
|
|
||||||
(excluding data type specific things (<code>int</code>, <code>char</code>, <code>void</code> …))</li>
|
|
||||||
<li>only letters are needed (i.e. the digits 0-9 are not)</li>
|
|
||||||
<li>only one statement is enough to code any program (plus
|
|
||||||
variable definitions)</li>
|
|
||||||
<li>white space has other uses than just indenting the code</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li><p>It also shows the power of boolean logic and bitwise arithmetic.</p></li>
|
|
||||||
<li><p>This is the first (?) entry in the history of IOCCC, that cannot be
|
|
||||||
totally un-obfuscated by the author. This is due to the clever choice of
|
|
||||||
the actual algorithm, that is obfucated by nature, and it is an open
|
|
||||||
research problem whether a simpler algorithm exists, with the same time
|
|
||||||
complexity.</p></li>
|
|
||||||
<li><p>The main obfuscation comes from using only arithmetic and boolean
|
|
||||||
(short-circuit) logic combined with recursion to remove all loops and
|
|
||||||
if-then-else constructs (also, no ternary <code>?:</code> constructs are present).
|
|
||||||
Two’s complement representation of integers is also abused. E.g. instead
|
|
||||||
of writing <code>x++</code> or <code>x-1</code>, it is much better to write <code>x=-~x</code> and <code>~-x</code>.</p></li>
|
|
||||||
<li><p>No numerical values, other than in the initialized char array, try</p>
|
|
||||||
|
|
||||||
<pre><code> ./fredriksson -ck0 [0-9] < fredriksson.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This should print 1, as there is a numer ‘3’ in the char array (only).
|
|
||||||
You can also try</p>
|
|
||||||
|
|
||||||
<pre><code> ./fredriksson -ck0 [0-9] < ag.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>after running fredriksson at least once (since this generates that
|
|
||||||
<code>ag.c</code> file), and this should print 0.</p></li>
|
|
||||||
<li><p>The source code is best viewed with cat (or using the program itself),
|
|
||||||
instead of some editor. (This is a somewhat system dependent thing.)</p>
|
|
||||||
|
|
||||||
<p>One reason for this is that the code builds (some of the) constant
|
|
||||||
values from string literal <code>"\b"</code>, except that the backspace <code>\b</code> is not
|
|
||||||
escaped like that, the source uses the raw ascii value (010 octal) instead.
|
|
||||||
Thus when viewing with cat or something, that backspace erases the leading
|
|
||||||
quotation mark. Makes it appear uncompilable, and it is: if you copy-paste
|
|
||||||
the cat output from terminal to some editor, save it, the result would not
|
|
||||||
compile.</p>
|
|
||||||
|
|
||||||
<p>Some other constants are built from ASCII values of chars.</p>
|
|
||||||
|
|
||||||
<p>Besides of making the code hard to read, all this makes it also quite large.</p></li>
|
|
||||||
<li><p>Running it through GNU indent or bcpp (C beautifiers) does not beautify
|
|
||||||
it a bit. In fact, indent makes it only worse (at least with the default
|
|
||||||
options). Running it through the preprocessor does basically nothing,
|
|
||||||
since no <code>#define</code>s are used.</p></li>
|
|
||||||
<li><p>Some <em>abuse of the rules</em>. The number of non-whitespace and <code>;</code>, <code>{</code>
|
|
||||||
and <code>}</code> chars is below the limit, but most of the whitespace chars are
|
|
||||||
in an <em>initialized character array</em>. That is, the number of chars in the
|
|
||||||
program exceeds the 2048 limit. However, whitespace is whitespace and
|
|
||||||
the rules did not specify that these must be in between the statements.
|
|
||||||
A character is a whitespace if <code>isspace()</code> returns non-zero value. Even
|
|
||||||
if deleting even one of those chars breaks the program! (This does not
|
|
||||||
apply to the generated source <code>ag.c</code>.)</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most artistic</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most artistic</h1>
|
|
||||||
|
|
||||||
<p>Uri Goren<br>
|
|
||||||
<a href="mailto:goren.uri@gmail.com">goren.uri@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make goren
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo "some text" | ./goren
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo "Hello, world!" | ./goren
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>In the words of <a href="http://en.wikipedia.org/wiki/Rene_Magritte">René François Ghislain Magritte Magritte</a>:</p>
|
|
||||||
|
|
||||||
<p><img src="http://upload.wikimedia.org/wikipedia/en/b/b9/MagrittePipe.jpg" title="Ceci n'est pas une pipe" alt="This is not a pipe" /></p>
|
|
||||||
|
|
||||||
<p>One may ask the surrealist question:</p>
|
|
||||||
|
|
||||||
<pre><code>echo 'If | is just a representation of a pipe, then how can data stuff it?' | ./goren
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>However if one takes a firm stand and declares:</p>
|
|
||||||
|
|
||||||
<pre><code>echo '| is just a representation of a pipe because I say so! So stuff it!' | ./goren
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>something happens! Why?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This program was written in homage to Rene Magritte’s picture “La
|
|
||||||
trahison des images” (The Treachery of Images).</p>
|
|
||||||
|
|
||||||
<p>In order to show my unconditional admiration of this work, I avoided
|
|
||||||
using conditions.</p>
|
|
||||||
|
|
||||||
<p>In this work, Magritte points out that a picture of a pipe is not
|
|
||||||
a pipe. But what IS a pipe? This program tries to provide an answer.</p>
|
|
||||||
|
|
||||||
<p>Magritte’s [test for pipes](http://en.wikipedia.org/wiki/The_Treachery_of_Images} is:</p>
|
|
||||||
|
|
||||||
<pre><code>The famous pipe. How people reproached me for it! And yet, could
|
|
||||||
you stuff my pipe? No, it's just a representation, is it not?
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Accordingly, this program only approves pipes which can be used for
|
|
||||||
stuffing data.</p>
|
|
||||||
|
|
||||||
<p>One thing I tried to achieve is condition free programming. Many
|
|
||||||
have noted that conditions make the code harder to read and understand.
|
|
||||||
A good example would be:</p>
|
|
||||||
|
|
||||||
<p><a href="/years.html#2004_burley">Brent Burley’s 2004 IOCCC winner</a></p>
|
|
||||||
|
|
||||||
<p>That entry omits conditional statements such as “if” and “while”.
|
|
||||||
His achievement in improving clarity by omitting conditions is
|
|
||||||
impressive, but I think it can be taken further, in two ways.</p>
|
|
||||||
|
|
||||||
<p>First, conditional operators, such as ?:, && and ||, can be thrown
|
|
||||||
away. Second, using setjmp and longjmp, which are unfortunately
|
|
||||||
not in common use, might make it difficult for a novice programmer
|
|
||||||
to understnad the code without referring to the man page.</p>
|
|
||||||
|
|
||||||
<p>By removing these, the code is 100% condition free, and every
|
|
||||||
function runs its instructions in perfect order. Naturally, this
|
|
||||||
makes the program flow trivial to understand. This can be verified
|
|
||||||
by disassembling the compiled code and looking for conditional jumps
|
|
||||||
(when compiled with gcc on x86, there are none).</p>
|
|
||||||
|
|
||||||
<h3>Compatibility:</h3>
|
|
||||||
|
|
||||||
<p>The program should compile with any C compiler, but was tested
|
|
||||||
mostly with gcc on Linux.</p>
|
|
||||||
|
|
||||||
<p>It doesn’t support 64 bits (due to integer-pointer casts, and a >>31).
|
|
||||||
It does work on 64-bit Linux, becasue all functions are below 4GB.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,242 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best solved puzzle</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best solved puzzle</h1>
|
|
||||||
|
|
||||||
<p>Shinichiro Hamaji<br>
|
|
||||||
<a href="mailto:shinichiro.hamaji@gmail.com">shinichiro.hamaji@gmail.com</a></p>
|
|
||||||
|
|
||||||
<p>bsoup</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make hamaji
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hamaji < a_nonogram_file
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hamaji < dragon.nono
|
|
||||||
./hamaji < random.nono
|
|
||||||
./hamaji < soccer.nono
|
|
||||||
./hamaji < codegolf.nono
|
|
||||||
./hamaji < face.nono
|
|
||||||
./hamaji < penguin.nono
|
|
||||||
./hamaji < samurai.nono
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This program solves “Nonogram”, which also known as “Paint by Numbers”:</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/Nonogram">http://en.wikipedia.org/wiki/Nonogram</a></p>
|
|
||||||
|
|
||||||
<p>This entry roar as the Year of the Dragon: A year considered
|
|
||||||
some to be good luck. Well it was certainly true that the
|
|
||||||
IOCCC was lucky to get such a fine submission!</p>
|
|
||||||
|
|
||||||
<p>The source code is a solution to a Paint by Numbers puzzle when you
|
|
||||||
paint by C. Try your hand at solving a few of the other .nono
|
|
||||||
files and then compare your solution with this program!</p>
|
|
||||||
|
|
||||||
<p>NOTE: NONOGRAM ® is a registered Trademark and is used with permission.
|
|
||||||
See http://nonogram.com/ for more information.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>The format of the input files are as same as this site:</p>
|
|
||||||
|
|
||||||
<p><a href="http://codegolf.com/paint-by-numbers">http://codegolf.com/paint-by-numbers</a></p>
|
|
||||||
|
|
||||||
<p>For example, for a simple problem which shows a glider of <a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life">conway’s
|
|
||||||
lifegame</a>.</p>
|
|
||||||
|
|
||||||
<pre><code> 1
|
|
||||||
.
|
|
||||||
112
|
|
||||||
|
|
||||||
1 X
|
|
||||||
1 X
|
|
||||||
3 XXX
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>the input should be</p>
|
|
||||||
|
|
||||||
<pre><code>1
|
|
||||||
1
|
|
||||||
3
|
|
||||||
-
|
|
||||||
1
|
|
||||||
1.1
|
|
||||||
2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The width and the height of an input puzzle should be less than or
|
|
||||||
equal to 60.</p>
|
|
||||||
|
|
||||||
<p>When this solver finds the problem has no solution, it prints “invalid”.
|
|
||||||
This means the problem is indeed broken. For example, this happens for
|
|
||||||
an input like</p>
|
|
||||||
|
|
||||||
<pre><code>2
|
|
||||||
-
|
|
||||||
2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>When this solver cannot find a solution, it prints “failed”. This
|
|
||||||
failure can happen when the problem has more than one solution or the
|
|
||||||
solver cannot solve the input problem. Here is an example input of the
|
|
||||||
former:</p>
|
|
||||||
|
|
||||||
<pre><code>1
|
|
||||||
1
|
|
||||||
-
|
|
||||||
1
|
|
||||||
1
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>There are two solutions:</p>
|
|
||||||
|
|
||||||
<pre><code> 11
|
|
||||||
|
|
||||||
1 X
|
|
||||||
1 X
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>and</p>
|
|
||||||
|
|
||||||
<pre><code> 11
|
|
||||||
|
|
||||||
1 X
|
|
||||||
1 X
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Detail</h3>
|
|
||||||
|
|
||||||
<p>Solving Nonogram is known NP-complete, so we cannot make a solver
|
|
||||||
which solves all puzzles. However, we can write a solver which solves
|
|
||||||
most problems solvable by humans. There are a bunch of ways to write
|
|
||||||
such programs. The two most obvious approaches are:</p>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li>Check all possible solutions with backtracking.</li>
|
|
||||||
<li>Implement all techniques which humans use.</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The former, brute-force approach is easy to implement. However, it
|
|
||||||
works only for smaller problems (width and height should be at most 30
|
|
||||||
or so). Similarly, using generic probabilistic metaheuristics such as
|
|
||||||
simulated annealing doesn’t work for big problems.</p>
|
|
||||||
|
|
||||||
<p><a href="http://ccl.northwestern.edu/netlogo/models/community/Nonogram">http://ccl.northwestern.edu/netlogo/models/community/Nonogram</a></p>
|
|
||||||
|
|
||||||
<p>By its definition, the latter works for all human-solvable
|
|
||||||
problems. The issue of the latter approach is this kind of programs
|
|
||||||
tends to be lengthy. This approach still requires some recursions. The
|
|
||||||
most difficult problems which are considered human-solvable may
|
|
||||||
require some “guesses”. For this kind of problems, we need to assume a
|
|
||||||
cell is a space or a box, go ahead some steps with simple methods,
|
|
||||||
mark the tried cell as a box (or a space if we assumed the tried cell
|
|
||||||
is a box) if a contradiction is found.</p>
|
|
||||||
|
|
||||||
<p>My program uses an approach like “Set based solver” introduced in
|
|
||||||
<a href="http://www.haskell.org/haskellwiki/Nonogram">http://www.haskell.org/haskellwiki/Nonogram</a> .
|
|
||||||
This should be equivalent to the combinations of simple methods (no
|
|
||||||
advanced reasoning with guess). My solver also runs non-recursive
|
|
||||||
guess for each undetermined cells. So, my program should be able to
|
|
||||||
solve most human-solvable problems (assuming humans cannot execute
|
|
||||||
deeper recursions).</p>
|
|
||||||
|
|
||||||
<h3>Obfuscation</h3>
|
|
||||||
|
|
||||||
<p>First of all, as you see, my program looks like a nonogram puzzle
|
|
||||||
which results a dragon. This puzzle is “dragon.nono” in this
|
|
||||||
directory. Note that whitespaces in character literals, a string
|
|
||||||
literal, and around the last comment are considered as a boxed cell.</p>
|
|
||||||
|
|
||||||
<p>My program is based on bit operations for speed. Many values are
|
|
||||||
stored using negative logic (0 means on and 1 means off) to utilize
|
|
||||||
the initial value of global variables. Thus, it might be difficult to
|
|
||||||
figure out how it works.</p>
|
|
||||||
|
|
||||||
<p>My program is decently shortened, because the size of source code is
|
|
||||||
limited by IOCCC’s rule (2048 non-whitespace characters) and a lot of
|
|
||||||
characters are just wasted for numbers around the picture.</p>
|
|
||||||
|
|
||||||
<p>The three requirements (dragon, speed, and size) naturally ended up
|
|
||||||
with the well obfuscated code.</p>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>This program uses two C99 features. One line comments and “long long”.
|
|
||||||
GCC’s “-ansi -pedantic” check should pass:</p>
|
|
||||||
|
|
||||||
<pre><code>$ gcc -ansi -pedantic -std=c99 hamaji.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>I checked my program with gcc-4.6.2 on linux, llvm-gcc-4.2 on mac, and
|
|
||||||
clang-3.0 on mac.</p>
|
|
||||||
|
|
||||||
<p>Note that the behavior of scanf differs on linux and mac, but this
|
|
||||||
program supports both semantics.</p>
|
|
||||||
|
|
||||||
<p>This program should not depend on sizeof(int), sizeof(void*), ASCII,
|
|
||||||
memory layout, undefined evaluation order (e.g., a[i++]=i), etc.
|
|
||||||
This program won’t work if the size of long long literal is less than 8.
|
|
||||||
By grepping the source code of gcc</p>
|
|
||||||
|
|
||||||
<pre><code>grep LONG_LONG_TYPE_SIZE gcc/config/*/*
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>I found long long may be 32bit integers only on AVR.</p>
|
|
||||||
|
|
||||||
<h3>A few more</h3>
|
|
||||||
|
|
||||||
<p>This code is considered as a new year’s postcard in Japan. We chose
|
|
||||||
the dragon because 2012 is the year of dragon.</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/Japanese_New_Year#Postcards">http://en.wikipedia.org/wiki/Japanese_New_Year#Postcards</a></p>
|
|
||||||
|
|
||||||
<p>The second author wrote the picture, and the first author did
|
|
||||||
everything else.</p>
|
|
||||||
|
|
||||||
<p>The dragon.nono, samurai.nono, and penguin.nono was written by the
|
|
||||||
second author. The soccer.nono was from a wikipedia entry. This file
|
|
||||||
is important because it requires some guesses. The random.nono file
|
|
||||||
was randomly generated. The codegolf.nono and face.nono have borrowed
|
|
||||||
from this site:</p>
|
|
||||||
|
|
||||||
<p><a href="http://codegolf.com/paint-by-numbers">http://codegolf.com/paint-by-numbers</a></p>
|
|
||||||
|
|
||||||
<p>You can reproduce dragon.nono from hamaji.c using c2nono.pl:</p>
|
|
||||||
|
|
||||||
<pre><code>perl c2nono.pl hamaji.c | ./hamaji
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best self documenting program</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best self documenting program</h1>
|
|
||||||
|
|
||||||
<p>Hou Qiming<br>
|
|
||||||
<a href="mailto:hqm03ster@gmail.com">hqm03ster@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make hou
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hou 'a calculator expression -- see the C Code for details'
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hou 11/26+222/31
|
|
||||||
|
|
||||||
./hou 'log((21701-19937)-(23209-21701))/log(2)'
|
|
||||||
|
|
||||||
./hou 'sin(1.5708)+0.04321+log(sqrt(exp(1*1*1)))+(1+2*3)-0.4-0.6+(4+6)*(2-1+2*3)-tan(0.785398)+2*10/3*6*sqrt(16/2/2)*10+10000-1000'
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This self-documenting scientific calculator compiles clean with no
|
|
||||||
warnings under the most strict pedantic mode of gcc and clang.</p>
|
|
||||||
|
|
||||||
<p>The first example, along with the correct result appears in the
|
|
||||||
source code. What does it mean?</p>
|
|
||||||
|
|
||||||
<p>The calculator obeys the precendence rules and allows parenthesis,</p>
|
|
||||||
|
|
||||||
<pre><code> ./hou '1+2*3'
|
|
||||||
./hou '(1+2)*3'
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>What exactly does the text formatting do?</p>
|
|
||||||
|
|
||||||
<p>What does this evaluate to in C?</p>
|
|
||||||
|
|
||||||
<pre><code> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h4>Self documenting source</h4>
|
|
||||||
|
|
||||||
<p>Comments would almost be redundant. :-}</p>
|
|
||||||
|
|
||||||
<h4>The ASCII art is valid C code</h4>
|
|
||||||
|
|
||||||
<p>Not just fancy formatted comment removed by the C Pre-processor</p>
|
|
||||||
|
|
||||||
<h4>The only multi-byte strings are format strings</h4>
|
|
||||||
|
|
||||||
<p>The code does not contain some simple string-encoded lookup table for calculator operations.</p>
|
|
||||||
|
|
||||||
<h4>Example input and output in the source</h4>
|
|
||||||
|
|
||||||
<p>The example input and output in the C code is significant. Can you find out why?</p>
|
|
||||||
|
|
||||||
<h4>The button layout</h4>
|
|
||||||
|
|
||||||
<p>The button layout in the C code is significant … not just a nice looking layout.</p>
|
|
||||||
|
|
||||||
<h4>input parsing</h4>
|
|
||||||
|
|
||||||
<p>The parser is functionally equivalent to a normal arithmetic parser for all valid inputs.
|
|
||||||
For another fun challenge: try to determine how it parses the command line argument.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Obfuscations</h3>
|
|
||||||
|
|
||||||
<p>This program is designed to be self-documenting. It doesn’t just provide an
|
|
||||||
example command line. It also provides the expected output and illustrates all
|
|
||||||
supported functionality using embedded ASCII art.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>A few line numbers are significant and careless beautification will break the program.</li>
|
|
||||||
<li>The entire ASCII art is valid code. The preprocessor won’t remove any part of it.</li>
|
|
||||||
<li>The only strings longer than 1 byte are printf/sscanf format strings, even
|
|
||||||
after preprocessing. No string-encoded lookup table is used.</li>
|
|
||||||
<li>The example input and its expected output are both algorithmically significant.</li>
|
|
||||||
<li>The button layout is also significant.</li>
|
|
||||||
<li>The actual syntax being parsed is not the obvious, despite being
|
|
||||||
functionally equivalent for all correct inputs.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>This program requires “argv” to point to writable memory. It doesn’t require
|
|
||||||
the actual argv strings to be writable, though.</li>
|
|
||||||
<li>This program requires ASCII.</li>
|
|
||||||
<li>This program doesn’t work with %e style numbers like “1e-4”.</li>
|
|
||||||
<li>Some seemingly redundant code works to eliminate warnings and evade a gcc bug.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Spoilers</h3>
|
|
||||||
|
|
||||||
<p>The parser parses function names, substraction, and division as single-letter
|
|
||||||
unary operators. A bitmask encoded hash table is used to check no-ops/digits
|
|
||||||
and another hash function maps the ASCII to a function ordinal, which is then
|
|
||||||
executed by the button panel.</p>
|
|
||||||
|
|
||||||
<p>Both hash functions are found using a separate search program. Another program
|
|
||||||
is used to find a way to format one hash function as example input such that
|
|
||||||
it produces something resembling the bitmask hash table as part of its output.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best one liner</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best one liner</h1>
|
|
||||||
|
|
||||||
<p>Taketo Konno<br>
|
|
||||||
Tokyo, Japan<br>
|
|
||||||
<a href="mailto:inaniwa3@gmail.com">inaniwa3@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make konno
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./konno just_a_single_argument_of_lower_case_letters
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./konno qwerty
|
|
||||||
./konno ioccc
|
|
||||||
./konno "the quick brown fox jumps over the lazy dog"
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This tiny program outputs what looks like a tiny keyboard.<br>
|
|
||||||
OK, so the letters are missing. But that is no problem because
|
|
||||||
this program identifes the lower case letters that were pressed!</p>
|
|
||||||
|
|
||||||
<p>It is one of those minimal keyboards without all of those
|
|
||||||
confusing symbols keys. No shift for SHOULDING CAPS
|
|
||||||
but at least it does not have that useless caps lock key!</p>
|
|
||||||
|
|
||||||
<p>We recommend that you completely deconstruct / figure out
|
|
||||||
how this program works and does what it does. Can you
|
|
||||||
extend this program to deal with a full QWERTY keyboard?
|
|
||||||
Can you then minimize the size of that code?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Limitation</h3>
|
|
||||||
|
|
||||||
<p>This program ignores non-lower case letters.</p>
|
|
||||||
|
|
||||||
<h3>Obfuscation</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>“for” is not used.</li>
|
|
||||||
<li>A part of program is encrypted.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most surprisingly portable</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most surprisingly portable</h1>
|
|
||||||
|
|
||||||
<p>Gregor Richards<br>
|
|
||||||
<a href="mailto:Richards@codu.org">Richards@codu.org</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make richards
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./richards
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Oh no, yet another dc-style calculator? (see 2000/dlowe using an embedded Perl
|
|
||||||
interpreter and deemed Worst Abuse of the Rules).
|
|
||||||
Well, this one does it (expression calculation, that is, not the rule abuse) in a different way.
|
|
||||||
The author claims that his calculator does just-in-time compilation.
|
|
||||||
What would you do to prove or disprove his claim without attempting to unravel the source?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This is an implementation of the classic UNIX dc command, the reverse-polish
|
|
||||||
calculator. Actually it’s a pretty bad implementation, since it only implements
|
|
||||||
32-bit integers (well, sizeof(int)-sized integers). It only implements the
|
|
||||||
commands +, -, *, /, p (only for numbers), register stacks, macros and
|
|
||||||
comparisons. Wow, you’d think I could’ve done better in 2K of code.</p>
|
|
||||||
|
|
||||||
<p>OH! I forgot to mention! It’s a JIT.</p>
|
|
||||||
|
|
||||||
<p>Wait, don’t stop reading! I know what you’re thinking, platform-specific code
|
|
||||||
is discouraged in IOCCC. But do you see any platform-specific code? There’s no
|
|
||||||
assembler here! This JIT works on a dozen platforms, and the only
|
|
||||||
platform-specific assumptions it makes are that the stack grows down and
|
|
||||||
integers are at least 32-bit.</p>
|
|
||||||
|
|
||||||
<p>You will probably get warnings while compiling the code. In particular:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>If your system requires the inclusion of alloca.h to use alloca, use the
|
|
||||||
compile flag -DAH</li>
|
|
||||||
<li>If your system cannot use mmap, use the compile flag -DNM</li>
|
|
||||||
<li>I don’t include any headers I don’t strictly need to, so you’ll get warnings
|
|
||||||
about (at least) memcpy, isdigit, atoi, calloc, malloc and alloca if you
|
|
||||||
didn’t use -DAH.</li>
|
|
||||||
<li>GCC likes to complain about while (a = b) (assignments as a condition).</li>
|
|
||||||
<li>I don’t return from main, even though it’s declared to return int.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Platforms on which all known/tested optimization levels work with no additional
|
|
||||||
flags:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>gcc 4.6.2 + x86[_64] + GNU/Linux, Mac OS X or Windows</li>
|
|
||||||
<li>clang 2.9-16 + x86[_64] + GNU/Linux or Mac OS X</li>
|
|
||||||
<li>tcc 0.9.25</li>
|
|
||||||
<li>gcc 4.4.5 + alpha, arm, mips[el], powerpc[64], s390x (IBM zSeries)</li>
|
|
||||||
<li>gcc 4.1.3 + vax + NetBSD</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Platforms which work but not at all optimization levels or needing special
|
|
||||||
flags:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>owcc 1.9 + x86 + Windows: Needs -DNM -DAH -fno-stack-check</li>
|
|
||||||
<li>gcc 4.4.5 + sh4: -O0 works, higher optimization levels don’t work for unknown reasons.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,283 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best non-chess game</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best non-chess game</h1>
|
|
||||||
|
|
||||||
<p>Oscar Toledo G.<br>
|
|
||||||
Av. Sta. Cruz del Monte 9-304<br>
|
|
||||||
Cd. Satelite. Edo. de Mexico.<br>
|
|
||||||
CP. 53110. Mexico.<br>
|
|
||||||
<a href="mailto:biyubi@gmail.com">biyubi@gmail.com</a><br>
|
|
||||||
<a href="http://nanochess.110mb.com/">http://nanochess.110mb.com/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make toledo
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./toledo
|
|
||||||
|
|
||||||
# NOTE: This requires X11 to run or modifications to use layer.c on
|
|
||||||
# Windows
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./toledo
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This two player game uses X11. The control keys can be configured by
|
|
||||||
modifying the A,B,C and D macros at compilation.</p>
|
|
||||||
|
|
||||||
<p>After a quick splash screen the objective should be clear. There
|
|
||||||
are Red, Green and Cyan tanks. A larger window can be made by altering
|
|
||||||
the source early on, right before the code gets hard to follow.</p>
|
|
||||||
|
|
||||||
<p>Like Oscar’s previous winning X11 program for the 19th IOCCC, if
|
|
||||||
you remove both the X11 include files and replace them with</p>
|
|
||||||
|
|
||||||
<pre><code>#include "layer.c"
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>you ought to be able to compile and run this program on Windows.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<pre><code> /=========\
|
|
||||||
\==\ /==/ ||
|
|
||||||
|| || /====\ |\/=\ || //==\ ==\ |=\
|
|
||||||
|| || || || || || // || =| | |
|
|
||||||
|| || //===| || || ||=// \\=\\ ==/ |=/
|
|
||||||
|| || || || || || || \\ || User's
|
|
||||||
\===/ \\==// || || || \\ \==// Manual
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This is a color X11 3D tank-game for two players, just compile
|
|
||||||
and run it without arguments.</p>
|
|
||||||
|
|
||||||
<p>You will see briefly a tank spinning before each level.</p>
|
|
||||||
|
|
||||||
<p>Left half of the window shows the red player view and right
|
|
||||||
half shows the green player view, the background will change to
|
|
||||||
blue when the view goes inactive.</p>
|
|
||||||
|
|
||||||
<p>The objective is to chase and destroy the other player’s tank,
|
|
||||||
there is also an aqua tank for testing your aim and getting
|
|
||||||
extra points.</p>
|
|
||||||
|
|
||||||
<blockquote><p>Caveat: You can shoot only 3 bullets at a time.
|
|
||||||
Trick: You can fire faster if they explode on anything.
|
|
||||||
Believe it or not, it has strategy!</p></blockquote>
|
|
||||||
|
|
||||||
<p>When only one tank remains on the field, the level will advance.
|
|
||||||
Don’t forget to destroy the aqua tank.</p>
|
|
||||||
|
|
||||||
<p>The playground is surrounded by mountains and each level is
|
|
||||||
filled with random obstacles (pyramids and cubes).</p>
|
|
||||||
|
|
||||||
<p>The bars show players energy and score, each bar shows energy
|
|
||||||
and indicates current player view (wider on the left), right
|
|
||||||
part grows with every point.</p>
|
|
||||||
|
|
||||||
<p>Keys for player 1 (lowercase):</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Tab - Fire</li>
|
|
||||||
<li>w - Go ahead</li>
|
|
||||||
<li>s - Go backwards</li>
|
|
||||||
<li>a - Turn left</li>
|
|
||||||
<li>d - Turn right</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Keys for player 2:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Backspace - Fire</li>
|
|
||||||
<li>Up arrow - Go ahead</li>
|
|
||||||
<li>Down arrow - Go backwards</li>
|
|
||||||
<li>Left arrow - Turn left</li>
|
|
||||||
<li>Right arrow - Turn right</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<blockquote><p>Note: Numeric keys don’t work.</p></blockquote>
|
|
||||||
|
|
||||||
<p>If you don’t like the keys assignment, you can change it on the
|
|
||||||
the makefile.</p>
|
|
||||||
|
|
||||||
<h2>PARENTAL ADVISORY WARNING:</h2>
|
|
||||||
|
|
||||||
<p>This game is highly violent, when the tank explodes you can
|
|
||||||
see the little stick man blowing in parts.</p>
|
|
||||||
|
|
||||||
<p>Not really, just kidding :D</p>
|
|
||||||
|
|
||||||
<h2>PLATFORMS TESTED:</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>openSuSE 10.2 x86-32, X11R6 1024x768 32-bits color.</li>
|
|
||||||
<li>Fedora Core 8 x86-64, X11R6 1280x1024 32-bits color.</li>
|
|
||||||
<li>Fedora Core 11 x86-64, X11R6 1024x768 32-bits color.</li>
|
|
||||||
<li>Fedora Core 14 x86-64, X11R6 1024x768 32-bits color.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>COMPLETE FEATURE SET:</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Multiplayer out of the box.</li>
|
|
||||||
<li>Totally self-contained, no external files.</li>
|
|
||||||
<li>Fast-furious action at 29.97 frames per second.</li>
|
|
||||||
<li>Just as the movies, 16:9 aspect-ratio.</li>
|
|
||||||
<li>Beautiful mountains landscape plus horizon line :)</li>
|
|
||||||
<li>Tanks and bullets exploding as wires with weird physics.</li>
|
|
||||||
<li>Tanks backoff when firing.</li>
|
|
||||||
<li>There is an infinite number of levels.</li>
|
|
||||||
<li>Always different levels.</li>
|
|
||||||
<li>Animated intro.</li>
|
|
||||||
<li>It has color!.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>FEATURES THAT PROGRAMMERS WILL FIND APPEALING:</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Works both with x86-32 and x86-64 processors.</li>
|
|
||||||
<li>Double buffered, portable to any X11 with 24/32-bit color.</li>
|
|
||||||
<li>Memory-hungry as must be any 3-D program, uses a 256 MB
|
|
||||||
array.</li>
|
|
||||||
<li>Total and absolute irreverent coding style, so it generates
|
|
||||||
a lot of warnings when compiled.</li>
|
|
||||||
<li>It can take several minutes to compile (known culprits:
|
|
||||||
Fedora Core 11-14 on x86-64 512 MB)</li>
|
|
||||||
<li>It is written in the only true C: K&R, and no, it not means
|
|
||||||
Katherine & Rose.</li>
|
|
||||||
<li>Vectorial scalable graphics, do you want a bigger
|
|
||||||
playfield? change variables M & N.</li>
|
|
||||||
<li>Half of the program is formatted as 3-D cube, view with
|
|
||||||
Tabs at 8 columns and a square font.</li>
|
|
||||||
<li>The other half of the program is unprintable source code,
|
|
||||||
so no typing from paper, you have to write a converter of
|
|
||||||
tabs and formfeeds to its C escaped forms.</li>
|
|
||||||
<li>No text, so this program can be used and understood easily
|
|
||||||
on any country.</li>
|
|
||||||
<li>This program is highly ecologic, it sleeps when it is not
|
|
||||||
doing anything.</li>
|
|
||||||
<li>Virtual world with its own physics laws.</li>
|
|
||||||
<li>When closing the window it will show an X11 error :P</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>OBFUSCATION TRICKS:</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Loop code included inside loop test.</li>
|
|
||||||
<li>Function arguments used as variables.</li>
|
|
||||||
<li>Operators used freely.</li>
|
|
||||||
<li>Precalculated values to save bytes.</li>
|
|
||||||
<li><p>Uses the +++, +- and *+ undocumented C operators :P</p>
|
|
||||||
|
|
||||||
<pre><code> ....,,,,---++++++--,,..
|
|
||||||
.,,,....... .$@@@@@@@@@@@@$$@@@@@@@@@@@@@@#+
|
|
||||||
@@@@@###@@@@$$$@@@@$$$@@@-......-@+......,,,,,,##
|
|
||||||
=++==++++++++=@@$==#$$$$$---,,,,@@@,,,,,,-------@@,..........,,.
|
|
||||||
,===#$$$$$$###$####=======@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+=##$@@@@@@@@.
|
|
||||||
+@,,++++++++=+=========++++===++++++++++-+++@@-,,,,,,,,---+++=++++--,,... @.
|
|
||||||
.@. .......,,,,-----++=@=++==@$=+--,,... @.
|
|
||||||
$# S P O I L E R .,,-#@--,,,@$..... @.
|
|
||||||
.@ ..,--+==++-,,,,.,,,,=@+++++====+++++---,,,....@.
|
|
||||||
@+ ..,,-+++++++-,,.. @. ....,,,,,---+@@
|
|
||||||
,@ ..,--+++=+++,,.. $# .==+
|
|
||||||
@#--++==++-,,.. ,@ S P O I L E R .==+
|
|
||||||
,#@@$+,,. @. ==+
|
|
||||||
.,,+++++,,. S P O I L E R $= +=+
|
|
||||||
..,-==++-,. ,@ ---
|
|
||||||
.,-+=+++,.. @. .++-
|
|
||||||
.,,++=++-,. @+ ==+
|
|
||||||
.,-++==+-,. +@ ==+
|
|
||||||
..,+++=+-,.. .@. +=+
|
|
||||||
.,-+++++,@@==
|
|
||||||
</code></pre></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>THE HISTORY OF THIS PROGRAM:</h1>
|
|
||||||
|
|
||||||
<p>When I started working on this program, I figured that it would
|
|
||||||
be easy to fit on the character limit, but I missed three
|
|
||||||
things, the enormous X11 names, the unportable keycodes and my
|
|
||||||
2 KB of artwork.</p>
|
|
||||||
|
|
||||||
<p>Very hard coding did the first thing, in fact I worked out
|
|
||||||
twenty-nine different versions, at one step I had four
|
|
||||||
parallel versions with different characteristics removed
|
|
||||||
(mountains, horizon line, score/status bars and explosions),
|
|
||||||
I’ve managed to fit it all together!.</p>
|
|
||||||
|
|
||||||
<p>The second thing was solved using the makefile, it is under
|
|
||||||
160 bytes and you get adjustable keyboard. The greatest
|
|
||||||
mistery on the earth is why X11 handles unportable keycodes to
|
|
||||||
the user.</p>
|
|
||||||
|
|
||||||
<p>And finally, the third “Thing” was growing and growing, and
|
|
||||||
growing, eating bytes for lunch… after endless rounds of
|
|
||||||
crunching I obtained three-hundred seventy-eight bytes of
|
|
||||||
artwork and guess what?, it doesn’t fitted.</p>
|
|
||||||
|
|
||||||
<p>So I had to integrate a decompressor, based on the space,
|
|
||||||
tabulators and other non-counted characters.</p>
|
|
||||||
|
|
||||||
<p>The final program is composed of eight microfunctions, one is
|
|
||||||
the core and does most of the hard work, other functions help
|
|
||||||
doing the X11 things, explosion effects, 3-D calculations and
|
|
||||||
viewing.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>K() - 3-D transformation</li>
|
|
||||||
<li>s() - Rendering</li>
|
|
||||||
<li>b() - Line color selection</li>
|
|
||||||
<li>G() - Explosion animation</li>
|
|
||||||
<li>g() - Moves 3-D object backward and forward</li>
|
|
||||||
<li>F() - Collision detection</li>
|
|
||||||
<li>T() - Core (also known as main loop :D)</li>
|
|
||||||
<li>main() - Initialization and uncruncher, what a common name!,
|
|
||||||
C programs should start in the cool() function :).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The source code was formatted as an cube using a specially
|
|
||||||
written program, the reality is that the program is smaller and
|
|
||||||
obfuscated of what is needed so the reformatting doesn’t
|
|
||||||
exceeded the character limits, the crunched vectors were
|
|
||||||
generated by another special program and the tank that
|
|
||||||
surrounds this text was generated by yet another program.</p>
|
|
||||||
|
|
||||||
<p><em>Have fun!</em></p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most sound</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most sound</h1>
|
|
||||||
|
|
||||||
<p>Daniel Vik<br>
|
|
||||||
802 Durshire Way<br>
|
|
||||||
Sunnyvale, Ca 94087<br>
|
|
||||||
<a href="mailto:daniel@vik.cc">daniel@vik.cc</a><br>
|
|
||||||
<a href="http://www.danielvik.com">http://www.danielvik.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make vik
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./vik file.mod > audio_file.raw
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./vik randowan.mod | mplayer -demuxer rawaudio -
|
|
||||||
./vik mad_world.mod | mplayer -demuxer rawaudio -
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Alternatively, you can use</p>
|
|
||||||
|
|
||||||
<pre><code>./vik file.mod > file.raw; ./raw2wav file.raw > file.wav
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>It is possible to download a number of Mod files from <a href="http://modarchive.org">The Mod Archive</a>.</p>
|
|
||||||
|
|
||||||
<p>The randowan.mod and mad_world.mod files were created by
|
|
||||||
<a href="http://www.translucentboy.com">Henrik Bertilsson</a> and
|
|
||||||
are included with his permission.</p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This entry converts .MOD audio files to a playable stream
|
|
||||||
in a most pleasing manner if you don’t like tremolo or vibrato.</p>
|
|
||||||
|
|
||||||
<p>Also it abuses the C compiler and/or assembler with a partially
|
|
||||||
initialized 32 MByte array. Can you tell what is that partial
|
|
||||||
initilzation for?</p>
|
|
||||||
|
|
||||||
<p>Does it take your system a long time to compile? You may want to do try:</p>
|
|
||||||
|
|
||||||
<pre><code> cc -S vik.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>and to examine the resulting assembly file vik.s. On some platforms
|
|
||||||
the assembly file is about 128 MBytes in size!</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Introduction</h1>
|
|
||||||
|
|
||||||
<p>In 1987, Karsten Obarski changed the way music was handled in games and
|
|
||||||
demos with the introducton of the MOD file format on Commodore Amiga.</p>
|
|
||||||
|
|
||||||
<p>A MOD file contains a set of samples, a number of patterns indicating
|
|
||||||
how and when the samples are to be played, a list of what patterns to
|
|
||||||
play in what order, and a number of effects.</p>
|
|
||||||
|
|
||||||
<h1>Features</h1>
|
|
||||||
|
|
||||||
<p>This program converts MOD files created with the standard trackers for
|
|
||||||
Amiga, e.g. Pro Tracker, Noise Tracker and Sound Tracker to raw 16 bit
|
|
||||||
44.1kHz stereo audio. The program supports MOD music with 4, 6, and 8
|
|
||||||
channels MOD files with up to 31 samples.</p>
|
|
||||||
|
|
||||||
<p>The MOD format includes many effects for each audio channel and this
|
|
||||||
program supports most of them, including:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Arpeggio</li>
|
|
||||||
<li>Slide and fine slide up/down/to note</li>
|
|
||||||
<li>Set sample offset</li>
|
|
||||||
<li>Volume slide</li>
|
|
||||||
<li>Pattern break</li>
|
|
||||||
<li>Filter on/off</li>
|
|
||||||
<li>Set volume</li>
|
|
||||||
<li>Cut sample</li>
|
|
||||||
<li>Delay sample</li>
|
|
||||||
<li>Delay pattern</li>
|
|
||||||
<li>Set speed</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Due to size constraints tremolo and vibrato is not supported. Also, to
|
|
||||||
avoid infinite long songs, the position jump feature is ignored.</p>
|
|
||||||
|
|
||||||
<h1>Songs</h1>
|
|
||||||
|
|
||||||
<p>With his permission, the package incldues two songs composed by Henrik
|
|
||||||
Bertilsson, also known as Deelite:</p>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li> Mad World</li>
|
|
||||||
<li> Randowan</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Build</h1>
|
|
||||||
|
|
||||||
<p>Compiling for *nix systems (including cygwin) is straight forward:</p>
|
|
||||||
|
|
||||||
<pre><code>$ gcc -o vik vik.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>Usage</h1>
|
|
||||||
|
|
||||||
<h3>Convert MOD file to raw 44.1kHz stereo audio file</h3>
|
|
||||||
|
|
||||||
<pre><code>$ ./vik mad_world.mod > audio_file.raw
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Listen to the MOD file (streaming to mplayer)</h3>
|
|
||||||
|
|
||||||
<pre><code>$ ./vik randowan.mod | mplayer -demuxer rawaudio -
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>(Don’t forget the last ‘-’ as it makes mplayer read from stdin.)</p>
|
|
||||||
|
|
||||||
<h1>Obfuscation</h1>
|
|
||||||
|
|
||||||
<p>The IOCCC rules did not put a limit on the entropy of the source code,
|
|
||||||
and it appears that the general entropy rules doesn’t apply. An estimate
|
|
||||||
is that the code density entropy of this entry is ~1.2 which means that
|
|
||||||
there are around 2500 characters of code carrying information, yet there
|
|
||||||
are only 2037 IOCCC characters of actual code. Most of the additional
|
|
||||||
characters are encoded with non-counting characters in the frequency
|
|
||||||
table. But there are also ~50 or so white space characters spread out
|
|
||||||
through the source code that carry information.</p>
|
|
||||||
|
|
||||||
<p>The use of macros certainly adds to the obfuscation but the reason for
|
|
||||||
using them is mainly to fit as many features as possible within the size
|
|
||||||
limits. So please excuse the use of them.</p>
|
|
||||||
|
|
||||||
<p>Once the preprocessor is run, the code gets more interesting. The MOD
|
|
||||||
player is basically a register based state machine and all the magic is
|
|
||||||
hidden in a fog of short statements. Many of the register updates are
|
|
||||||
conditional and the program uses the ? operator (sigh) mainly to save
|
|
||||||
space, but also to leverage the comma operator and precedence more
|
|
||||||
efficiently.</p>
|
|
||||||
|
|
||||||
<h1>Portability</h1>
|
|
||||||
|
|
||||||
<p>The progam is portable to most platforms. The only system dependency is
|
|
||||||
that the program relies on writing binary data to stdout.</p>
|
|
||||||
|
|
||||||
<p>Microsoft compilers adds a carriges return to newlines, and to compile
|
|
||||||
the program with this platform, the following line can be added after
|
|
||||||
the main declaration in order for the program to run correctly:</p>
|
|
||||||
|
|
||||||
<pre><code>_setmode(_fileno(stdout), 0x8000);
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>Limitations</h1>
|
|
||||||
|
|
||||||
<p>The program only runs when a valid MOD file is passed as argument. If
|
|
||||||
no argument is passed, the program crashes.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.3 DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most shiny</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most shiny</h1>
|
|
||||||
|
|
||||||
<p>Matt Zucker<br>
|
|
||||||
<a href="mailto:mzucker1@swarthmore.edu">mzucker1@swarthmore.edu</a><br>
|
|
||||||
<a href="http://www.swarthmore.edu/NatSci/mzucker1/">http://www.swarthmore.edu/NatSci/mzucker1/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make zucker
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./zucker > image.ppm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./zucker "Hello!!!" > hello.ppm
|
|
||||||
./zucker faster\! -preview > image2.ppm
|
|
||||||
|
|
||||||
# Display the PPM image with your favorite image viewer
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>The rendered image is centered and is output as a 600 by 220 pixel PPM.
|
|
||||||
The vector font is proportional.</p>
|
|
||||||
|
|
||||||
<p>This entry uses no local variables. None! At! All!</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>An image generator</h1>
|
|
||||||
|
|
||||||
<h2>What it does:</h2>
|
|
||||||
|
|
||||||
<p>This program makes pretty pictures. To see the default output, try
|
|
||||||
running</p>
|
|
||||||
|
|
||||||
<pre><code> ./zucker > image.ppm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>On the author’s 2.5 GHz MacBook Pro, this command takes approximately
|
|
||||||
1 minute and 18 seconds to run – your runtime may vary. You will
|
|
||||||
need an image viewer capable of displaying Netpbm images in order to
|
|
||||||
display the output. On the Mac, <a href="http://wakaba.c3.cx/s/apps/xee">Xee</a>
|
|
||||||
works well; otherwise <a href="http://www.imagemagick.org/">ImageMagick</a>
|
|
||||||
and/or <a href="http://www.graphicsmagick.org/">GraphicsMagick</a> are both
|
|
||||||
capable of displaying Netpbm files, and are available on multiple
|
|
||||||
platforms. (Using Xee is particularly nice because it periodically
|
|
||||||
reloads the image as it is rendered.)</p>
|
|
||||||
|
|
||||||
<p>Aside from the default image, you may create your own by running the
|
|
||||||
program as follows:</p>
|
|
||||||
|
|
||||||
<pre><code> ./zucker "your text" > image.ppm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>To mitigate long runtimes, the program can be invoked in a “preview”
|
|
||||||
mode by appending <code>-preview</code> to the command line arguments, like so:</p>
|
|
||||||
|
|
||||||
<pre><code> ./zucker faster\! -preview > image.ppm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>If your platform distinguishes between binary and text streams, you
|
|
||||||
may need to insert some code to reopen standard output in binary mode
|
|
||||||
at the start of <code>main</code>. An ASCII platform is assumed.</p>
|
|
||||||
|
|
||||||
<h2>Pedagogical value:</h2>
|
|
||||||
|
|
||||||
<p>This program is quite suitable for the inexperienced programmer, due
|
|
||||||
to a number of considerations:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>It is fairly short: just 4 preprocessor directives followed by 29
|
|
||||||
lines of source.</p></li>
|
|
||||||
<li><p>It compiles cleanly as ANSI C under gcc 4.2.1 with very strict
|
|
||||||
compilation flags.</p></li>
|
|
||||||
<li><p>It uses a very small subset of the keywords available in C, namely
|
|
||||||
<code>char</code>, <code>float</code>, <code>int</code>, <code>typedef</code>, <code>struct</code>, <code>for</code>, and <code>return</code>.
|
|
||||||
More difficult concepts such as <code>void</code>, <code>if</code>, <code>switch</code>, and
|
|
||||||
<code>while</code> are eschewed for simplicity’s sake.</p></li>
|
|
||||||
<li><p>It also uses a very small number of library functions: just <code>putchar</code>,
|
|
||||||
<code>cos</code>, <code>sin</code>, <code>atan2</code>, <code>sqrt</code>, and <code>pow</code>.</p></li>
|
|
||||||
<li><p>New programmers often prefer to use global variables when
|
|
||||||
possible. Hence, <em>all</em> variables in this program (aside from
|
|
||||||
function parameters) have global scope.</p></li>
|
|
||||||
<li><p>An important aspect of the computation is graphically illustrated
|
|
||||||
by the source code itself: the geometric construction of a
|
|
||||||
reflection ray at an object’s surface, given the incoming
|
|
||||||
direction and surface normal.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Further details (contains spoilers):</h2>
|
|
||||||
|
|
||||||
<p>The program is not quite a traditional ray tracer, but a “sphere
|
|
||||||
tracer” which uses distance fields to encode proximity to objects in
|
|
||||||
the scene. Using sphere tracing to compute visibility instead of
|
|
||||||
analytic ray tracing provides two advantages: first, it greatly eases
|
|
||||||
the computation of ray-torus intersection (which would otherwise
|
|
||||||
require solving a quartic polynomial), and second, it makes it
|
|
||||||
possible to compute ambient occlusion (which is used to generate soft
|
|
||||||
shadows). Unlike many traditional ray tracers and sphere tracers, this
|
|
||||||
one uses iteration instead of recursion to compute the effect of
|
|
||||||
reflections. This, unfortunately, resulted in the programmer going
|
|
||||||
insane; however, program size was reduced and readability
|
|
||||||
hindered. Neither the plaintext for the program’s default output nor
|
|
||||||
for the Netpbm header appears in the program source, which hinders
|
|
||||||
readability as well. Also, unlike some previous IOCCC entries which
|
|
||||||
render ASCII text, this one uses a vector (as opposed to raster)
|
|
||||||
font. Although the program does not generate uppercase letters, it
|
|
||||||
handles them in a reasonable manner when they appear in the input.</p>
|
|
||||||
|
|
||||||
<p>Even when the program is pretty-printed and preprocessor macros are
|
|
||||||
expanded, it should be fairly resistant to analysis due to reckless
|
|
||||||
reuse of global variables, to the inherently opaque nature of the
|
|
||||||
math, and to its overall density. Global variables are used to store
|
|
||||||
the results of intermediate computation. As a result, seemingly simple
|
|
||||||
functions have important side effects. Although some of the global
|
|
||||||
variables are simply constants, their use is overloaded. For instance,
|
|
||||||
the variable <code>X</code> is used both as the number 40 and as the ASCII
|
|
||||||
character <code>'('</code>. Maintainability is hindered due to hardcoding
|
|
||||||
several aspects of the program in multiple locations. As an example,
|
|
||||||
it is impossible to modify either the image width or height without
|
|
||||||
changing the source in at least three different places, including
|
|
||||||
inside the large string literal.</p>
|
|
||||||
|
|
||||||
<p>Some of the functions are simple vector algebra operations such as
|
|
||||||
vector construction, dot product, and normalization. However, it was
|
|
||||||
found to be much more compact to define a single operation for
|
|
||||||
multiply-and-add rather than to have separate functions for addition,
|
|
||||||
subtraction, and scaling. Again, compactness led to obfuscation.</p>
|
|
||||||
|
|
||||||
<p>This program heavily abuses <code>for</code> loops. The comma operator is used to
|
|
||||||
get as much milage as possible out of statements inside of loop
|
|
||||||
declarations. Between <code>for</code> loops, the comma operator, and the ternary
|
|
||||||
operator, it was possible to avoid <code>if</code> and <code>while</code> altogether.</p>
|
|
||||||
|
|
||||||
<p>Bitwise and arithmetic operators are used instead of logical operators
|
|
||||||
whenever gcc doesn’t warn about it. Conversely, integer
|
|
||||||
multiplication, division, and modulus are sometimes used in place of
|
|
||||||
traditional bitwise operators just to keep the reader on his or her
|
|
||||||
toes. Automatic casting between characters, integers, and floats is
|
|
||||||
performed just about everywhere. Fascinatingly, this doesn’t seem to
|
|
||||||
affect performance too badly. Sometimes when an explicit cast
|
|
||||||
(i.e. from float to int) is needed, the program instead simply assigns
|
|
||||||
to a free variable of the desired type instead. Both the <code>array[index]</code>
|
|
||||||
and <code>index[array]</code> notations are used interchangably throughout the
|
|
||||||
program.</p>
|
|
||||||
|
|
||||||
<p>Two other programs were written to support development of this
|
|
||||||
program. The first used a randomized search algorithm to deduce the
|
|
||||||
most compact encoding of the vector font instructions into ASCII; the
|
|
||||||
second used a modified form of the Knuth-Plass algorithm to layout the
|
|
||||||
final text on top of a hand-generated ASCII “stencil”. The programs
|
|
||||||
were not submitted as entries for this year’s IOCCC, not because they
|
|
||||||
lack obfuscation, but because neither is written in C (they are in C++
|
|
||||||
and Python, respectively).</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2012,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most GIFted expressions</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most GIFted expressions</h1>
|
|
||||||
|
|
||||||
<p>Philip Blakely<br>
|
|
||||||
Cambridge, UK<br>
|
|
||||||
<a href="mailto:pmblakely@gmail.com">pmblakely@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make blakely
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./blakely "RPN formula" resolution > output.gif
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./blakely "xx*yy*+" 64 > paraboloid.gif
|
|
||||||
|
|
||||||
./blakely 9 32 > empty.gif
|
|
||||||
|
|
||||||
time ./blakely 0 250 > flat.gif
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Several IOCCC themes (RPN calculator, animated GIF generator, ray tracing) in one package! Very impressive!</p>
|
|
||||||
|
|
||||||
<p>The checkerboard pattern in the output can be broken. Could you figure out how?</p>
|
|
||||||
|
|
||||||
<p>Larger GIF files confuse some image viewers.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>Remarks</h2>
|
|
||||||
|
|
||||||
<p>This program renders a generic RPN expression in ray-traced animated GIF form.
|
|
||||||
The expression in spatial variables x and y is specified on the command-line with the required resolution,
|
|
||||||
and an animated GIF showing a fly-around of the resulting surface is output to stdout.</p>
|
|
||||||
|
|
||||||
<h2>Usage</h2>
|
|
||||||
|
|
||||||
<p>The program should be run as:</p>
|
|
||||||
|
|
||||||
<pre><code>./blakely xy* 32 > pic.gif
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>where the first parameter is a RPN expression, and the second is the width of the required GIF, up to a maximum of 250.</p>
|
|
||||||
|
|
||||||
<p>The expressions are written in Reverse Polish Notation with the following characters recognised:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>+,-,*,/ - usual arithmetic operations</li>
|
|
||||||
<li>^ - Exponentiation - valid for constant exponent only</li>
|
|
||||||
<li>s - sin</li>
|
|
||||||
<li>c - cos</li>
|
|
||||||
<li>0-9 - single digit integers</li>
|
|
||||||
<li>d - duplicate number on stack</li>
|
|
||||||
<li>t - transpose top two elements on stack</li>
|
|
||||||
<li>x - x coordinate value</li>
|
|
||||||
<li>y - y coordinate value</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>NB all arithmetic is done in double precision, so 23/ is two-thirds, rather than 0</p>
|
|
||||||
|
|
||||||
<p>The surface plotted corresponds to -1 <= x,y <= 1 and for best results, the generated z value should lie between -1 and 1.</p>
|
|
||||||
|
|
||||||
<p>If there is a division by zero, square-root of a negative number, or similar operation, then the results are undefined.</p>
|
|
||||||
|
|
||||||
<h2>Examples</h2>
|
|
||||||
|
|
||||||
<p>For test-runs, use a resolution of 32. For simple expressions, the GIF generation should take only
|
|
||||||
a few seconds with a modern processor and full optimization. Run-time scales as O(N<sup>3</sup>) with resolution N,
|
|
||||||
and more complex expressions take longer to compute. For example, increasing the resolution of ripple.gif
|
|
||||||
to 250 took ~35 minutes to render on an i7 processor.</p>
|
|
||||||
|
|
||||||
<pre><code>./blakely xy* 32 > saddle.gif
|
|
||||||
|
|
||||||
./blakely xx*yy*1++d5*ct/ 64 > ripple.gif
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Algorithm</h2>
|
|
||||||
|
|
||||||
<p>A generic root-finding algorithm to find the point of intersection between a ray
|
|
||||||
and the surface is done using a simple forward search from the eye.
|
|
||||||
In order to make the rendering realistic, both the value of the expression, and its derivative with respect to x and y must be tracked.
|
|
||||||
This is done using an obvious stack-based approach.</p>
|
|
||||||
|
|
||||||
<h2>Obfuscations</h2>
|
|
||||||
|
|
||||||
<p>Much of the obfuscation is achieved through the use of single-letter variables and #defines.
|
|
||||||
The characters output for the GIF format are generated in myriad and wonderful ways, making use
|
|
||||||
of XOR, return values from putchar, and odd expressions.
|
|
||||||
The layout is in the form of X Y Z.</p>
|
|
||||||
|
|
||||||
<h2>Limitations</h2>
|
|
||||||
|
|
||||||
<p>ASCII is assumed since many bytes for the GIF output are generated from characters given in the source code.
|
|
||||||
On compilation a few warnings about parentheses come up when using gcc 4.6.3, and one about no return value from main() (who uses exit codes anyway?),
|
|
||||||
but clang 3.1 emits no warnings.</p>
|
|
||||||
|
|
||||||
<h2>Questions</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Apart from their appearance when computing the RPN expression, sin and cos are not used.
|
|
||||||
How do we then get the correct angles for rotation?</li>
|
|
||||||
<li>Exactly how many times will the animation repeat?</li>
|
|
||||||
<li>Why is there an upper limit of 250x250 for the resolution?</li>
|
|
||||||
<li>What is the point of b[0]?</li>
|
|
||||||
<li>Where are the words NETSCAPE and GIF hidden in the source?</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>(Note that the author may or may not be able to answer all of the above questions.)</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most notable and best tool</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most notable and best tool</h1>
|
|
||||||
|
|
||||||
<p>Alex Deckmyn<br>
|
|
||||||
<a href="mailto:alex.deckmyn@gmail.com">alex.deckmyn@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make deckmyn
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code># A shell interpreter with proper backtick interpolation is required
|
|
||||||
./deckmyn "`cat deckmyn.c`" "`cat musicfile.txt`" > sheetmusic.pbm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>The C of this entry is definitely sharp. The program cleverly uses its own
|
|
||||||
source at runtime to define the notes, time signature and accidental bitmaps.</p>
|
|
||||||
|
|
||||||
<p>In addition to sheet music, this program is also able, given the right input,
|
|
||||||
to generate an image of a 10-pin DIP chip (a sound processor?).</p>
|
|
||||||
|
|
||||||
<p>Ironically, the way this entry is called from the command line is an abuse of C Shell.
|
|
||||||
Please use Bourne-family shells to run this entry.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Example use</h1>
|
|
||||||
|
|
||||||
<p>You need the source code and example input (either one of the example files, or manual input as below) ready. And a program capable of showing .pbm bitmap format.</p>
|
|
||||||
|
|
||||||
<pre><code>./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
|
||||||
display greensleeves.pbm
|
|
||||||
|
|
||||||
./deckmyn "`cat deckmyn.c`" "KF m44c4 c4 g4 g4 : a4 a4 g2 :; " > short_bass.pbm
|
|
||||||
display short_bass.pbm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>Description</h1>
|
|
||||||
|
|
||||||
<p>Every major C competition should have an entry capable of producing C major.
|
|
||||||
This is a music notation program. It produces bitmaps (.pbm) of music based on ASCII input. A full manual is added as a separate file. Some musical examples are also included.</p>
|
|
||||||
|
|
||||||
<p>The program is capable of printing notes, rests, (double) bar lines and accidentals on a single melodic line (multiple staves). No chords, polyphony etc.</p>
|
|
||||||
|
|
||||||
<p>The program expects <em>two command line arguments</em>. The first is a (very long) string that contains the complete music font. Note that it should <em>not</em> be given as a file name! The default music font is encoded in the (whitespace of the) source code deckmyn.c itself. Therefore, the first argument should be “<code>cat deckmyn.c</code>”.</p>
|
|
||||||
|
|
||||||
<p>The second command line argument is the music itself. This is, again, a string, not a file name. All music signs are entered as tokens of exactly 3 characters. The code is very sensitive to bad spacing! So for instance, if you use a file to write the music (e.g. example_greensleeves), you should keep in mind that newline is also a character!</p>
|
|
||||||
|
|
||||||
<h1>Internals</h1>
|
|
||||||
|
|
||||||
<p>To minimise the memory footprint, this program has <em>no variable declarations at all</em>, except for the arguments to main(). The only available memory space is from the command line arguments and count (argv and argc). Parts of argv are cast as integer when values under 0 or beyond 127 are expected.</p>
|
|
||||||
|
|
||||||
<p>The “music font” is defined by the source code itself. The first few lines are not part of the font definition, as this memory space will modified by the program. (So as required by the rules, it is only a (memory) copy of the source code that is modified.)</p>
|
|
||||||
|
|
||||||
<p>As there is no memory available, output is directly to stdout, byte by byte, from the top left to the bottom right pixel.</p>
|
|
||||||
|
|
||||||
<h1>LIMITATIONS</h1>
|
|
||||||
|
|
||||||
<p>The memory locations of argv are used for various purposes. Therefore, the program name (default “deckmyn”) must be <em>at least 4 characters long</em>, including possibly the path. This, along with the ending ‘\0’, gives minimum 5 bytes of useful memory space. Otherwise, the program may attempt to write outside the string.</p>
|
|
||||||
|
|
||||||
<p>The code is quite sensitive. Errors in the input can lead to strange results. The code does not read beyond the end of the music input, but that is about the only error checking available. Any input that is not according to the rules in the MANUAL, may cause errors.</p>
|
|
||||||
|
|
||||||
<p>The program has no special hardware limitations or requirements, other than 8bit char (signed or unsigned) and two’s complement negatives.</p>
|
|
||||||
|
|
||||||
<p>The limitations of using char as counters for e.g. the number of music staves are minor. 127 staves to a page is rather a lot.</p>
|
|
||||||
|
|
||||||
<h1>Obfuscations</h1>
|
|
||||||
|
|
||||||
<p>The code has no declared variables other than the command line variables. Not even pointers (we all know how messy code can get with too many pointers!). As more than one variable needs values beyond 127, parts of the command line memory are cast as integer using a macro.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The formatting of the code is in fact necessary, as this is the definition of the music font. It is therefore not an obfuscation.</li>
|
|
||||||
<li>The use of only argv/argc as memory locations is a matter of reducing the memory footprint. Again, it is not an obfuscation.</li>
|
|
||||||
<li>Calling the only remaining variables, and the two defined macros, c and C, is merely a matter of conforming to the standard WYSIWYG paradigm common in commercial notation programs (What You C is What You Get). So once again it is not an obfuscation. Anyway, it’s a C coding contest, right?</li>
|
|
||||||
<li>Randomly using the numerical (ASCII) value for characters is compensated for by replacing some numbers by a character representation. On average, therefore, it is not an obfuscation.</li>
|
|
||||||
<li>Randomly changing the way the elements of argv are addressed is a matter of maintaining a diversified code base. It is therefore not… Oh allright.</li>
|
|
||||||
<li>The actual output of the music is done by one print command including a 800+ character nested conditional expression.</li>
|
|
||||||
<li>printf is also used for its return value.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best way to lose a life</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best way to lose a life</h1>
|
|
||||||
|
|
||||||
<ol type="a">
|
|
||||||
<li>David Lowe<br>
|
|
||||||
434 Tenney Drive<br>
|
|
||||||
Rogue River, OR<br>
|
|
||||||
97537<br>
|
|
||||||
<a href="mailto:j.david.lowe@gmail.com">j.david.lowe@gmail.com</a><br>
|
|
||||||
<a href="http://www.pootpoot.net/">http://www.pootpoot.net/</a></li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make dlowe
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./dlowe
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./dlowe
|
|
||||||
# Watch for a while if you like, then press a key within the window
|
|
||||||
# Use up and down keys to escape death
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>The judges lose playing this game. This entry wins!</p>
|
|
||||||
|
|
||||||
<p>OS X users running Mountain Lion and later will need to download and install:</p>
|
|
||||||
|
|
||||||
<pre><code>http://xquartz.macosforge.org/landing/
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Q: How did we get past the variadic macro problem on a Mac?</p>
|
|
||||||
|
|
||||||
<p>A: Don’t use -pedantic-errors in the Makefile.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Conway’s Game of DEATH</h1>
|
|
||||||
|
|
||||||
<p>This is a challenging, fast-paced arcade game, based on the famous Game of
|
|
||||||
Life.</p>
|
|
||||||
|
|
||||||
<h2>Story</h2>
|
|
||||||
|
|
||||||
<p>In the game, you are Mr.C, a lightweight spaceship making a futile dash for
|
|
||||||
escape from the rigid rules and predictability of life in the B3/S23 universe.</p>
|
|
||||||
|
|
||||||
<p>Use the up and down arrow keys to steer: collisions are fatal for Mr.C! Learn
|
|
||||||
to spot incoming gliders, skim the surfaces of beehives and blocks, and give
|
|
||||||
blinkers plenty of space. Things get crazier as Mr.C picks up speed… can he
|
|
||||||
escape?</p>
|
|
||||||
|
|
||||||
<p>No. There is no winning. Sadly for Mr.C, this universe goes on forever. Just
|
|
||||||
see how far you can make it!</p>
|
|
||||||
|
|
||||||
<p>Press ‘q’ any time to quit.</p>
|
|
||||||
|
|
||||||
<h2>Features</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>casual gameplay</li>
|
|
||||||
<li>infinite, procedurally generated universe</li>
|
|
||||||
<li>progressive difficulty</li>
|
|
||||||
<li>animated splash screens</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Limitations</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Flicker, especially at high speeds, and in spite of “double-buffering” (X11
|
|
||||||
doesn’t make it possible to lock drawing to the display refresh rate.)</li>
|
|
||||||
<li>Cannot be run outside of the directory containing the data files (splash.d,
|
|
||||||
dead.d and sprites.d).</li>
|
|
||||||
<li>Cannot build or run without X11 (or an X11 compatibility layer).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Wish List</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Score keeping</li>
|
|
||||||
<li>Color</li>
|
|
||||||
<li>In-game instructions</li>
|
|
||||||
<li>Sound</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Hosts Tested</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Darwin 10.8.0 i386 (clang 1.6 and gcc 4.2.1)</li>
|
|
||||||
<li>Linux 2.6.32 i686 (clang 1.1 and gcc 4.4.3)</li>
|
|
||||||
<li>Linux 3.2.0 x86_64 (clang 3.0 and gcc 4.6.3)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Obfuscations</h2>
|
|
||||||
|
|
||||||
<p>The code is formatted into a 14-cell shape which will evolve into a glider in
|
|
||||||
19 generations.</p>
|
|
||||||
|
|
||||||
<p>Lots of globals, including a global struct whose members have the same names
|
|
||||||
as global variables.</p>
|
|
||||||
|
|
||||||
<p>Global variables getting reused in different contexts.</p>
|
|
||||||
|
|
||||||
<p>Huge and convoluted expressions, abusing ternary operators and operator
|
|
||||||
precedence.</p>
|
|
||||||
|
|
||||||
<p>Lots of magic numbers, abuse of the relationships between magic numbers, and
|
|
||||||
abuse of the arithmetic properties of magic numbers.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,203 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most complex ASCII fluid - Honorable mention</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most complex ASCII fluid - Honorable mention</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make endoh1
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./endoh1 < configuration.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./endoh1 < endoh1.c
|
|
||||||
|
|
||||||
./endoh1 < pour-out.txt
|
|
||||||
|
|
||||||
./endoh1 < fountain.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Let’s play Jeopardy!</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>A: An obfuscated program that deals with complex numbers and produces animated ASCII graphics.</li>
|
|
||||||
<li>Q: What is a Mandelbrot simulator?</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Bzzzt!</p>
|
|
||||||
|
|
||||||
<p>Such heavily squeezed fluid simulation (this is parsed uniquely
|
|
||||||
as fluids are not squeezable) has a few quirks that the judges were
|
|
||||||
happy to experiment with.</p>
|
|
||||||
|
|
||||||
<p>One configuration file was inspired by an <a href="http://whatif.xkcd.com/6/">XKCD what if? entry</a>.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Synopsis</h3>
|
|
||||||
|
|
||||||
<p><strong>DO NOT FORGET “-DG=1 -DP=4 -DV=8”</strong> and make your terminal window larger
|
|
||||||
than 80 x 25.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm
|
|
||||||
./endoh1 < endoh1.c
|
|
||||||
./endoh1 < logo.txt
|
|
||||||
./endoh1 < column.txt
|
|
||||||
./endoh1 < pour-out.txt
|
|
||||||
./endoh1 < tanada.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>What it is</h3>
|
|
||||||
|
|
||||||
<pre><code>,___. ,. ,. ,. ,___. ,. ,. ,.
|
|
||||||
|/--' || `' || |/--' `' || |\_.
|
|
||||||
|\__. || ,. ,. ,. ,__/| |\__. ,. ,____. ,. ,. || ,_. |/-' ,_. ,__.
|
|
||||||
|/--' || || || || |/-\| `--\| || |/\/\| || || || ,/-\. || ,/-\. |/-\.
|
|
||||||
|| || `\_/| || |\_/| ,__/| || |||||| `\_/| || `\_/\.`\_. `\_/' || `'
|
|
||||||
`' `' `--' `' `---' `---' `' `'`'`' `--' `' `-'`' `-' `-' `'
|
|
||||||
|
|
||||||
|
|
||||||
,.,. ,.,.
|
|
||||||
,/\/\. ,. ,. ,. ,/\/\. ,. ,. ,__.
|
|
||||||
|||#/' || `' ,_.|| |||#/' `',_.,__. || ||\\. ,.
|
|
||||||
|||#\. || ,. ,. ,.,/#||| |\//\. ,.|#||##| ,. ,. || ,.,. |\/-' ,.,. ,.|\.
|
|
||||||
|\/--' ||,/\.|| |||#/\/| `\#||| |||#||/\|,/\.|| ||,/'`\.|#| ,/'`\.|\/-\.
|
|
||||||
`\| ||`\#||| |||#||\| ,//\/| ||`\|||||`\#||| ||`\.,/\/\|,.`\.,/'`\| `'
|
|
||||||
`' `' `-'`' `'`-'`-' `-'`-' `' `'`'`' `-'`' `' `'`--'`'`' `'`' `'
|
|
||||||
|
|
||||||
|
|
||||||
,_.,_. ,. ,. ,. ,_.,_. ,. ,. ,.
|
|
||||||
|#||#| || `' || |#||#| `' || ||,_.
|
|
||||||
||\/#| ||,. ,. ,.,_.,/| |\||#| ,.,_.,__.,. ,. || ,.,. |||#| ,.,. ,.,_.
|
|
||||||
|||##| |||| || |||#||#| |#||#| |||#||##||| || ||,/||\.||`-',/||\.|||#\.
|
|
||||||
||`--' ||`\_.|| |||\||#| |#||#| ||||'||\|`\_.|| ||`\||#|`\.,.`\||/'||`--'
|
|
||||||
`' `' |#||| `'|#||#| |#||#| `'`' `'`' |#||| `' |||/' |||| |||| `'
|
|
||||||
`-'`' `-'`-' `-'`-' `-'`' `'`' `'`' `'`'
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This program is a fluid simulator using “Smoothed-particle hydrodynamics (SPH)”
|
|
||||||
method.</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics">http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics</a></p>
|
|
||||||
|
|
||||||
<p>The SPH particles represent the fluid flow. Particles have information about
|
|
||||||
the position, density, and velocity. In every simulation step, they are
|
|
||||||
changed by pressure force, viscosity force, and external force (i.e., gravity).</p>
|
|
||||||
|
|
||||||
<p>This program reads a text from standard input, and uses it as an initial
|
|
||||||
configuration of the particles. The character <code>#</code> represents “wall particle” (a
|
|
||||||
particle with fixed position), and any other non-space characters represent
|
|
||||||
free particles.</p>
|
|
||||||
|
|
||||||
<p>The compilation options <code>-DG=1 -DP=4 -DV=8</code> represent, respectively, the factor
|
|
||||||
of gravity, pressure, and viscosity. By changing their values, you can see
|
|
||||||
different fluid behavior.</p>
|
|
||||||
|
|
||||||
<p>“Marching square”-like algorithm is used to render the particles.</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/Marching_squares">http://en.wikipedia.org/wiki/Marching_squares</a></p>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>The program requires a C99 compiler; it uses <code>complex</code> types and one-line
|
|
||||||
comments. It also uses <code>usleep</code>, which may require <code>-D_BSD_SOURCE</code> or somewhat
|
|
||||||
to build with no warning. Under these conditions, it should be portable.
|
|
||||||
At least, recent compilers with <code>-std=c99 -Wall -W -Wextra -pedantic</code> says
|
|
||||||
nothing.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
|
|
||||||
clang -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>I expect it to work in any Unix-like environment. VTxxx/ANSI sequences are
|
|
||||||
used to clear screen and move cursor to home.</p>
|
|
||||||
|
|
||||||
<p>I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04)
|
|
||||||
and gcc-4.5.3 and clang-3.1 on Cygwin. On Cygwin, gcc and clang complain about
|
|
||||||
a usage of <code>I</code> (complex’s imaginary unit), but I bet this is cygwin’s issue;
|
|
||||||
it is surely a C99 feature.</p>
|
|
||||||
|
|
||||||
<h3>Obfuscation w/ Spoiler</h3>
|
|
||||||
|
|
||||||
<p>First of all, the source code itself serves as an initial configuration.
|
|
||||||
Preprocessing directives (such as <code>#include</code>)’s <code>#</code> serve as walls.</p>
|
|
||||||
|
|
||||||
<p>This program uses <code>double complex</code> to represent any 2D vector. But, note that
|
|
||||||
x-axis and y-axis is swapped (real axis = y-axis, imaginary axis = x-axis).
|
|
||||||
The purpose of swapping is not only obfuscation, but also short coding: for
|
|
||||||
example, to add gravity to total force, <code>force += G</code> suffices, rather than
|
|
||||||
<code>force += G*I</code>.
|
|
||||||
(Incidentally, you can exert horizontal gravity by using, such as, <code>-DG=I</code>)</p>
|
|
||||||
|
|
||||||
<p>Every five entries of <code>double complex a[]</code> contain information of one particle:
|
|
||||||
position, wall-flag, density, force, and velocity, in turn.</p>
|
|
||||||
|
|
||||||
<p>You can use <code>G</code>, <code>P</code>, and <code>V</code> as a guide to find the calculation code of
|
|
||||||
gravity, pressure, and viscosity forces.</p>
|
|
||||||
|
|
||||||
<p>Though some assignments may look meaningless, it is actually meaningful; it
|
|
||||||
extracts “integer part of real part” from a complex value by assigning (and
|
|
||||||
casting) it to an integer-type variable.</p>
|
|
||||||
|
|
||||||
<h3>Notes about Additional Files</h3>
|
|
||||||
|
|
||||||
<p>“logo.txt” is a source of the logo in this remark file.</p>
|
|
||||||
|
|
||||||
<p>“column.txt” is a water column collapse, which is a popular demo of SPH.</p>
|
|
||||||
|
|
||||||
<p>“pour-out.txt” pours you a cup of tea.</p>
|
|
||||||
|
|
||||||
<p>“tanada.txt” simulates “Terrace farming”. (“Tanada” means a “terraced rice
|
|
||||||
fields” in Japanese.)</p>
|
|
||||||
|
|
||||||
<p>“clock.txt” is a “water” clock created by HAMANO Tsukasa.</p>
|
|
||||||
|
|
||||||
<p>Other *.txt files are due to the judges.</p>
|
|
||||||
|
|
||||||
<p>“endoh1_color.c” is a variant that shows the density by using terminal 256
|
|
||||||
colors.</p>
|
|
||||||
|
|
||||||
<h3>Acknowledgment</h3>
|
|
||||||
|
|
||||||
<p>I would like to thank my wife @hirekoke for her teaching me the SPH method.</p>
|
|
||||||
|
|
||||||
<p>The judges <strike>ordered</strike> suggested creating a color version
|
|
||||||
after the judgment.</p>
|
|
||||||
|
|
||||||
<p>The judges and HAMANO Tsukasa (The silver medalist at this IOCCC) kindly
|
|
||||||
provided many configuration files.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>PiE in the sky award</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>PiE in the sky award</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make endoh2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./endoh2 > pi.c
|
|
||||||
gcc -o pi pi.c
|
|
||||||
./pi > 314.c
|
|
||||||
...
|
|
||||||
|
|
||||||
./endoh2 e > e.c
|
|
||||||
gcc -o e e.c
|
|
||||||
./e > 271.c
|
|
||||||
...
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>make pi
|
|
||||||
make e
|
|
||||||
make everything
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>A pi/e printing quasi-quine in ASCII art with a compressed font in it;
|
|
||||||
what else to wish for in this program? Virtual machine emulation?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>Yeah, “Again”. Sorry. But I don’t feel guilty or uncomfortable.</p>
|
|
||||||
|
|
||||||
<p>This entry is based on ‘over-used themes’ such as self reproducing
|
|
||||||
program and pi or e computation. I know you’re tired of them.</p>
|
|
||||||
|
|
||||||
<p>But have you ever seen <strong>all-in-one</strong>?</p>
|
|
||||||
|
|
||||||
<h3>What it is</h3>
|
|
||||||
|
|
||||||
<p>This program generates a new program in the shape of the Greek letter
|
|
||||||
<code>pi</code>. Then, the generated program:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>computes 3 digits of pi and prints it as a ASCII-art program that:</li>
|
|
||||||
<li>computes 4 digits of pi and prints it as a ASCII-art program that:</li>
|
|
||||||
<li>computes 5 digits of pi and prints it as a ASCII-art program that:</li>
|
|
||||||
<li>computes 6 digits of pi and prints it as a ASCII-art program that:</li>
|
|
||||||
<li>etc.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>One more thing… When you give a command line option “e” to the
|
|
||||||
first program, the generated one will compute Napier’s constant
|
|
||||||
rather than pi.</p>
|
|
||||||
|
|
||||||
<h3>Obfuscation</h3>
|
|
||||||
|
|
||||||
<p>This program itself is in the shape of a spigot. This is derived
|
|
||||||
from analogy with “spigot algorithm” which infinitely computes the
|
|
||||||
value of a mathematical constant such as <code>pi</code> or <code>e</code>.</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/Spigot_algorithm">http://en.wikipedia.org/wiki/Spigot_algorithm</a></p>
|
|
||||||
|
|
||||||
<p>The two sets of programs, 314*.c and 271*.c, are almost the same
|
|
||||||
except its shape and constant computation part. I tailored the
|
|
||||||
common part to parse in both shapes (“3.14…” and “2.71…”), by
|
|
||||||
tweaking the computation order and adding meaningless code fragment.</p>
|
|
||||||
|
|
||||||
<p>On the other hand, to make it fit inside one screen (80 x 25), my
|
|
||||||
program is shortened properly, more than it looks. (As you may
|
|
||||||
know, Quine needs to make its program size doubled.)
|
|
||||||
For example, this program involves 3x5 bitmap font data of ten
|
|
||||||
characters (‘0’ – ‘9’), as just 20 bytes: “G1%xJ{;Q7wunmuGuu%uu”.
|
|
||||||
We can decode character n as <code>275*s[n+10] - 8*s[n] - 8</code>. I solved the
|
|
||||||
system of Bezout’s identities to find the magic string, with the
|
|
||||||
aid of a brute force. See <code>find-font-table.rb</code> in detail.</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/B%C3%A9zout's_identity">http://en.wikipedia.org/wiki/B%C3%A9zout's_identity</a></p>
|
|
||||||
|
|
||||||
<p>I used many other tricks for short coding.</p>
|
|
||||||
|
|
||||||
<p>I’m sorry that many ASCII-art-style winning entries of IOCCCs
|
|
||||||
ignore preprocessor directives. In my program, #include is a part
|
|
||||||
of ASCII-art with comment padded.</p>
|
|
||||||
|
|
||||||
<p>These design requirements made my program well-obfuscated
|
|
||||||
willy-nilly.</p>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>I expect it to work in any major environment and C compiler.
|
|
||||||
To build with no warning, it requires two C99 features: string
|
|
||||||
literal more than 509 characters and omissible return in main
|
|
||||||
function. In fact, recent compilers with “-std=c99 -Wall -W
|
|
||||||
-Wextra -pedantic” would say nothing.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
|
||||||
clang -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04)
|
|
||||||
and gcc-4.5.3 and clang-3.1 on Cygwin.</p>
|
|
||||||
|
|
||||||
<h3>Synopsis</h3>
|
|
||||||
|
|
||||||
<pre><code>gcc endoh2.c -o endoh2
|
|
||||||
|
|
||||||
./endoh2 > pi.c
|
|
||||||
cat pi.c
|
|
||||||
|
|
||||||
gcc pi.c -o pi ; ./pi > 314.c ; cat 314.c
|
|
||||||
gcc 314.c -o 314 ; ./314 > 3141.c ; cat 3141.c
|
|
||||||
gcc 3141.c -o 3141 ; ./3141 > 31415.c ; cat 31415.c
|
|
||||||
gcc 31415.c -o 31415 ; ./31415 > 314159.c ; cat 314159.c
|
|
||||||
gcc 314159.c -o 314159 ; ./314159 > 3141592.c ; cat 3141592.c
|
|
||||||
etc...
|
|
||||||
|
|
||||||
./endoh2 e > e.c
|
|
||||||
cat e.c
|
|
||||||
|
|
||||||
gcc e.c -o e ; ./e > 271.c ; cat 271.c
|
|
||||||
gcc 271.c -o 271 ; ./271 > 2718.c ; cat 2718.c
|
|
||||||
gcc 2718.c -o 2718 ; ./2718 > 27182.c ; cat 27182.c
|
|
||||||
gcc 27182.c -o 27182 ; ./27182 > 271828.c ; cat 271828.c
|
|
||||||
gcc 271828.c -o 271828 ; ./271828 > 2718281.c ; cat 2718281.c
|
|
||||||
etc...
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>You can do <code>make everything</code> for the process (with no <code>cat</code>).</p>
|
|
||||||
|
|
||||||
<p>Note: The executable may return a failure (non-zero) exit status
|
|
||||||
unless -std=c99 option is given.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most conspiratorial</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most conspiratorial</h1>
|
|
||||||
|
|
||||||
<p>Aaron Grothe<br>
|
|
||||||
2205 South 51st Street<br>
|
|
||||||
Omaha, NE 68106<br>
|
|
||||||
US<br>
|
|
||||||
<a href="mailto:ajgrothe@yahoo.com">ajgrothe@yahoo.com</a></p>
|
|
||||||
|
|
||||||
<p>David Madore<br>
|
|
||||||
<a href="http://www.madore.org/~david/">http://www.madore.org/~david/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make grothe
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code># To create a shared secret shared among M people with N+1 needed to reconstruct
|
|
||||||
./grothe -secret 1-/dev/urandom 2-/dev/urandom ... N-/dev/urandom \
|
|
||||||
1+shared1 2+shared2 ... M+sharedM
|
|
||||||
|
|
||||||
# To reconstruct the original (an arbitrary combination of N+1 or
|
|
||||||
# more shared files with their proper numbers)
|
|
||||||
./grothe I-sharedI J-sharedJ K-sharedK ... +reconstructed
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./grothe -grothe.c 1+grothe.c.1 2+grothe.c.2
|
|
||||||
|
|
||||||
./grothe -cookie_recipe.txt 1-/dev/urandom 2-/dev/urandom \
|
|
||||||
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
|
|
||||||
|
|
||||||
./grothe 1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
|
|
||||||
+cookie_recipe_restore.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Also known as Best abuse of the judging process.</p>
|
|
||||||
|
|
||||||
<p>The IOCCC 2012 submission page didn’t enforce the 2048 meaningful
|
|
||||||
character limit. This entry, as submitted, weighed in at 2222 chars
|
|
||||||
but was, luckily for it, extremely easy to bring down below the
|
|
||||||
limit. There were a number of strings that when concatenated allowed
|
|
||||||
the program to slide under the limit.</p>
|
|
||||||
|
|
||||||
<p>It was clear to the judges that the extra size was an entry
|
|
||||||
beautification step. Had it not, this entry would have been
|
|
||||||
rejected in round 0.</p>
|
|
||||||
|
|
||||||
<p>The judges also took some liberty obfuscating this entry a litte more.</p>
|
|
||||||
|
|
||||||
<p>How does this entry work? The only place multiplication is used is
|
|
||||||
to perform the atoi conversion.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p><strong>Description</strong></p>
|
|
||||||
|
|
||||||
<p>This program implements a version of Shamir’s Secret Sharing. Shamir’s Secret
|
|
||||||
Sharing allows you to encrypt a file into N parts where it will take M parts to
|
|
||||||
recreate the original file. E.g. you can split the secret recipe for Crystal Pepsi
|
|
||||||
into 3 parts and require two of them be available to extract the original recipe.</p>
|
|
||||||
|
|
||||||
<p>Actually surprisingly useful for an IOCCC entry :-)</p>
|
|
||||||
|
|
||||||
<p><strong>Usage</strong></p>
|
|
||||||
|
|
||||||
<p>To share a secret</p>
|
|
||||||
|
|
||||||
<p>E.g.</p>
|
|
||||||
|
|
||||||
<p>file to be shared - cookie_recipe.txt
|
|
||||||
number of pieces - 2 + file to be shared
|
|
||||||
total number of pieces created by program 4
|
|
||||||
pieces needed to reassemble recipe 3 or greater</p>
|
|
||||||
|
|
||||||
<p><strong>example usage</strong></p>
|
|
||||||
|
|
||||||
<p># to share secret into 4 pieces of which at least 3 will be needed to get back the recipe</p>
|
|
||||||
|
|
||||||
<pre><code>./grothe \
|
|
||||||
-cookie_recipe.txt
|
|
||||||
1-/dev/urandom 2-/dev/urandom
|
|
||||||
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p># put recipe back together using 1, 2 and 4th piece</p>
|
|
||||||
|
|
||||||
<pre><code>./grothe \
|
|
||||||
1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
|
|
||||||
+cookie_recipe_restore.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p><strong>Limitations</strong></p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>program is limited to 256 input and output files and will slow down dramatically when you get past 20-50 inputs and outputs</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p><strong>Obfuscations</strong></p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>nothing is done consistently throughout the program E.g i+=1, i=i+1, i++ and ++i are all used in the program. The mark of true code buggery. - “A foolish consistency is the hobgoblin of little minds” - Ralph Waldo Emerson</li>
|
|
||||||
<li>uses the most powerful obfuscation of all “Math”. “Any sufficiently advanced cryptography is indistinguasble from magic” - Apologies to Arthur C. Clarke</li>
|
|
||||||
<li>shadows variables by using brackets in main program to create local copies of variables that are the same as global scope variables. -Wshadow should probably be a part of -Wall in gcc</li>
|
|
||||||
<li>uses array_index[array_name] instead of array_name[array_index] in several places. Still don’t know why C continues to allow this
|
|
||||||
( error strings are encoded with offsets that are also used to select them in the case statement. All strings are located in one function for easy localization</li>
|
|
||||||
<li>liberal use of octal numbers, hexadecimal numbers and regular decimal numbers throughout program</li>
|
|
||||||
<li>variables and function names are semi-random and upper and lower case characters are used</li>
|
|
||||||
<li>use of #defines from stdio.h, stdlib.h for values _STDIO_H and EXIT_SUCCESS used to represent 1 and 0 respectively in the program</li>
|
|
||||||
<li>arrays only need to be 256x256 most are set to greater values than they need to be so trying to figure it out can be a bit tough</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p><strong>References</strong></p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Shamir’s Secret Sharing - <a href="http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing">http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing</a></li>
|
|
||||||
<li>David Madore’s implementation of Shamir’s Secret Sharing - <a href="http://www.madore.org/~david/programs/programs-1.36.html">http://www.madore.org/~david/programs/programs-1.36.html</a></li>
|
|
||||||
<li>Steve’s Recipe Database - source for the $25k Cookie Recipe - <a href="http://recipes.stevex.net/">http://recipes.stevex.net/</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most elementary use of C - Silver award</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most elementary use of C - Silver award</h1>
|
|
||||||
|
|
||||||
<p>Tsukasa Hamano<br>
|
|
||||||
<a href="mailto:hamano@cuspy.org">hamano@cuspy.org</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make hamano
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hamano < textfile > output.pdf
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hamano < hint.text > hint.pdf
|
|
||||||
|
|
||||||
# You can read output.pdf with PDF reader
|
|
||||||
acroread hint.pdf
|
|
||||||
# or
|
|
||||||
evince hint.pdf
|
|
||||||
|
|
||||||
# deobfuscate
|
|
||||||
gcc -xc hint.pdf -o hint
|
|
||||||
./hint
|
|
||||||
|
|
||||||
# Of course, You can obfuscate c code
|
|
||||||
echo 'void main(){puts("Hello World!");}' | ./hamano > hello.pdf
|
|
||||||
gcc -xc hello.pdf -o hello2
|
|
||||||
./hello2 | gcc -xc - -o ./hello3
|
|
||||||
./hello3
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This entry treads into a new territory for IOCCC - generating PDF files.</p>
|
|
||||||
|
|
||||||
<p>The originally submitted entry could have been thought of as a “Best abuse of
|
|
||||||
Ghostscript” winner. :-)</p>
|
|
||||||
|
|
||||||
<p>The source code and rendered pages are obfuscated for humans (where
|
|
||||||
is the font?), and the submitted entry created PDF files that left Ghostscript
|
|
||||||
confused.</p>
|
|
||||||
|
|
||||||
<p>The results can be viewed with Acrobat Reader,
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Evince">evince</a> and Apple’s Preview.</p>
|
|
||||||
|
|
||||||
<p>The updated version can also be viewed using Ghostscript.</p>
|
|
||||||
|
|
||||||
<p>There is something strange about the little flags in the output.
|
|
||||||
A search of English literature will provide a hint. The conclusion
|
|
||||||
you might draw is too elementary. :-)</p>
|
|
||||||
|
|
||||||
<p>So what do those flags really mean?</p>
|
|
||||||
|
|
||||||
<p>The [Dancing men algorithm][1] might be useful.</p>
|
|
||||||
|
|
||||||
<p>Don’t forget to take a look at the generated PDF, perhaps you might even want
|
|
||||||
to compile the output with a C compiler. When you run it, what does it
|
|
||||||
output?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This program obfuscate text file into PDF file with Dancing men
|
|
||||||
algorithm.</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/The_Adventure_of_the_Dancing_Men">http://en.wikipedia.org/wiki/The_Adventure_of_the_Dancing_Men</a></p>
|
|
||||||
|
|
||||||
<p>Probably, the output PDF file is compliant with PDF 1.3. And also
|
|
||||||
available to compile as C code.</p>
|
|
||||||
|
|
||||||
<p>I’ve been tested with GCC 4.7 and Clang 3.0 on Linux, and following
|
|
||||||
PDF Reader:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Adobe Acrobat Reader</li>
|
|
||||||
<li>Evince</li>
|
|
||||||
<li>Ghostscript</li>
|
|
||||||
<li>Xpdf</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Obfuscations</h3>
|
|
||||||
|
|
||||||
<p>This program is obfuscated by using classical methods.
|
|
||||||
But can you find out the embedded font from fragmented glyph?</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most useful obfuscation</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most useful obfuscation</h1>
|
|
||||||
|
|
||||||
<p>Qiming Hou<br>
|
|
||||||
<a href="mailto:hqm03ster@gmail.com">hqm03ster@gmail.com</a><br>
|
|
||||||
<a href="http://www.houqiming.net">http://www.houqiming.net</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make hou
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hou syntax-file file-to-process
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try (Unix):</h3>
|
|
||||||
|
|
||||||
<p>The results are best viewed in a 80x25 console with ANSI colors.</p>
|
|
||||||
|
|
||||||
<pre><code>less hou.c
|
|
||||||
|
|
||||||
./hou ansi.txt hou.c | less -r
|
|
||||||
|
|
||||||
./hou chk.txt hou.c | wc
|
|
||||||
|
|
||||||
./hou markdown.txt remarks.markdown > remarks.htm
|
|
||||||
your-browser remarks.htm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try (Windows):</h3>
|
|
||||||
|
|
||||||
<pre><code>copy header.htm hou.htm /y
|
|
||||||
hou html.txt hou.c >> hou.htm
|
|
||||||
start hou.htm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>What a versatile entry! It can be used to check the size of IOCCC entries <em>and</em> to publish them as HTML.</p>
|
|
||||||
|
|
||||||
<p>For extra credit: what is the meaning of the number 2321237?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Disclaimer</h3>
|
|
||||||
|
|
||||||
<p>The reviewer may have already noticed that the 2nd page of this program is a dense blob, which is discouraged by the contest rules. We wish to point out that a majority of state-of-art programming editors support syntax highlighting, which should be enabled when reading this entry. Anticipating that the reviewer’s preferred color setting may produce a suboptimal visual effect, a few syntax files are provided to highlight the source code under an author-provided setting, using the submitted program itself. Syntax highlighting would also visually improve the 3rd page.</p>
|
|
||||||
|
|
||||||
<p>The code may throw a few warnings due to formating constraints. The author did try to remove warnings under gcc and Visual Studio, though.</p>
|
|
||||||
|
|
||||||
<p>The author does not own the original anime series where the embedded ASCII arts come from. For comparison, original non-ASCII art depictions of the relevant characters and objects can be found by googling the embedded text messages.</p>
|
|
||||||
|
|
||||||
<h3>Syntax files</h3>
|
|
||||||
|
|
||||||
<p>The syntax file consists of a number of rewriting rules. Each rule consists of a regular expression, a space, a format string, and a newline. All text matching the regular expression would be replaced by the format string. In case of a conflict, rules appearing earlier would take precedence. One can refer to the original text in the format string using “%s”. Other “%” characters in the format string must be escaped with another “%”. The space character can be used in the regular expression by escaping it with [] or “”.</p>
|
|
||||||
|
|
||||||
<p>The following regular expression operators are supported:</p>
|
|
||||||
|
|
||||||
<pre><code>() [] * + ? | ""
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>For example, one can use the following expression to match a certain declaration statement in hou.c:</p>
|
|
||||||
|
|
||||||
<pre><code>"char"[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*(,[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*)*;
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The regex engine is also algorithmically efficient. To illustrate the point, ansi.txt contains a pathological expression [2] that guarantees a hang for the competing Perl engine while matching itself. Try to compare these two engines:</p>
|
|
||||||
|
|
||||||
<pre><code>./hou ansi.txt ansi.txt
|
|
||||||
perl patho.pl < ansi.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Finally, there are a few limitations…</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The only escape sequence supported is \n and it doesn’t work in [].</li>
|
|
||||||
<li>The maximum file/rule size is a linear function of the hard-coded constant M.</li>
|
|
||||||
<li>Single-character matches at the end of file may be missed.</li>
|
|
||||||
<li>The operator | doesn’t obey precedence rules and some extra ()s may be required.</li>
|
|
||||||
<li>Incorrect syntax files are not tolerated.</li>
|
|
||||||
<li>The program relies on ASCII.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Why obfuscated</h3>
|
|
||||||
|
|
||||||
<p>The first layer of obfuscation comes from the challenge of embedding a large ASCII art in a dense blob. The entire art is composed using only keywords, strings and character constants. That results in a number of otherwise useless defines and quite a number of unconventionally written constants. While the preprocessor may remove the former, the later would remain regardless of beautification and preprocessing.</p>
|
|
||||||
|
|
||||||
<p>The second layer of obfuscation comes from the need to squeeze a reasonably powerful regex engine into the remaining area that isn’t occupied by excessive keywords and useless constants. To achieve this, the regex compiler is written using the same threaded virtual machine [1] that parses the regex. Due to compiler limitations, the generated VM code also ends up obscured by a large amount of spaghetti branches and virtual thread creations. Finally, the VM in [1] is extended to track multiple expression matches for the actual formating.</p>
|
|
||||||
|
|
||||||
<p>As an extra tweak, the text message actually does something useful. Remove the “Make a contract with me” catch line and the program would cease to function.</p>
|
|
||||||
|
|
||||||
<h3>References</h3>
|
|
||||||
|
|
||||||
<p>[1] <a href="http://swtch.com/~rsc/regexp/regexp2.html">Russ Cox, Regular Expression Matching: the Virtual Machine Approach</a></p>
|
|
||||||
|
|
||||||
<p>[2] <a href="http://swtch.com/~rsc/regexp/regexp1.html">Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, …)</a></p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,193 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best short program</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best short program</h1>
|
|
||||||
|
|
||||||
<p>Seonghoon Kang<br>
|
|
||||||
<a href="mailto:kang.seonghoon@mearie.org">kang.seonghoon@mearie.org</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make kang
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo Nineteen hundred and eighty-four | ./kang
|
|
||||||
echo uno | ./kang
|
|
||||||
echo trois | ./kang
|
|
||||||
echo fier | ./kang
|
|
||||||
echo "shest'" | ./kang
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>The judges were able to appreciate the Indo-European language family
|
|
||||||
relation by making this entry successfully recognize <em>some</em> French,
|
|
||||||
German, Italian, Russian, and Spanish numerals.</p>
|
|
||||||
|
|
||||||
<p>Also worth mentioning is this entry’s ability to understand the
|
|
||||||
colloquial year numbers of the last millennium.</p>
|
|
||||||
|
|
||||||
<p>We’ve added a linefeed to the print format for convenience.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>Synopsis</h2>
|
|
||||||
|
|
||||||
<p>This short program reads a spelt number (e.g. <code>forty-two</code>) and writes a
|
|
||||||
corresponding decimal number (e.g. <code>42</code>). Too long for one-liners, alas,
|
|
||||||
but it still qualifies as a <em>short</em> program as it has less than 0x100 bytes.</p>
|
|
||||||
|
|
||||||
<p>It accepts a variety of spelt numbers:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>It correctly handles <code>zero</code>.</li>
|
|
||||||
<li>Hyphen does not make a difference: <code>forty-two</code> and <code>forty two</code> are same.
|
|
||||||
So does period or comma.</li>
|
|
||||||
<li>Cases do not make a difference either: <code>TWO</code>, <code>Two</code>, <code>two</code> are same.</li>
|
|
||||||
<li><code>one</code> and <code>a</code> are interchangeable: <code>one hundred</code> and <code>a hundred</code> are same.</li>
|
|
||||||
<li><code>and</code> is optional: <code>one hundred twenty-three</code> and <code>one hundred and twenty-three</code>
|
|
||||||
are same.</li>
|
|
||||||
<li>It supports every non-negative integer less than 10<sup>15</sup>-1. It uses
|
|
||||||
the small scale (i.e. American): <code>billion</code> is 10<sup>9</sup> and <code>trillion</code> is
|
|
||||||
10<sup>12</sup>.</li>
|
|
||||||
<li>Sometimes, it can magically correct typos.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>It does <em>not</em> accept some spelt numbers, which I found mostly irrelevant:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>A bare <code>hundred</code>, <code>thousand</code> etc. do not work.</li>
|
|
||||||
<li><code>one million million</code> does not work. Get used to <code>one trillion</code>!</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Requirements</h2>
|
|
||||||
|
|
||||||
<p>This program is quite portable, only requiring the following:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The signature <code>int main(int, int)</code> should be accepted by the linker. (Original
|
|
||||||
version only)</li>
|
|
||||||
<li><code>char</code> should be at least 8 bits long (as dictated by the standard), <code>int</code>
|
|
||||||
should be at least 32 bits long, <code>long long</code> should be at least 64 bits long.</li>
|
|
||||||
<li>Both the compiler and execution environment should use an ASCII-compatible
|
|
||||||
character set and two’s complement representation.</li>
|
|
||||||
<li>Overflow and underflow on <code>char</code> should wrap around, if your <code>char</code> is unsigned.</li>
|
|
||||||
<li><a href="http://cm.bell-labs.com/who/ken/trust.html">A trustworthy compiler</a>.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The design of the program explicitly allows for <code>EOF</code> which does not equal to -1
|
|
||||||
(it has to be negative per the standard) and both signed and unsigned <code>char</code>,
|
|
||||||
for example. Furthermore it is endian-independent.</p>
|
|
||||||
|
|
||||||
<h2>Obfuscations (SPOILERS!)</h2>
|
|
||||||
|
|
||||||
<p>Many obfuscations used are typical for standard IOCCC entries:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Two arguments from <code>main</code> function are reused as normal variables.</li>
|
|
||||||
<li>Every conditional has been replaced with <code>?:</code> ternary operator and <code>||</code>
|
|
||||||
short-circuiting operator.</li>
|
|
||||||
<li>It has exactly three nested <code>for</code> loops and nothing else.</li>
|
|
||||||
<li>Common two’s complement tricks: <code>~-a</code> instead of <code>a-1</code>,
|
|
||||||
<code>~a?...:...</code> instead of <code>a!=-1?...:...</code>, etc.</li>
|
|
||||||
<li>Comma operators (<code>,</code>) for multiple statements. The number of them is
|
|
||||||
minimized, however, as it is too easy to (ab)use them.</li>
|
|
||||||
<li>It lacks most parentheses around bitwise and arithmetic operators. It was
|
|
||||||
originally written for shortness so parentheses were <strong>EVIL</strong>.</li>
|
|
||||||
<li><code>n["string"]</code> instead of <code>"string"[n]</code>. Both are fine for this program but
|
|
||||||
I went to the former just for fun.</li>
|
|
||||||
<li>Utter lack of any kind of layouts. (Oh, except for the first column.)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Other obfuscations are more subtle:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The string <code>"1+DIY/.K430x9G(kC["</code> is 18 bytes long, but actually 19 bytes
|
|
||||||
including the final null character are used.</li>
|
|
||||||
<li>It internally represents numbers as hexadecimal. When the input is <code>two
|
|
||||||
hundred and three</code>, it actually writes 0x203 as hexadecimal.</li>
|
|
||||||
<li>Some variables (notably, <code>n</code>) have dual uses.</li>
|
|
||||||
<li>The magic number <a href="http://en.wikipedia.org/wiki/Answer_to_The_Ultimate_Question_of_Life,_the_Universe,_and_Everything">42</a> makes an appearance.</li>
|
|
||||||
<li>It has a long long numb-<code>main</code>-er within it!</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>But the most important obfuscation is the clever construction of lookup table.
|
|
||||||
The program uses 11 different characters required for recognizing 22 lexemes:</p>
|
|
||||||
|
|
||||||
<pre><code>zero one tw- th(i)r- fo(u)r- fi- six-
|
|
||||||
seven- eigh- nin- ten eleven twelve
|
|
||||||
hundred(s) thousand(s) million(s) billion(s) trillion(s)
|
|
||||||
a and -teen -ty
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>So that they are internally represented as like:</p>
|
|
||||||
|
|
||||||
<pre><code>r n tw- tr- fr- f- s-
|
|
||||||
sn- g- nn- tn ln twl
|
|
||||||
nr(s) tsan(s) lln(s) blln(s) trlln(s)
|
|
||||||
a an -tn -ty
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The stemmer recognizes the longest matching prefix, so every lexeme can be
|
|
||||||
recognized by at most three characters (e.g. <code>trl</code> instead of <code>trlln</code>). This is
|
|
||||||
also handy for ignoring plurals. But that would make that the table does not fit
|
|
||||||
in the printable byte—11<sup>2</sup> is already almost 2<sup>7</sup>!</p>
|
|
||||||
|
|
||||||
<p>The trick is to use octal; three characters (<code>a</code>, <code>b</code> and <code>g</code>) are interpreted
|
|
||||||
as sequences of two characters (<code>ny</code>, <code>nn</code> and <code>nw</code> respectively). Asides from
|
|
||||||
a smaller lookup table, it has many good consequences:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Both <code>a</code> and <code>and</code> share the common prefix, <code>ny</code>, and can be discarded
|
|
||||||
altogether. Note that <code>ny</code> itself does not appear from other entries.</li>
|
|
||||||
<li><code>thousand</code> is interpreted as <code>tsan</code>, which is equivalent to <code>tfyn</code> in the
|
|
||||||
octal scheme. As it is the only entry with <code>tf</code> prefix, it can be shorten by
|
|
||||||
one character.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Having said this important trick, other details should be relatively easier to
|
|
||||||
follow. The order of lookup table, for example, is very important,
|
|
||||||
and the biggest constant 6177 is not arbitrarily chosen.</p>
|
|
||||||
|
|
||||||
<h2>Acknowledgement</h2>
|
|
||||||
|
|
||||||
<p>The cleaner (size-optimized) version of this program was originally published
|
|
||||||
in my website in July 2011. Sun Park and others have reviewed it and let me
|
|
||||||
aware of possible improvements. I’d also like to thank Seo Sanghyeon for
|
|
||||||
proof-reading remarks.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best one liner</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best one liner</h1>
|
|
||||||
|
|
||||||
<p>Taketo Konno<br>
|
|
||||||
Tokyo, Japan<br>
|
|
||||||
<a href="mailto:inaniwa3@gmail.com">inaniwa3@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make konno
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./konno N
|
|
||||||
# where N is 0 to 255
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./konno 30
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This entry is a good one-liner to analyze completely.</p>
|
|
||||||
|
|
||||||
<p>For extra credit, what are the minimal changes to convert it to
|
|
||||||
64-bit integers so that it could print 32 lines?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<p>This program outputs <a href="http://mathworld.wolfram.com/ElementaryCellularAutomaton.html">elementary cellular automaton</a> patterns.</p>
|
|
||||||
|
|
||||||
<p>Try:</p>
|
|
||||||
|
|
||||||
<pre><code>./konno 30
|
|
||||||
./konno 90
|
|
||||||
./konno 102
|
|
||||||
./konno 109
|
|
||||||
./konno 165
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>There are 256 (from 0 to 255) possible rules.</p>
|
|
||||||
|
|
||||||
<h3>Obfuscation</h3>
|
|
||||||
|
|
||||||
<p>This program uses bit operations. I think</p>
|
|
||||||
|
|
||||||
<pre><code>7&O<<!o>>!o+29
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>is an intersting operation. This isn’t equal to</p>
|
|
||||||
|
|
||||||
<pre><code>7&O>>29
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>operation. What is the operation doing?</p>
|
|
||||||
|
|
||||||
<h3>Limitation</h3>
|
|
||||||
|
|
||||||
<p>This program assumes that the size of int is 4.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most surreptitious</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most surreptitious</h1>
|
|
||||||
|
|
||||||
<p>Don Yang<br>
|
|
||||||
<a href="mailto:omoikane@uguu.org">omoikane@uguu.org</a><br>
|
|
||||||
<a href="http://uguu.org/">http://uguu.org/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make nyaruko
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./nyaruko [seed.txt] < original.bin > output.c
|
|
||||||
bash output.c > key.c
|
|
||||||
perl output.c > data.c
|
|
||||||
|
|
||||||
cat key.c data.c > output.c
|
|
||||||
|
|
||||||
gcc output.c -o output
|
|
||||||
./output > regenerated.bin
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo "A quick brown fox jumps over the lazy dog" | ./nyaruko > output.c
|
|
||||||
perl output.c > data.c
|
|
||||||
gcc -o data data.c
|
|
||||||
./data
|
|
||||||
gcc -o output output.c
|
|
||||||
./output
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>The judges have nothing to add that has not already been written
|
|
||||||
about in the spoiler.html.gz file! :-)</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Usage</h1>
|
|
||||||
|
|
||||||
<p>Nyaruko is a binary to text filter. Given some input on stdin,
|
|
||||||
Nyaruko will produce C code that reproduces this input on stdout:</p>
|
|
||||||
|
|
||||||
<pre><code>./nyaruko < original.bin > output.c
|
|
||||||
gcc output.c -o output
|
|
||||||
./output > regenerated.bin
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Output is encrypted, but both key and data are included in the output.
|
|
||||||
To separate the key from the data, run these commands:</p>
|
|
||||||
|
|
||||||
<pre><code>bash output.c > key.c
|
|
||||||
perl output.c > data.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The key-less data.c still compiles, but produces a different message
|
|
||||||
on stdout instead of the original input. This message is a hint to
|
|
||||||
why the code is formatted the way it is.</p>
|
|
||||||
|
|
||||||
<p>To combine the key and data, concatenate them together in either
|
|
||||||
order:</p>
|
|
||||||
|
|
||||||
<pre><code>cat key.c data.c > output.c
|
|
||||||
cat data.c key.c > output.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>By default, Nyaruko generates a unique random key for every message,
|
|
||||||
using /dev/urandom as the seed. If given an extra command line
|
|
||||||
argument, Nyaruko will seed using that file instead of /dev/urandom:</p>
|
|
||||||
|
|
||||||
<pre><code>./nyaruko seed.txt < input.bin > output.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This makes the output key deterministic, allowing the same key to be
|
|
||||||
shared across different files. On operating systems that do not have
|
|
||||||
/dev/urandom, users should always specify this extra seed argument to
|
|
||||||
avoid deterministic keys.</p>
|
|
||||||
|
|
||||||
<h1>Features</h1>
|
|
||||||
|
|
||||||
<p>Implementation details that makes Nyaruko more obfuscated than usual
|
|
||||||
programs:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> Nyaruko recycles variables and buffers to reduce internal state.
|
|
||||||
The variable names are also carefully chosen for mixed-case
|
|
||||||
madness.</li>
|
|
||||||
<li> Nyaruko employs some preprocessor magic to share much of the same
|
|
||||||
code and state between the encoder and decoder, and to increase
|
|
||||||
occurrences of smileys ;)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Output code has these features:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> Fits nicely under 80 columns, and does not contain any trigraphs.</li>
|
|
||||||
<li> Uses a fairly efficient encoding scheme, better than uuencode for
|
|
||||||
files larger than ~13K, and better than base64 for files larger
|
|
||||||
than 20K.</li>
|
|
||||||
<li> Encryption with ISAAC, a cryptographically secure pseudorandom
|
|
||||||
number generator.</li>
|
|
||||||
<li> Trivial 3 language polyglot.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Code layout is meant to resemble Nyaruko, also known as Nyarlathotep,
|
|
||||||
the Crawling Chaos. The most obvious thing to do with chaos is to
|
|
||||||
make a random number generator, and the most obvious thing to do with
|
|
||||||
a random number generator is to make one-time-pads for encryption.</p>
|
|
||||||
|
|
||||||
<h1>Compatibility</h1>
|
|
||||||
|
|
||||||
<p>Nyaruko has these environment dependencies:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> Requires ASCII character set.</li>
|
|
||||||
<li> Assumes sizeof(unsigned int) == 4.</li>
|
|
||||||
<li> Best viewed with tab stops set to 8 spaces.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Output code has the same dependencies, with the additional
|
|
||||||
requirement that the compiler must support arbitrarily long string
|
|
||||||
literals. Maximum input size that can be encoded while still
|
|
||||||
producing standard-compliant output is ~276 bytes for C89, and ~3168
|
|
||||||
bytes for C99.</p>
|
|
||||||
|
|
||||||
<p>Nyaruko has been to verified to work with these compiler/OS
|
|
||||||
combinations:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> gcc 4.4.5 on Linux (32bit and 64bit)</li>
|
|
||||||
<li> clang 3.1 on Windows (Cygwin)</li>
|
|
||||||
<li> gcc 4.5.3 on Windows (Cygwin)</li>
|
|
||||||
<li> gcc 4.5.3 on Windows (MingW)</li>
|
|
||||||
<li> gcc 4.3.5 on JSLinux</li>
|
|
||||||
<li> tcc 0.9.25 on JSLinux</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Note that on MingW, stdin and stdout are not opened in binary mode by
|
|
||||||
default, this means Nyaruko may not faithfully encode files on MingW.</p>
|
|
||||||
|
|
||||||
<h1>Extra files</h1>
|
|
||||||
|
|
||||||
<p>spoiler.html.gz - Contains full recording of how the code went from
|
|
||||||
blank state to an obfuscated program, gzipped to fit under 1MB.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,486 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most functional</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most functional</h1>
|
|
||||||
|
|
||||||
<p>John Tromp<br>
|
|
||||||
<a href="mailto:john.tromp@gmail.com">john.tromp@gmail.com</a><br>
|
|
||||||
<a href="http://tromp.github.io/">http://tromp.github.io/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<p>On a 32-bit machine:</p>
|
|
||||||
|
|
||||||
<pre><code>make tromp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>On a 64-bit machine:</p>
|
|
||||||
|
|
||||||
<pre><code>make tromp64
|
|
||||||
# And mentally substitute ./tromp64 for ./tromp everywhere below
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>cat ascii-prog.blc data | ./tromp -b
|
|
||||||
cat binary-prog.Blc data | ./tromp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>(cat hilbert.Blc; echo -n 1234) | ./tromp
|
|
||||||
(cat oddindices.Blc; echo; cat primes.blc | ./tromp -b) | ./tromp
|
|
||||||
cat primes.blc | ./tromp -b | ./primes.pl
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>The judges dare to say that the data files this entry is processing
|
|
||||||
are more obfuscated than the entry itself.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This program celebrates the close connection between obfuscation and conciseness,
|
|
||||||
by implementing the most concise language known, Binary Lambda Calculus (BLC).</p>
|
|
||||||
|
|
||||||
<p>BLC was developed to make Algorithmic Information Theory, the theory of smallest programs,
|
|
||||||
more concrete. It starts with the simplest model of computation, the lambda calculus,
|
|
||||||
and adds the minimum amount of machinery to enable binary input and output.</p>
|
|
||||||
|
|
||||||
<p>More specifically, it defines a universal machine, which, from an input stream of bits,
|
|
||||||
parses the binary encoding of a lambda calculus term, applies that to the remainder
|
|
||||||
of input (translated to a lazy list of booleans,
|
|
||||||
which have a standard representation in lambda calculus),
|
|
||||||
and translates the evaluated result back into a stream of bits to be output.</p>
|
|
||||||
|
|
||||||
<p>Lambda is encoded as 00, application as 01, and the variable bound by the n'th
|
|
||||||
enclosing lambda (denoted n in so-called De Bruijn notation) as 1^{n}0.
|
|
||||||
That’s all there is to BLC!</p>
|
|
||||||
|
|
||||||
<p>For example the encoding of lambda term S = \x \y \z (x z) (y z),
|
|
||||||
with De Bruijn notation \ \ \ (3 1) (2 1),
|
|
||||||
is 00 00 00 01 01 1110 10 01 110 10</p>
|
|
||||||
|
|
||||||
<p>In the closely related BLC8 language, IO is byte oriented,
|
|
||||||
translating between a stream of bytes and a list of length-8 lists of booleans.</p>
|
|
||||||
|
|
||||||
<p>The submission implements the universal machine in the most concise manner conceivable.
|
|
||||||
It lacks #defines and #includes, and compiles to a (stripped) executable of under 6K in size.</p>
|
|
||||||
|
|
||||||
<p>Without arguments, it runs in byte mode, using standard in- and output.
|
|
||||||
With one (arbitrary) argument, it runs in bit mode, using only the least significant
|
|
||||||
bit of input, and using characters ‘0’ and ‘1’ for output.</p>
|
|
||||||
|
|
||||||
<p>The program uses the following exit codes:
|
|
||||||
0: OK; result is a finite list
|
|
||||||
5: Out of term space
|
|
||||||
6: Out of memory
|
|
||||||
1,2,3,4,8,9: result not in list form</p>
|
|
||||||
|
|
||||||
<p>The size of the term space is fixed at compile time with -DA</p>
|
|
||||||
|
|
||||||
<h1>A half byte `cat'</h1>
|
|
||||||
|
|
||||||
<p>The shortest (closed) lambda calculus term is \x x (\ 1 in De Bruijn notation)
|
|
||||||
which is the identity function. When its encoding 0010 is fed
|
|
||||||
into the universal machine, it will simply copy the input to the output.
|
|
||||||
(well, not that simply, since each byte is smashed to bits and rebuilt from scratch)
|
|
||||||
Voila: a half byte cat:</p>
|
|
||||||
|
|
||||||
<pre><code> echo " Hello, world" | ./tromp
|
|
||||||
Hello, world
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Since the least significant 4 bits of the first byte are just arbitrary padding
|
|
||||||
that is ignored by the program,
|
|
||||||
any character from ASCII 32 (space) through 47 (/) will do, e.g.:</p>
|
|
||||||
|
|
||||||
<pre><code> echo "*Hello, world" | ./tromp
|
|
||||||
Hello, world
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>Bad programs</h1>
|
|
||||||
|
|
||||||
<p>If the input doesn’t start with a valid program, that is,
|
|
||||||
if the interpreter reaches end-of-file during program parsing,
|
|
||||||
it will crash in some way:</p>
|
|
||||||
|
|
||||||
<pre><code> echo -n "U" | ./tromp
|
|
||||||
Segmentation fault
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Furthermore, the interpreter requires the initial encoded lambda term to be closed,
|
|
||||||
that is, variable n can only appear within at least n enclosing lambdas.
|
|
||||||
For instance the term \ 5 is not closed,
|
|
||||||
causing the interpreter to crash when looking into a null-pointer environment:</p>
|
|
||||||
|
|
||||||
<pre><code> echo ">Hello, world" | ./tromp
|
|
||||||
Segmentation fault
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Since these properties can be checked when creating BLC programs,
|
|
||||||
the interpreter doesn’t bother checking for it.</p>
|
|
||||||
|
|
||||||
<h1>A Self Interpreter</h1>
|
|
||||||
|
|
||||||
<p>The BLC universal machine may be small at 650 bytes of C
|
|
||||||
(952 bytes including layout), but written
|
|
||||||
as a self interpreter in BLC it is downright minuscule at 232 bits (29 bytes):</p>
|
|
||||||
|
|
||||||
<pre><code> 01010001
|
|
||||||
10100000
|
|
||||||
00010101
|
|
||||||
10000000
|
|
||||||
00011110
|
|
||||||
00010111
|
|
||||||
11100111
|
|
||||||
10000101
|
|
||||||
11001111
|
|
||||||
000000111
|
|
||||||
10000101101
|
|
||||||
1011100111110
|
|
||||||
000111110000101
|
|
||||||
11101001 11010010
|
|
||||||
11001110 00011011
|
|
||||||
00001011 11100001
|
|
||||||
11110000 11100110
|
|
||||||
11110111 11001111
|
|
||||||
01110110 00011001
|
|
||||||
00011010 00011010
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The byte oriented BLC8 version weighs in at 43 bytes (shown in hexadecimal).</p>
|
|
||||||
|
|
||||||
<pre><code> 19468
|
|
||||||
05580
|
|
||||||
05f00
|
|
||||||
bfe5f
|
|
||||||
85f3f
|
|
||||||
03c2d
|
|
||||||
b9fc3f8
|
|
||||||
5e9d65e5f
|
|
||||||
0decb f0fc3
|
|
||||||
9befe 185f7
|
|
||||||
0b7fb 00cf6
|
|
||||||
7bb03 91a1a
|
|
||||||
|
|
||||||
(cat uni8.Blc; echo " Ni hao") | ./tromp
|
|
||||||
Ni hao
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>A prime number sieve</h1>
|
|
||||||
|
|
||||||
<p>Even shorter than the self-interpreter is this prime number sieve in 167 bits (under 21 bytes):</p>
|
|
||||||
|
|
||||||
<pre><code>000100011001100101000110100
|
|
||||||
000000101100000100100010101
|
|
||||||
11110111 101001000
|
|
||||||
11010000 111001101
|
|
||||||
000000000010110111001110011
|
|
||||||
11111011110000000011111001
|
|
||||||
10111000
|
|
||||||
00010110
|
|
||||||
0000110110
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The n'th bit in the output indicates whether n is prime:</p>
|
|
||||||
|
|
||||||
<pre><code> cat primes.blc | ./tromp -b | head -c 70
|
|
||||||
0011010100010100010100010000010100000100010100010000010000010100000100
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>For those who prefer to digest their primes in decimal, there is oddindices.Blc,
|
|
||||||
which will print the indices of all odd characters (with lsb = 1)
|
|
||||||
separated by a given character:</p>
|
|
||||||
|
|
||||||
<pre><code> (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70
|
|
||||||
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>A Space filling program</h1>
|
|
||||||
|
|
||||||
<p>Program hilbert.Blc, at 143 bytes, is a very twisty “one-liner” (shown in hexadecimal):</p>
|
|
||||||
|
|
||||||
<pre><code>1818181 8111154 6806041 55ff041
|
|
||||||
9d f9 de 16 ff fe 5f 3f
|
|
||||||
ef f615ff9 46 84 058117e 05
|
|
||||||
cb fe bc bf
|
|
||||||
ee86cb9 4681600 5c0bfac bfbf71a
|
|
||||||
85 e0 5c f4
|
|
||||||
14d5fe0 8180b048d0800e078 016445f
|
|
||||||
fe 5f
|
|
||||||
f7 ffffe5fff2fc 02f7ad97f5bf ff
|
|
||||||
ff bf ff ca af ff
|
|
||||||
7817ffa df76695 4680601 57f7e16
|
|
||||||
05 c1
|
|
||||||
3fe80b2 2c18581 bfe5c10 42ff805
|
|
||||||
de ec 06 c2 c0 c0
|
|
||||||
60 8191a00167fb cbcfdf65f7c0 a20
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>It expects n arbitrary characters of input, and draws a space filling Hilbert curve of order n:</p>
|
|
||||||
|
|
||||||
<pre><code> (cat hilbert.Blc; echo -n "1") | ./tromp
|
|
||||||
_
|
|
||||||
| |
|
|
||||||
|
|
||||||
(cat hilbert.Blc; echo -n "12") | ./tromp
|
|
||||||
_ _
|
|
||||||
| |_| |
|
|
||||||
|_ _|
|
|
||||||
_| |_
|
|
||||||
|
|
||||||
(cat hilbert.Blc; echo -n "123") | ./tromp
|
|
||||||
_ _ _ _
|
|
||||||
| |_| | | |_| |
|
|
||||||
|_ _| |_ _|
|
|
||||||
_| |_____| |_
|
|
||||||
| ___ ___ |
|
|
||||||
|_| _| |_ |_|
|
|
||||||
_ |_ _| _
|
|
||||||
| |___| |___| |
|
|
||||||
|
|
||||||
(cat hilbert.Blc; echo -n "1234") | ./tromp
|
|
||||||
_ _ _ _ _ _ _ _
|
|
||||||
| |_| | | |_| | | |_| | | |_| |
|
|
||||||
|_ _| |_ _| |_ _| |_ _|
|
|
||||||
_| |_____| |_ _| |_____| |_
|
|
||||||
| ___ ___ | | ___ ___ |
|
|
||||||
|_| _| |_ |_| |_| _| |_ |_|
|
|
||||||
_ |_ _| _ _ |_ _| _
|
|
||||||
| |___| |___| |_| |___| |___| |
|
|
||||||
|_ ___ ___ ___ ___ _|
|
|
||||||
_| |_ |_| _| |_ |_| _| |_
|
|
||||||
| _ | _ |_ _| _ | _ |
|
|
||||||
|_| |_| | |___| |___| | |_| |_|
|
|
||||||
_ _ | ___ ___ | _ _
|
|
||||||
| |_| | |_| _| |_ |_| | |_| |
|
|
||||||
|_ _| _ |_ _| _ |_ _|
|
|
||||||
_| |___| |___| |___| |___| |_
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>A BrainFuck interpreter</h1>
|
|
||||||
|
|
||||||
<p>The smallest known BF interpreter is written in… you guessed it, BLC,
|
|
||||||
coming in at 112 bytes (including 3 bits of padding):</p>
|
|
||||||
|
|
||||||
<pre><code> od -t x4 bf.Blc
|
|
||||||
0000000 01a15144 02d55584 223070b7 00f032ff
|
|
||||||
0000020 7f85f9bf 956fe15e c0ee7d7f 006854e5
|
|
||||||
0000040 fbfd5558 fd5745e0 b6f0fbeb 07d62ff0
|
|
||||||
0000060 d7736fe1 c0bc14f1 1f2eff0b 17666fa1
|
|
||||||
0000100 2fef5be8 ff13ffcf 2034cae1 0bd0c80a
|
|
||||||
0000120 e51fee99 6a5a7fff ff0fff1f d0049d87
|
|
||||||
0000140 db0500ab 3bb74023 b0c0cc28 10740e6c
|
|
||||||
0000160
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>It expects its input to consist of a Brainfuck program
|
|
||||||
(looking only at bits 0,1,4 to distinguish among ,-.+<>][ )
|
|
||||||
followed by a ], followed by the input for the Brainfuck program.</p>
|
|
||||||
|
|
||||||
<pre><code> more hw.bf
|
|
||||||
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.]
|
|
||||||
cat bf.Blc hw.bf | ./tromp
|
|
||||||
Hello World!
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Curiously, the interpreter bf.Blc is the exact same size as hw.bf.</p>
|
|
||||||
|
|
||||||
<h1>A BLC assembler</h1>
|
|
||||||
|
|
||||||
<p>Writing BLC programs can be made slightly less painful with this parser that
|
|
||||||
translates single-letter-variable lambda calculus into BLC:</p>
|
|
||||||
|
|
||||||
<pre><code> echo "\f\x f (f (f x))" > three
|
|
||||||
cat parse.Blc three | ./tromp
|
|
||||||
000001110011100111010
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>Converting between bits and bytes</h1>
|
|
||||||
|
|
||||||
<p>THe program inflate.Blc and its inverse deflate.Blc allow us to translate between
|
|
||||||
BLC and BLC8.
|
|
||||||
If you assemble a byte oriented program, you’ll need to compact it into BLC8:</p>
|
|
||||||
|
|
||||||
<p>So we could assemble an input reversing program as</p>
|
|
||||||
|
|
||||||
<pre><code> echo "\a a ((\b b b) (\b \c \d \e d (b b) (\f f c e))) (\b \c c)" > reverse
|
|
||||||
cat parse.Blc reverse | ./tromp > reverse.blc
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>and change it to BLC8 with</p>
|
|
||||||
|
|
||||||
<pre><code> cat deflate.Blc reverse.blc | ./tromp > rev.Blc
|
|
||||||
wc rev.Blc
|
|
||||||
0 1 9 rev.Blc
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>and then try it out with:</p>
|
|
||||||
|
|
||||||
<pre><code> cat rev.Blc - | ./tromp
|
|
||||||
Hello, world!
|
|
||||||
^D
|
|
||||||
!dlrow ,olleH
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>Symbolic Lambda Calculus reduction </h1>
|
|
||||||
|
|
||||||
<p>BLC8 program symbolic.Blc shows individual reduction steps on symbolic lambda terms.
|
|
||||||
Here it is used to show the calculation of 2<sup>3</sup> in Church numerals:</p>
|
|
||||||
|
|
||||||
<pre><code> echo "(\f\x f (f (f x))) (\f\x f (f x))" > threetwo
|
|
||||||
cat parse.Blc threetwo | ./tromp > threetwo.blc
|
|
||||||
cat symbolic.Blc threetwo.blc | ./tromp
|
|
||||||
(\a \b a (a (a b))) (\a \b a (a b))
|
|
||||||
\a (\b \c b (b c)) ((\b \c b (b c)) ((\b \c b (b c)) a))
|
|
||||||
\a \b (\c \d c (c d)) ((\c \d c (c d)) a) ((\c \d c (c d)) ((\c \d c (c d)) a) b)
|
|
||||||
\a \b (\c (\d \e d (d e)) a ((\d \e d (d e)) a c)) ((\c \d c (c d)) ((\c \d c (c d)) a) b)
|
|
||||||
\a \b (\c \d c (c d)) a ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b))
|
|
||||||
\a \b (\c a (a c)) ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b))
|
|
||||||
\a \b a (a ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b)))
|
|
||||||
\a \b a (a ((\c a (a c)) ((\c \d c (c d)) ((\c \d c (c d)) a) b)))
|
|
||||||
\a \b a (a (a (a ((\c \d c (c d)) ((\c \d c (c d)) a) b))))
|
|
||||||
\a \b a (a (a (a ((\c (\d \e d (d e)) a ((\d \e d (d e)) a c)) b))))
|
|
||||||
\a \b a (a (a (a ((\c \d c (c d)) a ((\c \d c (c d)) a b)))))
|
|
||||||
\a \b a (a (a (a ((\c a (a c)) ((\c \d c (c d)) a b)))))
|
|
||||||
\a \b a (a (a (a (a (a ((\c \d c (c d)) a b))))))
|
|
||||||
\a \b a (a (a (a (a (a ((\c a (a c)) b))))))
|
|
||||||
\a \b a (a (a (a (a (a (a (a b)))))))
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>As expected, the resulting normal form is Church numeral 8.</p>
|
|
||||||
|
|
||||||
<p>Taking only the first line of output gives us a sort of BLC disassembler,
|
|
||||||
an exact inverse of the above assembler. The prime number sieve disassembles as follows:</p>
|
|
||||||
|
|
||||||
<pre><code> cat symbolic.Blc primes.blc | ./tromp | head -1
|
|
||||||
\a (\b b (b ((\c c c) (\c \d \e e (\f \g g) ((\f c c f ((\g g g) (\g f (g g)))) (\f \g \h \i i g (h (d f))))) (\c \d \e b (e c))))) (\b \c c (\d \e d) b)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Hardly any less obfuscated…</p>
|
|
||||||
|
|
||||||
<p>The last line of
|
|
||||||
cat symbolic.Blc primes.blc | ./tromp | head -16
|
|
||||||
starts out as
|
|
||||||
\a \b b (\c \d c) (\c c (\d \e d) (\d d (\e \f f) (\e e (\f \g g) ((\f (\g \h \i</p>
|
|
||||||
|
|
||||||
<p>The \a is for ignoring the rest of the input (to which the universal machine
|
|
||||||
applies the decoded lambda term). The \b b (..) (…) is the list constructor,
|
|
||||||
usually called cons, applied to a head (a list element) and a tail (another list).
|
|
||||||
In this case the element is (\c \d c), which represents the boolean true, and
|
|
||||||
which we use to represent a 0 bit. This is the bit that says 0 is not prime.
|
|
||||||
The next list element (following another cons) is (\d \e d). Another 0 bit,
|
|
||||||
this time saying that 1 is not prime. The third list element is (\e \f f),
|
|
||||||
a 1 bit, confirming our suspicion that 2 is prime. As is the next number,
|
|
||||||
according to (\f \g g). We can see that the tail after the first 4 elements
|
|
||||||
is still subject to further reduction. The bit for number 4 will show up
|
|
||||||
for the first time in line 30, as (\g \h g), or 0, as the result of zeroing
|
|
||||||
out all multiples of the first prime, 2.
|
|
||||||
Since my computer reaches swap hell before line 40, we can’t see the next bit arriving,
|
|
||||||
at least not in this symbolic reduction.</p>
|
|
||||||
|
|
||||||
<h1>Performance</h1>
|
|
||||||
|
|
||||||
<p>Performance is quite decent, and amazingly good for such a tiny implementation,
|
|
||||||
being roughly 50% slower than a Haskell implementation of the universal machine
|
|
||||||
using so-called Higher Order Abstract Syntax which relies on the highly optimized
|
|
||||||
Haskell runtime system for evaluation. Of course individual blc programs running
|
|
||||||
under the interpreter perform much worse than that same program written in Haskell.</p>
|
|
||||||
|
|
||||||
<p>Our interpreter copes well with extra levels of interpretation:</p>
|
|
||||||
|
|
||||||
<pre><code> time cat primes.blc | ./tromp -b | head -c 210 > /dev/null
|
|
||||||
real 0m0.043s
|
|
||||||
time cat uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
|
||||||
real 0m0.191s
|
|
||||||
time cat uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
|
||||||
real 0m1.919s
|
|
||||||
time cat uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
|
||||||
real 0m23.514s
|
|
||||||
time cat uni.blc uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
|
||||||
real 4m52.700s
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>Obfuscation</h1>
|
|
||||||
|
|
||||||
<p>Obfuscation is due entirely to conciseness. Some questions to ponder:</p>
|
|
||||||
|
|
||||||
<p>Which of the term space codes 0,1,2,3 serves multiple purposes?</p>
|
|
||||||
|
|
||||||
<p>Why is the environment pointer pointing into the term space?</p>
|
|
||||||
|
|
||||||
<p>What does the test u+m&1? do?</p>
|
|
||||||
|
|
||||||
<p>How does the program reach exit code 0?</p>
|
|
||||||
|
|
||||||
<p>And how do any of those blc programs work?</p>
|
|
||||||
|
|
||||||
<h1>Portability</h1>
|
|
||||||
|
|
||||||
<p>The program freely (without casting) converts between int and int*, causing
|
|
||||||
many warnings;
|
|
||||||
note: expected ‘int *’ but argument is of type ‘int’
|
|
||||||
warning: assignment from incompatible pointer type
|
|
||||||
warning: assignment makes integer from pointer without a cast
|
|
||||||
warning: assignment makes pointer from integer without a cast
|
|
||||||
warning: incompatible implicit declaration of built-in function ‘calloc’
|
|
||||||
warning: incompatible implicit declaration of built-in function ‘exit’
|
|
||||||
warning: passing argument 1 of ‘d’ makes pointer from integer without a cast
|
|
||||||
warning: passing argument 1 of ‘p’ makes pointer from integer without a cast
|
|
||||||
warning: pointer/integer type mismatch in conditional expression</p>
|
|
||||||
|
|
||||||
<p>Avoiding these would make the program substantially longer,
|
|
||||||
and detract from its single minded focus on conciseness.</p>
|
|
||||||
|
|
||||||
<p>It implicitly declares functions read, write, exit and calloc, the latter two incompatibly.
|
|
||||||
32 bit and 64 bit executables are separate Makefile targets, involving a change
|
|
||||||
from int to long and from a hardcoded sizeof of 4 to 8.</p>
|
|
||||||
|
|
||||||
<p>The program has been tested to work correctly on Linux/Solaris/MacOSX both in 32 and 64 bits.</p>
|
|
||||||
|
|
||||||
<h1>How the program works</h1>
|
|
||||||
|
|
||||||
<p>See the file how13.</p>
|
|
||||||
|
|
||||||
<h1>Acknowledgements</h1>
|
|
||||||
|
|
||||||
<p>Christopher Hendrie, Bertram Felgenhauer, Alex Stangl, Seong-hoon Kang,
|
|
||||||
and Yusuke Endoh have contributed ideas and suggestions for improvement.</p>
|
|
||||||
|
|
||||||
<h1>References</h1>
|
|
||||||
|
|
||||||
<p>Binary Lambda Calculus
|
|
||||||
<a href="https://tromp.github.io/cl/Binary_lambda_calculus.html">https://tromp.github.io/cl/Binary_lambda_calculus.html</a></p>
|
|
||||||
|
|
||||||
<p>G J Chaitin, Algorithmic information theory, Volume I,
|
|
||||||
Cambridge Tracts in Theoretical Computer Science, Cambridge University Press, October 1987.
|
|
||||||
<a href="http://www.cs.auckland.ac.nz/~chaitin/cup.html">http://www.cs.auckland.ac.nz/~chaitin/cup.html</a></p>
|
|
||||||
|
|
||||||
<p>Jean-Louis Krivine. 2007.
|
|
||||||
A call-by-name lambda-calculus machine
|
|
||||||
Higher Order Symbol. Comput. 20, 3 (September 2007), 199-207.
|
|
||||||
<a href="http://www.pps.univ-paris-diderot.fr/~krivine/articles/lazymach.pdf">http://www.pps.univ-paris-diderot.fr/~krivine/articles/lazymach.pdf</a></p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best use of cocoa - Bronze award</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best use of cocoa - Bronze award</h1>
|
|
||||||
|
|
||||||
<p>Daniel Vik<br>
|
|
||||||
<a href="mailto:daniel@vik.cc">daniel@vik.cc</a><br>
|
|
||||||
<a href="http://danielvik.com/">http://danielvik.com/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make vik
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This entry requires <a href="http://www.zlib.net/">Zlib</a>.</p>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<h4>Embed text (from file or command line):</h4>
|
|
||||||
|
|
||||||
<pre><code>./vik e base.png filename > encodedimg.png
|
|
||||||
# or
|
|
||||||
./vik e base.png SomeRandomText > encodedimg.png
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h4>Extract the embedded text:</h4>
|
|
||||||
|
|
||||||
<pre><code>./vik d encodedimg.png
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h4>Embed a PNG into another</h4>
|
|
||||||
|
|
||||||
<pre><code>./vik e base.png source.png > encodedimg.png
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h4>Extract the embedded PNG:</h4>
|
|
||||||
|
|
||||||
<pre><code>./vik d encodedimg.png > restored.png
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./vik e ioccc.png chocolate.png > chocolate-in-ioccc.png
|
|
||||||
./vik e chocolate.png ioccc.png > ioccc-in-chocolate.png
|
|
||||||
./vik d chocolate-in-ioccc.png > restored-chocolate.png
|
|
||||||
./vik d ioccc-in-chocolate.png > restored-ioccc.png
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>References to chocolate had no effect on judging this entry. We
|
|
||||||
guarantee it.</p>
|
|
||||||
|
|
||||||
<p>Can you discern hidden pieces of chocolate in chocolate-in-ioccc.png ?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>Introduction</h2>
|
|
||||||
|
|
||||||
<p>This program is a steganography application for embedding an image or text
|
|
||||||
into another image as well as extracting the embedded image or text back.
|
|
||||||
The program stores the embedded image or text in the low bits of the RGB
|
|
||||||
values.</p>
|
|
||||||
|
|
||||||
<p>The program supports any 8 bit true color PNG images (RGB, RGBA, grayscale,
|
|
||||||
and grayscale+alpha). The output image is always 8 bit RGB. When embedding
|
|
||||||
one image into another, the width and height needs to be the same.</p>
|
|
||||||
|
|
||||||
<p>The program only updates the IDAT and IHDR chunks of the source image. Any
|
|
||||||
additional chunks are copied into the resulting image.</p>
|
|
||||||
|
|
||||||
<h3>Bonus Extractor:</h3>
|
|
||||||
|
|
||||||
<p>For some reason the chocolate image seems to have some special properties.
|
|
||||||
Apart from being quite big and a little bit noisy, it appears that when
|
|
||||||
embedded into another image and extracted, the bitmap data is also a valid
|
|
||||||
brain$#@$ program. It is of course possible to get the bitmap data from the
|
|
||||||
extracted image, and run it through any of the previous winning brain$#@$
|
|
||||||
interpreters, but I thought it would be easier to include an interpreter in
|
|
||||||
the program to avoid the hassle:</p>
|
|
||||||
|
|
||||||
<pre><code>./vik e ioccc.png chocolate.png > encodedimg.png
|
|
||||||
./vik b encodedimg.png
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>It is of course also possible to embed a brain$#@$ program as a text file
|
|
||||||
(as explained above) and decode it, e.g.:</p>
|
|
||||||
|
|
||||||
<pre><code>./vik e ioccc.png .+[.+] > encodedimg.png
|
|
||||||
./vik b encodedimg.png
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Obfuscation</h3>
|
|
||||||
|
|
||||||
<p>I really wanted to keep the program simple, so instead of adding multiple
|
|
||||||
macros or helper methods that can be confusing, I placed all functionality
|
|
||||||
in the main function. Main is called recursively and quite extensively, but
|
|
||||||
it gives the benefit that all invocations of the function has the same
|
|
||||||
parameters, argv and argc. This really helps readability, as a programmer
|
|
||||||
doesn’t need to remember several variable or function names. I also tried
|
|
||||||
to reduce the number of keywords, and the program only has four for-loops
|
|
||||||
followed by a single return statement. There is a little bit of use of the
|
|
||||||
question mark operator, but this is really there to keep the program as
|
|
||||||
simple as possible.</p>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>The program is portable to most platforms that have zlib available. The
|
|
||||||
only system dependency is that the program relies on writing binary data to
|
|
||||||
stdout.</p>
|
|
||||||
|
|
||||||
<p>By default, Microsoft compilers adds carriage returns to new lines, and to
|
|
||||||
compile the program on this platform, the following line can be added after
|
|
||||||
the variable declarations in the main declaration in order to run
|
|
||||||
correctly:</p>
|
|
||||||
|
|
||||||
<pre><code>_setmode(_fileno(stdout), 0x8000);
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Limitations</h3>
|
|
||||||
|
|
||||||
<p>The program doesn’t have many error checks so passing in invalid arguments
|
|
||||||
or images of mismatching sizes, or unsupported pixel formats will cause the
|
|
||||||
program to crash.</p>
|
|
||||||
|
|
||||||
<h3>Extendability</h3>
|
|
||||||
|
|
||||||
<p>Since a lot of care was taken to keep the code simple, it turned out to be
|
|
||||||
quite easy to extend functionality. I did include a small brain$#@$ after I
|
|
||||||
realized that the chocolate image had some interesting properties.</p>
|
|
||||||
|
|
||||||
<p>But there is more functionality I added that didn’t fit within the size
|
|
||||||
limits and could not remain included. For example, I added a method to
|
|
||||||
format source code based on a PNG image. So the format of the program is
|
|
||||||
actually done by the program itself.</p>
|
|
||||||
|
|
||||||
<p>And to be honest, the chocolate image did not have a brain$#@$ program
|
|
||||||
embedded to begin with. I added functionality to the program to embed a
|
|
||||||
brain$#@$ into a PNG image and used it to create the image provided with
|
|
||||||
the entry.</p>
|
|
||||||
|
|
||||||
<p>I also added a method to analyze PNG images, to print the size and format,
|
|
||||||
as well as the scan line filters.</p>
|
|
||||||
|
|
||||||
<p>All these features were quite easy to add, much thanks to the (actually
|
|
||||||
pretty good) design of the code.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Balanced use of obfuscation - Gold award</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Balanced use of obfuscation - Gold award</h1>
|
|
||||||
|
|
||||||
<p>Adar Zeitak<br>
|
|
||||||
<a href="mailto:aa4z2@walla.co.il">aa4z2@walla.co.il</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make zeitak
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./zeitak < file.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>where file.c is the file to be checked for nesting errors. For example, you may
|
|
||||||
try incorrect.c and the program itself.</p>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./zeitak < zeitak.c
|
|
||||||
./zeitak < incorrect.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This is an extremely subtle and twisted piece of Gold award winning code!</p>
|
|
||||||
|
|
||||||
<p>The judges had spent a considerable amount of time analyzing this entry.
|
|
||||||
At one point we spent
|
|
||||||
<a href="https://twitter.com/ioccc/status/252162898800033792">18 minutes</a>
|
|
||||||
just to understand 18 key characters of this code.</p>
|
|
||||||
|
|
||||||
<p>The file zeitak_deobfucate.c provides a version that has been slightly
|
|
||||||
deobfuscated. You may find reading that file helpful in your attempt
|
|
||||||
to understand this extremely subtle entry.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Nesting Errors Detector</h3>
|
|
||||||
|
|
||||||
<h4>What does it do</h4>
|
|
||||||
|
|
||||||
<p>As you have probably understood by looking at the source*, this program has
|
|
||||||
something to do with parenthesis (and equality of opening and closing
|
|
||||||
parenthesis, if you look close enough). It goes over the file given to it and
|
|
||||||
checks that every opening (, [, or { has a matching closing one and
|
|
||||||
vice versa. It also checks that every “ or ‘ is closed.</p>
|
|
||||||
|
|
||||||
<p>If an error is detected, an error message will be printed. If the problem
|
|
||||||
is a superfluous closing bracket, it will even print a few characters
|
|
||||||
around it’s position.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Make sure you view the source with 4 spaces tab width.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Features</h4>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>Ignores parenthesis inside strings or character constants, so no errors
|
|
||||||
will be detected in the following line:</p>
|
|
||||||
|
|
||||||
<pre><code> printf(")");
|
|
||||||
</code></pre></li>
|
|
||||||
<li><p>Doesn’t get confused by the 1984/anonymous entry!</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Mis-Features</h4>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>Escapes (e.g. <code>\"</code>) are ignored, so the following line will produce
|
|
||||||
an error:</p>
|
|
||||||
|
|
||||||
<pre><code>printf("\"");
|
|
||||||
</code></pre></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Obfuscation</h4>
|
|
||||||
|
|
||||||
<p>IOCCC winners already contain entries without digits, control-flow
|
|
||||||
keywords and certain operators in their source. This entry has an
|
|
||||||
even more limited source, that is:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Without any digits.</li>
|
|
||||||
<li>Without any character constants.</li>
|
|
||||||
<li>Without using functions from headers other than stdio.</li>
|
|
||||||
<li>Without any control-flow keywords (not even the ?: operator).</li>
|
|
||||||
<li>Without any arithmetic or logic operators!</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>So, what’s left? Parenthesis, and lots of them, as looking at the source will
|
|
||||||
reveal immediately. The main obfuscation is building the whole algorithm using
|
|
||||||
only function calls, typecasts, array lookups and pointer operators.</p>
|
|
||||||
|
|
||||||
<p>Additional obfuscations include:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Extensive reuse of identifiers: Macros share names with variables, inner
|
|
||||||
curly braces scopes contain variables with names identical to those in the
|
|
||||||
outer scopes and some of the variables have different uses in different
|
|
||||||
parts of the program. Even the large array has more than one use.</li>
|
|
||||||
<li>A complicated data structure with “unused” fields.</li>
|
|
||||||
<li>Mostly one-letter identifiers.</li>
|
|
||||||
<li>Complex recursion: A function might call itself once, twice, or not at all.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Compilation/Running Notes</h4>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>The program requires <code>char</code> to be one byte and pointers to be
|
|
||||||
at least two bytes long.</p></li>
|
|
||||||
<li><p>The program was tested on the following platforms:</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p><strong> Ubuntu 9.04 32-bit with GCC
|
|
||||||
</strong> Windows 7 32-bit with GCC
|
|
||||||
** Windows 7 32-bit with OpenWatcom</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best painting tool</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best painting tool</h1>
|
|
||||||
|
|
||||||
<p>Michael Birken<br>
|
|
||||||
<a href="mailto:o__1@hotmail.com">o__1@hotmail.com</a><br>
|
|
||||||
<a href="http://www.meatfighter.com/">http://www.meatfighter.com/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make birken
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./birken < 17_columns_wide_paint_by_numbers_file
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./birken < examples/ioccc.txt
|
|
||||||
|
|
||||||
perl -e 'map{map{print int(rand()*8);}(0..16);print chr(10);}(0..30);' | tr '[0-4]' ' '| ./birken
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This program also wins the “Most amusing abuse of the iocccsize tool” award; although not the
|
|
||||||
absolute best: it is possible to achieve 0 by writing</p>
|
|
||||||
|
|
||||||
<pre><code>/* *\
|
|
||||||
/....
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The game of Tetris had been used in many endeavors, from studying <a href="http://arxiv.org/abs/cs/0210020">algorithmic complexity</a> to <a href="http://www.livescience.com/19894-tetris-treat-ptsd-flashbacks.html">treating PTSD</a>.
|
|
||||||
Using it for painting by numbers looks like a novel idea.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>About This Document</h3>
|
|
||||||
|
|
||||||
<p>This document is best viewed as an HTML file in a browser that supports animated gifs. Extract <code>examples.tbz2</code> for the sample input files.</p>
|
|
||||||
|
|
||||||
<pre><code>tar -xjvf examples.tbz2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Abstract</h3>
|
|
||||||
|
|
||||||
<p>By rotating, positioning and dropping a predetermined sequence of pieces, this program exploits the mechanics of Tetris to generate arbitrary images.</p>
|
|
||||||
|
|
||||||
<h3>Algorithm Overview</h3>
|
|
||||||
|
|
||||||
<p>The algorithm converts pixels from a source image into squares in the Tetris playfield, one row at a time from the bottom up. To generate an individual square, the algorithm assembles a structure consisting of a rectangular region fully supported by a single square protruding from the bottom. When the rectangular region is completed, its rows are cleared, leaving behind the protruding square. Three examples of the process appear below.</p>
|
|
||||||
|
|
||||||
<p><img src="pen0.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p><img src="pen1.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p><img src="pen2.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>During construction of a row, all of the squares produced by this method must be supported. In the images above, the generated squares are supported by the floor of the playfield. However, if an arbitrary row contains holes, it may not provide the support necessary for the construction of the row above it. The algorithm solves this problem by constructing a flat platform on top of the row with holes. In the animation below, a platform is built above a row comprising of a single red square. The platform is a temporary structure and inserting the final piece removes it.</p>
|
|
||||||
|
|
||||||
<p><img src="platform0.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>Below, a row containing 5 red squares is deposited above a row containing 3 red squares. This is accomplished by building a flat platform on top of the lower row. The platform provides the support necessary to generate the 5 red squares. Finally, the platform is removed by inserting its final piece and the new row drops into place. Note, if the algorithm needed to generate the rows in the opposite order (a row of 3 red squares above a row of 5 red squares), a platform would not be necessary.</p>
|
|
||||||
|
|
||||||
<p><img src="platform1.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<h3>Single Square Emitters</h3>
|
|
||||||
|
|
||||||
<p>For reference, the names of the 7 Tetriminos (the game pieces) appear in the table below.</p>
|
|
||||||
|
|
||||||
<p><img src="names.png" alt="" /></p>
|
|
||||||
|
|
||||||
<p>This algorithm was tailored specifically to render sprites from early video games. Those games packed graphics into 8×8 tiles where 2 bits were dedicated to each pixel. Consequentially, sprites usually contained only 3 colors plus transparent regions and they were typically sized either 16×16 or 16×32 pixels.</p>
|
|
||||||
|
|
||||||
<p>The animation below depicts all the patterns used to emit single squares. J, T and L Tetriminos are used interchangeably within each pattern to produce the protruding square at the bottom. The algorithm assigns those Tetriminos to the 3 colors present in the sprite. The remaining Tetriminos are assigned arbitrary colors. And, all the colors remain constant during gameplay.</p>
|
|
||||||
|
|
||||||
<p><img src="pen4.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>It is not possible to emit a square of all 3 colors in the first 2 and the last 2 columns due to the shapes of the 3 Tetriminos. As a result, the minimal width of a playfield to accommodate a 16 pixel wide sprite is 2 + 16 + 2 = 20 squares. However, it turns out that 20 is too small.</p>
|
|
||||||
|
|
||||||
<p>As illustrated below, the region above the protruding square cannot exclusively consist of a single row because the only pieces that could fit, the I Tetriminos, are unsupported.</p>
|
|
||||||
|
|
||||||
<p><img src="pen5.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>With 2 rows, the only means of spanning the full playfield width in a way that remains supported is to use S and Z Tetriminos. But, that will always leave holes in the upper row.</p>
|
|
||||||
|
|
||||||
<p><img src="pen6.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>The minimal number of rows required above the protruding square is 3 and as shown repeatedly above, such patterns do exist. 20 squares is the minimal width required to fit a 16 pixel wide sprite. But, 20 × 3 + 1 = 61, which is not divisible by 4 and hence not constructible out of Tetriminos. However, a width of 21 yields 21 × 3 + 1 = 64, which can be built with 16 Tetriminos. That width actually enables the algorithm to render sprites up to 17 pixels wide.</p>
|
|
||||||
|
|
||||||
<p>The original Tetris playfield is 10×20 squares, a 1:2 ratio. The program maintains that ratio by using a playfield of 21×42 squares.</p>
|
|
||||||
|
|
||||||
<p>Since J, T and L Tetriminos are used interchangeably to produce the emitted square and 3 squares of those Tetriminos contribute to the row above it, there are 21 − 3 + 1 = 19 single square emitting patterns. However, due to mirror symmetry, there are really only 10 patterns. Clearing 3 rows works for the majority of them. But, an exhaustive computer search revealed that 2 of the patterns require more. The next possible option is 7 rows since 21 × 7 + 1 = 148, requiring 37 Tetriminos. As the images below show, those patterns do exist.</p>
|
|
||||||
|
|
||||||
<p><img src="pen7.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p><img src="pen8.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<h3>Platforms</h3>
|
|
||||||
|
|
||||||
<p>Before a row is constructed, the algorithm inspects the row below it. If the row below fails to provide support for all of the squares to be deposited above it, then a temporary platform is required. When that platform is removed, the new row will drop, leaving some of the squares apparently floating above empty space due to the way that gravity works in the original Tetris.</p>
|
|
||||||
|
|
||||||
<p>The illustration below depicts the 10 platform patterns (really only 5 considering mirror symmetry). The construction of a platform begins by dropping a T Tetrimino on top one of the squares of the last generated row. The remaining Tetriminos support each other down to that first T. Meaning, as long as the previously generated row contains at least 1 square, like the red square below, then it is possible to construct a flat platform above it for the generation of the next row.</p>
|
|
||||||
|
|
||||||
<p><img src="platform2.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>In the middle of platform construction, the bottom row gets completed and cleared, leaving 3 rows above it. The final J or L Tetrimino that will remove those rows is not inserted until the square emitters are done generating the next row of the sprite on top of the platform. That final piece precludes square emission in the first and last 2 columns. But, as discussed above, the square emitters are limited to the 17 inner columns due to the geometry of the J, T and L Tetriminos used in the process.</p>
|
|
||||||
|
|
||||||
<p>Also, of the 19 possible ways to start constructing a platform on top of a T Tetrimino, only the 10 patterns shown above exist.</p>
|
|
||||||
|
|
||||||
<h3>Program Input</h3>
|
|
||||||
|
|
||||||
<p>The input sprite is represented textually. Digit characters <code>0</code> to <code>7</code> correspond to pixels with colors from the palette below.</p>
|
|
||||||
|
|
||||||
<p><img src="palette.png" alt="ANSI color palette" /></p>
|
|
||||||
|
|
||||||
<p>As discussed above, sprites are limited to a maximum of 3 colors from this palette.</p>
|
|
||||||
|
|
||||||
<p>All other characters are interpreted as transparent pixels.</p>
|
|
||||||
|
|
||||||
<p>The maximum permissible size of the input text is 32 rows by 17 columns. Row length can vary as long as no single row exceeds 17 characters.</p>
|
|
||||||
|
|
||||||
<p>Every row must contain at least one palette digit character.</p>
|
|
||||||
|
|
||||||
<p>The <code>examples</code> directory contains several sprites in this textual format that can be fed into standard input. Several examples take advantage of the Tetris playfield background color. Instead of using character <code>0</code>, internal regions marked as transparent are effectively rendered as black.</p>
|
|
||||||
|
|
||||||
<h3>Program Output</h3>
|
|
||||||
|
|
||||||
<p>The program conceptually uses Tetris as an output device similar to a line printer. It restricts itself to those operations that can be performed on the Tetris playfield: spawning, rotating, positioning and dropping Tetriminos. This process is visually represented using ANSI escape sequences.</p>
|
|
||||||
|
|
||||||
<h3>ANSImation</h3>
|
|
||||||
|
|
||||||
<p>The rate at which the program plays Tetris is completely determined by the rate in which the terminal application receives and displays the ANSI escape sequences.</p>
|
|
||||||
|
|
||||||
<p>To slowdown the output programmatically, introduce a delay immediately after the call to <code>fflush</code>.</p>
|
|
||||||
|
|
||||||
<h3>IOCCC Size Tool Bug</h3>
|
|
||||||
|
|
||||||
<p>This program demonstrates how to exploit a bug in IOCCC size tool version 2013-07-30-v17. The first line of the program is reproduced below.</p>
|
|
||||||
|
|
||||||
<pre><code>char*_ = "'""/*";
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>If that line is added to the top of any program, the tool will report a size of 8.</p>
|
|
||||||
|
|
||||||
<pre><code>./iocccsize -i < prog.c
|
|
||||||
8
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>When that line is deleted from this program, the tool properly reports the secondary size limit of the program as 2048.</p>
|
|
||||||
|
|
||||||
<pre><code>./iocccsize -i < prog.c
|
|
||||||
2048
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Although this bug provides an easy means of circumventing contest rule 2, as demonstrated from the size value, this entry is not necessarily striving for a ‘worst abuse of the rules’ award.</p>
|
|
||||||
|
|
||||||
<h3>Obfuscations</h3>
|
|
||||||
|
|
||||||
<p>This program is almost, but not quite, entirely unlike a demonstration of good programming practices. Contrary to other programs, an inspection of this one will certainly reveal that it possesses tea, not to mention an affinity for the constant 42.</p>
|
|
||||||
|
|
||||||
<p>Variables are named and ordered to spell out, “Tetris”, “ELORG”, “DVK” and the aforementioned “Tea”. ELORG is the abbreviation for Elektronorgtechnica, the former Soviet state owned computer organization that handled the worldwide Tetris intellectual property rights. DVK is the line of Soviet PDP-11-compatible personal computers capable of running Alexey Pajitnov’s original 1984 Tetris prototype.</p>
|
|
||||||
|
|
||||||
<p>Carefully selected variable names also yielded wonderful expressions like <code>l=0</code>, <code>O=0</code>, <code>O=1</code> and <code>while(O)</code>. “Tetris” also makes a second appearance of sorts:</p>
|
|
||||||
|
|
||||||
<pre><code>[T][e][t]--; while(R+i) { s
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The source is formatted to resemble the Tetris playfield midgame. It is also an homage to all the past IOCCC entries formatted as a compact block of text; the T, orientated appropriately to reflect its name and the first letter in the title of the game, is just a moment away from producing such a text block.</p>
|
|
||||||
|
|
||||||
<p>Three tables are encoded as separate strings within the program:</p>
|
|
||||||
|
|
||||||
<p>The first string stores the coordinates of the squares of the 19 distinct rotations of Tetriminos (see below). Since a Tetrimino is a chain of 4 squares, all Tetriminos fit within a 4×4 matrix. To determine the coordinates of the squares, the Tetrimino is pushed to the upper-left of the matrix. Each coordinate value requires 2 bits of storage. Consequentially, the four x-coordinates and the four y-coordinates were packed into separate octets. To convert the octets into valid ASCII characters, the squares were sorted such that the least significant bits stored the largest coordinate values. The results were offset by 35, the <code>#</code> character, which is 1 beyond the ASCII value of <code>"</code>, making it easier to pack into a string. None of the resultant values are beyond ASCII 127. The coordinates for all 19 rotations fit in a string of length 38.</p>
|
|
||||||
|
|
||||||
<p><img src="rotations.png" alt="" /></p>
|
|
||||||
|
|
||||||
<p>The second string stores the single square emitter patterns and the platform patterns. Each pattern is a sequence of pairs, { Tetrimino index, drop x-coordinate }. As mentioned, there are 19 distinct rotations, requiring 5 bits of storage for the Tetrimino index. Another 5 bits is required for the drop x-coordinate since there are 21 columns in the playfield. Necessarily, the pair is stored as 2 separate characters. By offsetting them by 40, the <code>(</code> character, the resultant string almost resembles a long and complex mathematical expression. The program takes advantage of mirror symmetry by only storing 10 single square emitter patterns and 5 platform patterns. The pattern lengths are not encoded within the string. Rather, they are embedded within the string decoding logic.</p>
|
|
||||||
|
|
||||||
<p>The third string conceptually stores the default colors of the 19 rotations. A 3-bit value is assigned to each, covering the 7 possible colors. In addition, when a mirrored pattern is executed, J exchanges with L and S exchanges with Z, necessitating a second list of 3-bit color values. Pairs of color values (6 bits) fit comfortably into a character that is offset by <code>#</code>. The result is a string of length 19.</p>
|
|
||||||
|
|
||||||
<p>The program is full of subtle obfuscations:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>The unary decrement operator is used in conjunction with global variable automatic zero initialization to set variables to <code>-1</code>.</p></li>
|
|
||||||
<li><p>The boolean expression of the form, <code>x + 1</code>, is used multiple times to determine if a value is not <code>-1</code>. Similarly, expressions of the form <code>x - y</code> are used to determine if <code>x != y</code>.</p></li>
|
|
||||||
<li><p>Several arrays store unrelated data in segments throughout the array to reduce named variables.</p></li>
|
|
||||||
<li><p>The <code>x["..."]</code> trick appears once.</p></li>
|
|
||||||
<li><p>Variable <code>i</code> is less than necessary.</p></li>
|
|
||||||
<li><p>A cursorily glance at the expressions <code>4&&L</code> and <code>m&&e==m</code> suggests that they always evaluate to true.</p></li>
|
|
||||||
<li><p>The varying single square emitter pattern lengths are resolved during string decoding using the clever expression, <code>(i & 3) - 3</code>, which identifies pattern 3 and 7 as longer.</p></li>
|
|
||||||
<li><p>The file size of <code>prog.c</code> is a prime number. Deleting the first line also produces a prime-sized program. These properties do not qualify the program as a prime number generator.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Beyond Obfuscation</h3>
|
|
||||||
|
|
||||||
<p>Due to the contest code size constraint, some optimizations reluctantly had to be omitted. For example, multi-square emitters are possible:</p>
|
|
||||||
|
|
||||||
<p><img src="multi2.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p><img src="multi3.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p><img src="multi4.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p><img src="multi5.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>In fact, using dynamic programming and creative heuristics, real-time search is possible, enabling patterns like this:</p>
|
|
||||||
|
|
||||||
<p><img src="triple0.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>And, even this:</p>
|
|
||||||
|
|
||||||
<p><img src="triple1.gif" alt="" /></p>
|
|
||||||
|
|
||||||
<p>In addition, it is possible to extend the algorithm to 6 colors instead of just 3. This is achieved using I, S and Z to produce the protruding square. A series of rectangular regions are constructed above those Tetriminos to erode them down to a single emitted square.</p>
|
|
||||||
|
|
||||||
<p>The details of these enhancements are left as an exercise to the reader.</p>
|
|
||||||
|
|
||||||
<h3>Example Files</h3>
|
|
||||||
|
|
||||||
<p>The following example files were created by the program author. They can be freely used and distributed.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>format.txt</code> - The layout of the program</li>
|
|
||||||
<li><code>helloworld.txt</code> - Hello World, Tetris-style</li>
|
|
||||||
<li><code>hilbert.txt</code> - A graphic based on the Hilbert curve</li>
|
|
||||||
<li><code>ioccc.txt</code> - IOCCC</li>
|
|
||||||
<li><code>landon.txt</code> - Portrait of a man with glasses</li>
|
|
||||||
<li><code>leo.txt</code> - Portrait of a man without glasses</li>
|
|
||||||
<li><code>rhino.txt</code> - A purple rhinoceros</li>
|
|
||||||
<li><code>simon.txt</code> - Portrait of a man without hair</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The following files are based on graphics from non-free, copyrighted video games. The use of a limited number of textual representations of the graphics for the demonstration of this program qualifies as fair use as such files do not significantly impede the right of the copyright holder to sell the copyrighted material and it is not being used to generate profit in this context. The origin of each file is detailed below (character, game, company, year).</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>belmont.txt</code> - Simon Belmont, Castlevania, Konami, 1986</li>
|
|
||||||
<li><code>bloober.txt</code> - Bloober, Super Mario Brothers, Nintendo, 1985</li>
|
|
||||||
<li><code>bomberman.txt</code> - Bomberman, Bomberman, Hudson, 1983</li>
|
|
||||||
<li><code>boo.txt</code> - Boo, Super Mario Brothers 3, Nintendo, 1988</li>
|
|
||||||
<li><code>bub.txt</code> - Bub, Bubble Bobble, Taito, 1986</li>
|
|
||||||
<li><code>cheepcheep.txt</code> - Cheep Cheep, Super Mario Brothers, Nintendo, 1985</li>
|
|
||||||
<li><code>gurin.txt</code> - Gurin, Binary Land, Hudson, 1983</li>
|
|
||||||
<li><code>koopaparatroopa.txt</code> - Koopa Paratroopa, Super Mario Brothers, Nintendo, 1985</li>
|
|
||||||
<li><code>lakitu.txt</code> - Lakitu, Super Mario Brothers, Nintendo, 1985</li>
|
|
||||||
<li><code>mario.txt</code> - Fire Mario, Super Mario Brothers, Nintendo, 1985</li>
|
|
||||||
<li><code>mspacman.txt</code> - Ms. Pac-Man and Ghost, Ms. Pac-Man, Midway, 1982</li>
|
|
||||||
<li><code>paranaplant.txt</code> - Piranha Plant, Super Mario Brothers, Nintendo, 1985</li>
|
|
||||||
<li><code>samus.txt</code> - Samus Aran, Metroid, Nintendo/Intelligent Systems, 1986</li>
|
|
||||||
<li><code>toad.txt</code> - Toad, Super Mario Brothers 2, Nintendo, 1987</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The origin of the remaining files are described below:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>happyface.txt</code> - Based on a smiley; rights unknown</li>
|
|
||||||
<li><code>snoo.txt</code> - 8-bit version of Snoo, Reddit’s alien mascot</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most partisan 1-liner</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most partisan 1-liner</h1>
|
|
||||||
|
|
||||||
<p>Adrian Cable<br>
|
|
||||||
<a href="mailto:adrian.cable@gmail.com">adrian.cable@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make cable1
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./cable1 name group1 group2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./cable1 obama republican democrat
|
|
||||||
./cable1 nixon republican democrat
|
|
||||||
./cable1 bush republican democrat
|
|
||||||
./cable1 kennedy republican democrat
|
|
||||||
./cable1 lincoln republican democrat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Partisan may be defined as a strong supporter of a cause, party or person.
|
|
||||||
We need not limit ourselves to the two major political parties in the US today.</p>
|
|
||||||
|
|
||||||
<p>Let us consider:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable1 Cooper Mac PC
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Simon works for Apple, so would would expect Mac. :-)
|
|
||||||
Landon is a long time Mac user:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable1 Noll Mac PC
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>That works too!. Now Leo brings PCs to the IOCCC judging for cross-platform
|
|
||||||
testing:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable1 Broukhis Mac PC
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>We can test other people. The late Steve Jobs:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable1 Jobs Mac PC
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>That works! How about Bill?</p>
|
|
||||||
|
|
||||||
<pre><code>./cable1 Gates Mac PC
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>A PC guy as expected. What about that other Steve?</p>
|
|
||||||
|
|
||||||
<pre><code>./cable1 Ballmer Mac PC
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Humm .. maybe there is a hidden reason he is leaving the late Micro$oft? :-)
|
|
||||||
Why late? See <a href="https://twitter.com/landonnoll/status/401582967123742720">this tweet</a>.</p>
|
|
||||||
|
|
||||||
<p>So how does a one line C source know so much? Hint: it doesn’t.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Presidents of the United States of America!</h1>
|
|
||||||
|
|
||||||
<p>Politics is full of memorable one-liners. Without wishing to misunderestimate the taste of the judges, nor prejudge the past, the author hopes you enjoy this contribution to the genre.</p>
|
|
||||||
|
|
||||||
<p>This one-line C program accepts as a first command-line argument the last name of any of the last 31 US Presidents (from Franklin Pierce onwards), in lower case, and prints out their political affiliation.</p>
|
|
||||||
|
|
||||||
<p>Use “republican” as the 2nd command-line argument, and “democrat” as the 3rd (or equivalent strings of your choice).</p>
|
|
||||||
|
|
||||||
<h2>Why is this entry obfuscated/interesting?</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The program looks up the name supplied on the command line against a list of Presidents' names, and matches names to political affiliations using a look-up table. But where in the source is the list of names, and where is the look-up table?</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Notes</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>For Theodore Roosevelt, use: ./cable1 roosevelt republican democrat</li>
|
|
||||||
<li>But, for Franklin D Roosevelt, use: ./cable1 fdr republican democrat</li>
|
|
||||||
<li>This program needs a little endian CPU to work properly.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Compiler warnings</h2>
|
|
||||||
|
|
||||||
<p>clang warns about a missing type specifier for main, and that implicit function declarations are invalid in C99 (but still accepts them).</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best of show</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best of show</h1>
|
|
||||||
|
|
||||||
<p>Adrian Cable<br>
|
|
||||||
<a href="mailto:adrian.cable@gmail.com">adrian.cable@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make cable2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./cable2 file.bmp [color]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<p>Extract example-images.tbz2:</p>
|
|
||||||
|
|
||||||
<pre><code>make data
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Here is an OCR example that shows all 94 supported ASCII characters:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable2 ascii.bmp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Here is an example of colored ASCII:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable2 multi_color.bmp color
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Here is an example using different character sizes and different
|
|
||||||
positions in the same file:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable2 mixed_sizes.bmp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>How about about hand-written C code:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable2 hello_world.bmp | gcc -xc -o hello -
|
|
||||||
./hello
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Sometimes typeset text will work, if the typeset has characters that
|
|
||||||
are enough to the supported handwritten shapes. For example,
|
|
||||||
Menlo, 160 pt:</p>
|
|
||||||
|
|
||||||
<pre><code>./cable2 typeset.bmp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>And as an added IOCCC bonus: :-)</p>
|
|
||||||
|
|
||||||
<pre><code>./cable2 bonus.bmp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>We can confirm that this is the first time the IOCCC has been used
|
|
||||||
to peer-review a new research. We had quite a bit of fun with a sharpie and a
|
|
||||||
scanner.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>OCR - Obfuscated Character Recognition of Handwritten Text</h1>
|
|
||||||
|
|
||||||
<p>This entry takes a BMP image file of hand-drawn (mouse-drawn?) text, specified as the first command-line parameter, and converts it to an ASCII text document. Magic!</p>
|
|
||||||
|
|
||||||
<p>BMP files created by most paint programs should work. The author recommends Paint.NET.</p>
|
|
||||||
|
|
||||||
<h2>Features</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Every printable ASCII character is recognized (94 characters plus space), plus a special bonus character.</li>
|
|
||||||
<li>Input images can be any size (limited only by memory), containing any number of lines of text.</li>
|
|
||||||
<li>BMP is really a mess of different formats, but the program supports most of them from Windows 3.1 and later.</li>
|
|
||||||
<li>Hand-drawn characters in the input image can be variably spaced and positioned and be of any width or height, but the bigger the better for accurate recognition (300 pixels tall or more is recommended). Characters must be drawn with a stroke width of around 9 pixels, and separated from adjacent characters. (In Paint.NET a brush of width 9 works well, with anti-aliasing turned off.)</li>
|
|
||||||
<li>You can use any colors you like for the text and background, even different colors for different text characters.</li>
|
|
||||||
<li>If “color” is specified as the second command line parameter, the program’s output will also be in color, on ANSI/VTxxx terminals.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Why is this entry obfuscated/interesting?</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The source is presented as a beautiful moonlit scene, in which a quick brown fox jumps over a lazy dog. Far too often in software development is aesthetic nuance lost in the name of serious-sounding conventions like “GNU style”, but not here.</li>
|
|
||||||
<li>Newcomers to C find it hard to learn all those different ways to control flow: for, while, if, do, goto, continue, break and heaven knows what else! So, in this program we only use for, so absolute beginners can get into the code straight away.</li>
|
|
||||||
<li>To teach newcomers all the important features of C, we demonstrate the importance of the liberal use of short circuits, sequence points, the ternary operator, using x<sup>y</sup> or x-y instead of x!=y, using ~x in place of x!=-1 for conciseness, mixing x[y] and y[x] for variety, educational #define’s, and so on.</li>
|
|
||||||
<li>main is the most useful function in all of C - so it is a mystery to the author why most programs use it only once. Here we use it over and over for maximum benefit.</li>
|
|
||||||
<li>The number 42 is featured in the source to provide an answer to the judges' deeper questions.</li>
|
|
||||||
<li>How are character colors converted from RGB in the input image to ANSI escape sequences? Clue: the weird macro P does the interesting part of it, but how?</li>
|
|
||||||
<li>The program prints a string when the bonus character is detected. How does it do this? Clue: the string to print is defined in the macro $, but how can a string defined in that way ever get printed?</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Other notes</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The novel character recognition algorithm used has not been previously published and was developed by the author specifically for the contest. Should this entry win the IOCCC, it will be the first time (to the author’s knowledge) that the IOCCC has been used for peer review/publication of original research.</li>
|
|
||||||
<li>OCR in general is a hard problem. Here, we only recognise one possible form for each character. You can see what the supported character shapes look like by looking at the examples in ascii.bmp. If you copy the shape of the character forms you find in there, recognition accuracy should be very good (95%+). A more “useful” version would extend the character stroke table to support multiple different commonly-used forms for each character.</li>
|
|
||||||
<li>Despite being the largest possible IOCCC entry at 4096 bytes, it is also probably the smallest general-purpose OCR program ever written (including the character stroke data), maybe by several orders of magnitude.</li>
|
|
||||||
<li>The author used an interesting compression algorithm (suggested by Gareth McCaughan - thank you!) to squeeze the character stroke table (containing around 2000 strokes for the whole ASCII character set) into a string constant of just 472 characters.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Bugs/features</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The width of input images must be a multiple of 4.</li>
|
|
||||||
<li>Input images can be 8-bit grayscale, 24-bit color or 32-bit color only. 8-bit color and 16-bit color are not supported. If you use the “color” command-line feature, do not use a grayscale input file!</li>
|
|
||||||
<li>Normal Windows BMP files are stored “upside-down”, i.e. the bottom line in the image is written first. Some (old) graphics programs actually write BMP files “top-to-bottom” and the program does not support such files.</li>
|
|
||||||
<li>Using antialiased brush strokes to draw your letters is fine, however, antialiasing interferes with color detection in “color” mode.</li>
|
|
||||||
<li>Only runs on little endian machines (since the BMP format is little endian, and endianness conversion would make the source too large for IOCCC rule 2).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Compiler warnings</h2>
|
|
||||||
|
|
||||||
<p>clang warns about unused expression results, missing type specifiers, and incompatible pointer conversions - all just a fun consequence of the obfuscations.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,264 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Largest small system emulator</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Largest small system emulator</h1>
|
|
||||||
|
|
||||||
<p>Adrian Cable<br>
|
|
||||||
<a href="mailto:adrian.cable@gmail.com">adrian.cable@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make cable3
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./runme
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This entry weighs in at a magical 4043 bytes (8086 nibbles, 28,301
|
|
||||||
bits). It manages to implement most of the hardware in a 1980’s era
|
|
||||||
IBM-PC using a few hundred fewer bits than the total number of
|
|
||||||
transistors used to implement the original 8086 CPU.</p>
|
|
||||||
|
|
||||||
<p>If you are using OS X, the included sc-ioccc.terminal configuration file will
|
|
||||||
correctly display console applications that use ANSI graphics.</p>
|
|
||||||
|
|
||||||
<p>Update: This entry now has its own web page <a href="http://www.megalith.co.uk/8086tiny">http://www.megalith.co.uk/8086tiny</a></p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>A tiny but highly functional PC emulator/virtual machine</h1>
|
|
||||||
|
|
||||||
<p>The author hereby presents, for the delectation (?) of the judges, a portable PC emulator/VM written specifically for the IOCCC which runs DOS, Windows 3.0, Excel, MS Flight Simulator, AutoCAD, Lotus 1-2-3 …</p>
|
|
||||||
|
|
||||||
<p>In just 4043 bytes of C source, you get a complete mid-late 1980s-era IBM-compatible PC, consisting of:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Intel 8086/186 CPU</li>
|
|
||||||
<li>1MB RAM</li>
|
|
||||||
<li>8072A 3.5" floppy disk controller (1.44MB/720KB)</li>
|
|
||||||
<li>Fixed disk controller (supports a single hard drive up to 528MB)</li>
|
|
||||||
<li>Hercules graphics card with 720x348 2-color graphics (64KB video RAM), and CGA 80x25 16-color text mode support</li>
|
|
||||||
<li>8253 programmable interval timer (PIT)</li>
|
|
||||||
<li>8259 programmable interrupt controller (PIC)</li>
|
|
||||||
<li>8042 keyboard controller with 83-key XT-style keyboard</li>
|
|
||||||
<li>MC146818 real-time clock</li>
|
|
||||||
<li>PC speaker</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The emulator uses the SDL graphics library for portability, and compiles for Windows, Mac OS X, Linux and probably most other 32-bit/64-bit systems too.</p>
|
|
||||||
|
|
||||||
<p>If you like living on the edge you can try building the emulator on a big endian machine, and you will get an emulation of a big endian 8086, a rather bizarre and somewhat useless beast. For everyone else, please run the emulator on a little endian machine.</p>
|
|
||||||
|
|
||||||
<p><em>RULE 2 ABUSE DISCLAIMER</em></p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>cable3.c is 4043 bytes in length (half an 8086)</li>
|
|
||||||
<li>iocccsize -i < cable3.c returns 1977 (the year the 4.77 MHz 8086 CPU was announced)</li>
|
|
||||||
<li>Therefore, any suspicions the judges may have regarding rule 2 non-compliance may be well-intentioned but are groundless.</li>
|
|
||||||
<li>Nonetheless, the author would like to apologise to the judges for the one-big-block-of-code nature of this entry, which turned out to be unavoidable. Hopefully the joys of this entry will make up for its shortcomings.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p><em>/RULE 2 ABUSE DISCLAIMER</em></p>
|
|
||||||
|
|
||||||
<h2>Why is this entry obfuscated/interesting?</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>First of all the 8086 is a nightmare processor to emulate. Instruction codings are complex and irregular in size and structure, with multiple addressing modes and no consistent memory placement for operands, very often multiple possible encodings for the same instruction, and the bizarre segment:offset memory model. In addition, the 8086 has a number of bugs (e.g. PUSH SP), undocumented behaviours and instructions (e.g. AAM/AAD + imm8, SALC, flag behaviour for MUL/DIV, etc. etc.), and archaic features (e.g. parity/auxiliary flags) which all need to be emulated properly. Here we emulate every feature of the CPU pretty exactly (in fact better than most commercial clones of the processor e.g. the NEC V30), with the exception of the trap flag which no real software uses except for debuggers (although support for the TF can be added if deemed important, without exceeding the IOCCC size limit).</li>
|
|
||||||
<li>In addition to the CPU we also emulate all the standard PC peripheral hardware. Parts of it are somewhat complete, much is rather dysfunctional (like the 8253/8259) but enough to support most real software.</li>
|
|
||||||
<li>Nonetheless the source, while large for the IOCCC, is rather tiny for a functional PC emulator - around 2% of the size of the source of other open-source 8086 PC emulators with comparable functionality.</li>
|
|
||||||
<li>In fact, this entry is just like happy hour - at 4043 bytes long, you pay for half the 8086, but you get served the whole one.</li>
|
|
||||||
<li>Getting the code down to <= 4096 characters to meet the IOCCC rule 2 overall size limit required a good deal of effort (and appreciable risk of divorce), with obfuscation being a pretty unavoidable consequence in most places … for the rest, I use short circuit operators whenever possible, mix x[y] and y[x], don’t use any flow control keywords except for for, use K&R-style declarations to honor the C language’s rich cultural heritage (plus it saves a byte), and occasionally go overboard with nasty nested indexes to give things like this: –64[T=1[O=32[L=(X=*Y&7)&1,o=X/2&1,l]=0,t=(c=y)&7,a=c/8&7,Y]>>6,g=~-T?y:(n)y,d=BX=y,l]</li>
|
|
||||||
<li>This entry highlights the importance of comments in C.</li>
|
|
||||||
<li>This entry might result in an adjustment to the IOCCC size tool for the 2014 competition (see above).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Compiling on different platforms</h2>
|
|
||||||
|
|
||||||
<p>This entry has been tested on Windows (compiled with MS Visual Studio 2010 and 2013), Mac OS X (clang and gcc), and Linux (clang and gcc). The Makefile supplied is good for Mac OS X, Linux and probably other UNIXes. I have received reports that the emulator works on Raspberry Pi/Android/ARM (you will need to compile with -fsigned-char) and iOS. You will need to adjust the Makefile if your system lacks sdl-config to correctly point to the SDL libraries and header files.</p>
|
|
||||||
|
|
||||||
<p>On UNIX-based systems we can get raw keystrokes using stty. However Windows has no stty. Therefore the Makefile includes a -D entry to define a “keyboard driver” KB which as it stands is suitable for UNIXes, but maybe not non-UNIX platforms. For example, for Windows/MS Visual Studio, instead of the Makefile definition of KB, use something slightly different - add the following entry to the Preprocessor Definitions list in the Project Properties page:</p>
|
|
||||||
|
|
||||||
<pre><code>KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>POSIX portability note</h2>
|
|
||||||
|
|
||||||
<p>The code as supplied uses implicit function declarations for POSIX file I/O and in doing so assumes that file offsets are the same bit width as your architecture. For some systems (e.g. 32-bit Mac OS X, which uses 64-bit file offsets) this is not the case, and to run successfully on these systems, you will need to explicitly declare these functions by adding the appropriate include to the top of the source:</p>
|
|
||||||
|
|
||||||
<pre><code>#include <unistd.h>
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Usage</h2>
|
|
||||||
|
|
||||||
<pre><code>./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>PLEASE NOTE that under UNIXes the keyboard must be in raw mode for the emulator to work properly. Therefore the emulator is best run from a shell script that looks something like:</p>
|
|
||||||
|
|
||||||
<pre><code>stty cbreak raw -echo min 0
|
|
||||||
./cable3 bios floppy.img harddisk.img
|
|
||||||
stty cooked echo
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>To run the emulator - floppy mode only</h2>
|
|
||||||
|
|
||||||
<p>The simplest use of the emulator is with a single floppy boot disk image, like the fd.img provided, which is a FreeDOS boot disk.</p>
|
|
||||||
|
|
||||||
<p>Before running the emulator on a Unix-type system, stty needs to be used to put the keyboard into raw mode (and afterwards it needs to be put back to cooked). So, run the emulator using something like this script (provided as “runme”):</p>
|
|
||||||
|
|
||||||
<pre><code>stty cbreak raw -echo min 0
|
|
||||||
./cable3 bios fd.img
|
|
||||||
stty cooked echo
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>To run the emulator - floppy + HD mode</h2>
|
|
||||||
|
|
||||||
<p>Easiest to start with is to try a ready-made 40MB hard disk image containing a whole bunch of software:</p>
|
|
||||||
|
|
||||||
<p><a href="http://bitly.com/1bU8URK">http://bitly.com/1bU8URK</a></p>
|
|
||||||
|
|
||||||
<p>For the more adventurous, you can start off with (for example) a blank 40MB image file called hd.img made using e.g. mkfile. Then use:</p>
|
|
||||||
|
|
||||||
<pre><code>stty cbreak raw -echo min 0
|
|
||||||
./cable3 bios fd.img hd.img
|
|
||||||
stty cooked echo
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Preparing the hard disk for use in the emulator is done just like a real PC. Boot the emulator, and use FDISK to partition the hard disk. When it’s done FDISK will reboot the emulator. Then you can use FORMAT C: and you are done. The resulting disk image is in the right format to be mounted on a real Windows PC using e.g. OSFMount, on a Mac using hdiutil, or on Linux using mount, providing an easy way to copy files and programs to and from the disk image. Or, you can install programs from regular floppy disk images (see “Floppy disk support” below).</p>
|
|
||||||
|
|
||||||
<h2>Keyboard emulation</h2>
|
|
||||||
|
|
||||||
<p>The emulator simulates an XT-style keyboard controlled by an Intel 8042 chip on I/O port 0x60, generating IRQ1 and then interrupt 9 on each keypress. This is harder than it sounds because a real 8042 returns scan codes rather than the ASCII characters which the C standard I/O functions return. Rather than make the emulator less portable and use ioctl or platform-dependent equivalents to obtain real scan codes from the keyboard, the emulator BIOS does the reverse of a real PC BIOS and converts ASCII characters to scancodes, simulating press/release of the modifier keys (e.g. shift) as necessary to work like a “real” keyboard. The OS (DOS/Windows) then converts them back to ASCII characters and normally this process works seamlessly (although don’t be surprised if there are issues, for example, with non-QWERTY e.g. international keyboards).</p>
|
|
||||||
|
|
||||||
<p>Most of the time you can just type normally, but there are special sequences to get Alt+xxx and Fxxx.</p>
|
|
||||||
|
|
||||||
<p>To send an Alt+XXX key combination, press Ctrl+A then the key, so for example to type Alt+F, press Ctrl+A then F.</p>
|
|
||||||
|
|
||||||
<p>To send an Fxx key, press Ctrl+F then a number key. For example, to get the F4 key, press Ctrl+F then 4. To get F10, press Ctrl+F then 0.</p>
|
|
||||||
|
|
||||||
<p>To send a Page Down key, press Ctrl+F then O. To send a Page Up key, press Ctrl+F then E. Other key combinations are left for the discovery of the user.</p>
|
|
||||||
|
|
||||||
<h2>Text mode support</h2>
|
|
||||||
|
|
||||||
<p>The emulator supports both text output via the standard BIOS interrupt 0x10 interface, and also direct video memory access (one page, 4KB video RAM at segment B800) in 80x25 CGA 16-color text mode.</p>
|
|
||||||
|
|
||||||
<p>BIOS text output calls are converted to simple writes to stdout. Direct video memory accesses for the 80x25 CGA color text mode are converted to ANSI terminal escape sequences. If you are using a terminal which does not support ANSI (e.g. you are compiling the emulator with MS VC++ and running in a Windows console window) then PC applications that directly write to video memory in text mode may be unusable.</p>
|
|
||||||
|
|
||||||
<p>Most CGA I/O ports are not supported except for the CGA refresh register at 0x3DA, which some applications use for timing or synchronisation.</p>
|
|
||||||
|
|
||||||
<p>The regular PC character code page (437) includes various extended ASCII characters for things like line drawing. You might want to set the font in your terminal program to something that includes these (e.g. on Mac OS X there is a freeware font called Perfect DOS VGA 437 which does the trick).</p>
|
|
||||||
|
|
||||||
<p>Occasionally a DOS application on exit will leave the video hardware in an odd state which confuses the emulator, resulting in subsequent text output being invisible. If this happens, just use the DOS CLS command to clear the screen and all will be well again.</p>
|
|
||||||
|
|
||||||
<h2>Graphics mode support</h2>
|
|
||||||
|
|
||||||
<p>Hercules 720x348 monochrome graphics mode emulation is implemented using SDL. Most Hercules features are supported via the normal I/O interface on ports 0x3B8 and 0x3BA including video memory bank switching (segments B000/B800), which some games use for double-buffered graphics. CGA graphics modes are not supported.</p>
|
|
||||||
|
|
||||||
<p>When an application enters graphics mode, the emulator will open an SDL window (which will be closed when the application goes back to text mode). Including code to redirect keystrokes from the SDL window to the main terminal window would have busted the IOCCC size limits, so you need to keep the main emulator terminal window in focus at all times even when you are doing graphics (sounds a little odd but you will get used to it).</p>
|
|
||||||
|
|
||||||
<p>On UNIXes, SDL will automatically output graphics via X11 if the DISPLAY environment variable is set up.</p>
|
|
||||||
|
|
||||||
<h2>Dual graphics card support</h2>
|
|
||||||
|
|
||||||
<p>Some applications (e.g. AutoCAD) support a PC configuration with a CGA card and a Hercules card, for simultaneous text and graphics output on different displays. The emulator simulates this configuration, too, using separate windows for the (terminal) text and (SDL) graphics displays.</p>
|
|
||||||
|
|
||||||
<h2>BIOS</h2>
|
|
||||||
|
|
||||||
<p>Like a real PC, the emulator needs a BIOS to do anything useful. Here we use a custom BIOS, written from scratch specifically for the emulator. Source code for the BIOS (written in 8086 assembly language) which compiles with the freely-available NASM x86 assembler is available from the author on request.</p>
|
|
||||||
|
|
||||||
<p>The BIOS implements the standard interrupt interfaces for video, disk, timer, clock and so on, much as a “real” PC BIOS does, and also a small timer-controlled video driver to convert video memory formatting into ANSI escape sequences when the emulator is in text mode.</p>
|
|
||||||
|
|
||||||
<h2>CPU and memory emulation</h2>
|
|
||||||
|
|
||||||
<p>Memory map is largely as per a real PC, with interrupt vector table at 0:0, BIOS data area including keyboard buffer at 40:0, CGA text video memory at B800:0, Hercules dual-bank graphics memory at B000/B800:0, and BIOS at F000:100. Unlike a real PC, in the emulator the CPU registers are memory-mapped (at F000:0), which enables considerable optimisation of the emulator’s instruction execution unit by permitting the unification of memory and register operations, while remaining invisible to the running software.</p>
|
|
||||||
|
|
||||||
<p>CPU supports the full 8086/186 instruction set. Due to the complexities of the 8086’s arbitrary-length instruction decoding and flags, 8086 instructions are first converted to a simpler intermediate format before being executed. This conversion, along with instruction lengths and how each instruction modifies the flags, is assisted by some lookup tables which form part of the BIOS binary.</p>
|
|
||||||
|
|
||||||
<p>The CPU also implements some “special” two-byte opcodes to help the emulator talk with the outside world. These are:</p>
|
|
||||||
|
|
||||||
<pre><code>0F 00 - output character in register AL to terminal
|
|
||||||
0F 01 - write real-time clock data (as returned by localtime) to memory location ES:BX
|
|
||||||
0F 02 - read AX bytes from disk at offset 512*(16*SI+BP) into memory location ES:BX. Disk is specified in DL (0 = hard disk, 1 = floppy disk)
|
|
||||||
0F 03 - write AX bytes at memory location ES:BX to disk at offset 512*(16*SI+BP). Disk is specified in DL as per 0F 02
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Emulator exit is triggered if CS:IP == 0:0 (which would be nonsensical in real software since this is where the interrupt vector table lives). The supplied Dos6.22.img disk includes a small program QUITEMU.COM which contains a single JMP 0:0 instruction, to allow the user to easily quit the emulator without shutting down the terminal.</p>
|
|
||||||
|
|
||||||
<h2>Floppy disk support</h2>
|
|
||||||
|
|
||||||
<p>Emulates a 3.5" high-density floppy drive. Can read, write and format 1.44MB disks (18 sectors per track, 2 heads) and 720KB disks (9 sectors per track, 2 heads).</p>
|
|
||||||
|
|
||||||
<p>If you want to install your own software from floppy images (downloaded from e.g. Vetusware), the easiest way to “change disks” is to copy each disk image in turn over the floppy image file you specify on the command line. Don’t forget to put your original boot disk back at the end!</p>
|
|
||||||
|
|
||||||
<h2>Hard disk support</h2>
|
|
||||||
|
|
||||||
<p>Supports up to 1023 cylinders, 63 sectors per track, 63 heads for disks up to 528MB.</p>
|
|
||||||
|
|
||||||
<p>Disk image format used is a subset of the standard “raw” format used by most disk image mount tools. In general, disk images prepared by the emulator will work with disk image tools and other emulators, but not the other way around.</p>
|
|
||||||
|
|
||||||
<p>The emulator uses a particularly dumb algorithm to derive a simulated cylinder/sector/head geometry from the disk image file’s size. This algorithm often results in not all the space in the image file being available for disk partitions. For example, creating a 40,000,000 byte image file results in DOS FDISK seeing only 31.9MB as the volume size.</p>
|
|
||||||
|
|
||||||
<p>Note that unlike a real PC, the emulator cannot boot from a hard disk (image). Therefore, you will always need to use a bootable floppy image, even if after boot everything runs from the HD.</p>
|
|
||||||
|
|
||||||
<h2>Mouse</h2>
|
|
||||||
|
|
||||||
<p>No mouse is emulated.</p>
|
|
||||||
|
|
||||||
<h2>Real-time clock</h2>
|
|
||||||
|
|
||||||
<p>Reading the RTC (both time and date) is emulated via the standard BIOS clock interface, pulling the time/date from the host computer. Setting the time or date is not supported.</p>
|
|
||||||
|
|
||||||
<h2>Timers</h2>
|
|
||||||
|
|
||||||
<p>A countdown timer on I/O port 0x40 is simulated in a broken way which is good enough for most software. On a real PC this has a default period of 55ms and is programmable. No programmability is supported in the emulator and the period may be about right or completely wrong depending on the actual speed of your computer.</p>
|
|
||||||
|
|
||||||
<p>On a real PC, IRQ0 and interrupt 8 are fired every 55ms. The emulator tries to do the same but again, the delay period is uncalibrated so you get what you get.</p>
|
|
||||||
|
|
||||||
<h2>PC speaker</h2>
|
|
||||||
|
|
||||||
<p>Beeps only, through the console.</p>
|
|
||||||
|
|
||||||
<h2>Software supported</h2>
|
|
||||||
|
|
||||||
<p>The emulator will run practically any software a real PC (of the spec listed at the top of this file) can. The author has tested a number of OSes/GUIs (MS-DOS 6.22, FreeDOS 0.82pl3, Windows 3.0, DESQview 2.8), professional software (Lotus 1-2-3 2.4 and AsEasyAs 5.7 for DOS, Excel 2.1 for Windows, AutoCAD 2.5, WordStar 4), programming languages (QBASIC, GWBASIC, Turbo C++), games (Carrier Command, Police Quest, and a bunch of freeware Windows games), and diagnostic/benchmark software (Manifest, Microsoft MSD, InfoSpot, CheckIt) and all of them run well.</p>
|
|
||||||
|
|
||||||
<p>Screenshots of some of these applications running (on Mac OS X) are provided for the impatient.</p>
|
|
||||||
|
|
||||||
<h2>Compiler warnings</h2>
|
|
||||||
|
|
||||||
<p>A lot of compiler warnings are produced by clang. Missing type specifiers, control reaching the end of functions without returning values, incompatible pointer type assignments, and some precedence warnings, all necessary to keep the source size down. Other compilers are likely to produce similar warnings.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best sparkling utility</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best sparkling utility</h1>
|
|
||||||
|
|
||||||
<ol type="a">
|
|
||||||
<li>David Lowe<br>
|
|
||||||
434 Tenney Drive<br>
|
|
||||||
Rogue River, OR<br>
|
|
||||||
97537<br>
|
|
||||||
<a href="mailto:j.david.lowe@gmail.com">j.david.lowe@gmail.com</a><br>
|
|
||||||
<a href="http://www.pootpoot.net/">http://www.pootpoot.net/</a></li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make dlowe
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./dlowe [numbers...]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./dlowe 0 1 2 3 4 5 6 7
|
|
||||||
./dlowe 16 32 64 128
|
|
||||||
|
|
||||||
echo sparkline of file sizes: `wc -c * | awk '{print $1}' | xargs ./dlowe`
|
|
||||||
|
|
||||||
./dlowe 0
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>We liked how this entry used Unicode, specifically UTF-8, in a somewhat obfuscated way.</p>
|
|
||||||
|
|
||||||
<p>Also, why doesn’t it crash, and produces a correct output when called with one argument
|
|
||||||
or when all arguments are equal?</p>
|
|
||||||
|
|
||||||
<p>For extra fun, compile and run</p>
|
|
||||||
|
|
||||||
<pre><code>#include <stdio.h>
|
|
||||||
int main() {
|
|
||||||
printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
|
|
||||||
}
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>with gcc and clang.</p>
|
|
||||||
|
|
||||||
<p>With GCC (4.7.2), we get</p>
|
|
||||||
|
|
||||||
<pre><code>-2147483648 -2147483648 -2147483648
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>and with clang (3.3), we get</p>
|
|
||||||
|
|
||||||
<pre><code>-2147483648 0 2147483647
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Which one is correct? :)</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>sparkl</h1>
|
|
||||||
|
|
||||||
<p>A tiny implementation of command-line ‘sparkline’ data visualization.</p>
|
|
||||||
|
|
||||||
<h2>Synopsis</h2>
|
|
||||||
|
|
||||||
<pre><code>$ sparkl 0 1 2 3 4 5 6 7
|
|
||||||
▁▂▃▄▅▆▇▉
|
|
||||||
|
|
||||||
$ echo sparkline of file lengths: `wc -c * | awk '{print $1}' | xargs sparkl`
|
|
||||||
sparkline of file sizes: ▁▁▁▃▃▂▁▂▁▁▉
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Description</h2>
|
|
||||||
|
|
||||||
<p>This is a handy little tool for visualizing numeric series from the
|
|
||||||
command-line, using ‘sparklines’. Pass it a numeric series as arguments, and
|
|
||||||
sparkl will display a sparkline graph, which you can use to very quickly get a
|
|
||||||
sense of the shape of your data.</p>
|
|
||||||
|
|
||||||
<h2>Limitations</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Crashes with 0 arguments. It’d be trivial to fix, but adds a few bytes to the
|
|
||||||
code.</li>
|
|
||||||
<li>Produces bogus graphs when given > about 5000 arguments.</li>
|
|
||||||
<li>Only works if your terminal is utf-8 and your font supports the 8 glyphs
|
|
||||||
used.</li>
|
|
||||||
<li>Produces a few harmless compiler warnings.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Obfuscation</h2>
|
|
||||||
|
|
||||||
<p>The code is very terse. I was torn between submitting this version, and a
|
|
||||||
one-line version compressed using a couple more -D flags.</p>
|
|
||||||
|
|
||||||
<p>Hand-rolled utf-8 sequence, magic numbers (what’s that 7 for?), meaningless
|
|
||||||
variable names, reused variables, and so on.</p>
|
|
||||||
|
|
||||||
<h2>Acknowledgements</h2>
|
|
||||||
|
|
||||||
<p>Edward Tufte invented sparklines (among other things.) Brilliant.</p>
|
|
||||||
|
|
||||||
<p>Zach Holman’s <a href="https://github.com/holman/spark">‘spark’ utility</a> was absolutely
|
|
||||||
an inspiration.</p>
|
|
||||||
|
|
||||||
<p>As I was writing up this description, I discovered I’m not the first person to
|
|
||||||
write an obfuscated C sparkline utility! Vicent Martí created
|
|
||||||
<a href="https://gist.github.com/vmg/1368661">this one</a> years (!) ago. (My
|
|
||||||
implementation is completely independent.)</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,246 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most lazy SKIer</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most lazy SKIer</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This builds endoh1, echo, hello, and tac.</p>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./endoh1 [file.lazy]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./endoh1 hello.lazy
|
|
||||||
./hello
|
|
||||||
echo Hello | ./echo
|
|
||||||
./tac < endoh1.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Be patient with the last one.</p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>We liked this entry because it can serve as a standalone program as well as an include file; and, as usual,
|
|
||||||
because its input data is at least as obfuscated as the program itself.</p>
|
|
||||||
|
|
||||||
<p>This entry can be considered an abuse of the GCC’s optimizer; it takes GCC about 4x longer to compile it
|
|
||||||
with -O3 than without, compared to clang’s 2x.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<pre><code>$ less prog.c
|
|
||||||
$ gcc -o prog prog.c
|
|
||||||
$ ./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>… Isn’t there any more to it?</p>
|
|
||||||
|
|
||||||
<p>Yes, of course.</p>
|
|
||||||
|
|
||||||
<p>This is a tool <em>for C programmers</em> to play the <a href="http://en.wikipedia.org/wiki/SKI_combinator_calculus">SKI combinator calculus</a>,
|
|
||||||
especially, <a href="redacted">Lazy K</a>.</p>
|
|
||||||
|
|
||||||
<p>This program will shine when it is used as a library.
|
|
||||||
For example, <code>hello.lazy</code> is a “Hello world” program written in Lazy K.</p>
|
|
||||||
|
|
||||||
<pre><code>$ lazy hello.lazy
|
|
||||||
Hello, world!
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>where <code>lazy</code> is <a href="redacted">a reference implementation of Lazy K</a>.
|
|
||||||
At the same time, <code>hello.lazy</code> is <em>a valid C program</em> that uses <code>prog.c</code> as a library.</p>
|
|
||||||
|
|
||||||
<pre><code>$ gcc -o hello -xc hello.lazy
|
|
||||||
$ ./hello
|
|
||||||
Hello, world!
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>In other words, this program is a kind of <a href="http://en.wikipedia.org/wiki/Polyglot_%28computing%29">polyglot</a>.</p>
|
|
||||||
|
|
||||||
<p>The usage is simple:
|
|
||||||
you just have to wrap Lazy K program with <code>#include "prog.c"</code>.
|
|
||||||
Note that <code>#</code> is a comment in Lazy K.</p>
|
|
||||||
|
|
||||||
<h3>Obfuscation</h3>
|
|
||||||
|
|
||||||
<p>… is inherent in SKI combinator calculus :-)</p>
|
|
||||||
|
|
||||||
<p>In addition, it uses various hacks to parse SKI code as C,
|
|
||||||
and to satisfy IOCCC’s size rule.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Abuse of function pointers</li>
|
|
||||||
<li>Code duplication by macros</li>
|
|
||||||
<li>Short coding</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>These led to the good obfuscation.
|
|
||||||
See Spoiler section in detail, if you need.</p>
|
|
||||||
|
|
||||||
<h3>Limitation</h3>
|
|
||||||
|
|
||||||
<p>This program supports only “Combinator-calculus style notation” of Lazy K.
|
|
||||||
“Unlambda style” and “Iota and Jot” style are not supported.
|
|
||||||
Also, it requires a space between identifiers.
|
|
||||||
In short, use <code>(S K)</code> instead of <code>(SK)</code>, “`sk”, <code>**i*i*i*ii*i*i*ii</code>,
|
|
||||||
or <code>11111100011100</code>.</p>
|
|
||||||
|
|
||||||
<p>Huge memory may be required to compile the program
|
|
||||||
(about 300 MB on my machine).</p>
|
|
||||||
|
|
||||||
<p>In addition, there are some limitations (and workarounds)
|
|
||||||
mentioned in Spoiler section.
|
|
||||||
But I think it wouldn’t matter only when you run the attached programs.</p>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>I confirmed that the program successfully worked
|
|
||||||
with the following compilers.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>gcc 4.6.3 [Linux, Mac OS X]</li>
|
|
||||||
<li>clang 3.0 [Linux, Mac OS X]</li>
|
|
||||||
<li>tcc 0.9.26 [Linux]
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>N.B. tcc 0.9.25 seems to have a bug and fails to run it.</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Recent compilers with <code>-Wall -W -Wextra -pedantic</code> say nothing.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -Wall -W -Wextra -pedantic prog.c
|
|
||||||
clang -Wall -W -Wextra -pedantic prog.c
|
|
||||||
tcc -Wall -W -Wextra -pedantic prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>I think it will work on almost all platforms. I confirmed:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Ubuntu Linux</li>
|
|
||||||
<li>Mac OS X</li>
|
|
||||||
<li>Raspberry PI</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>To check whether the program is specified on the command line
|
|
||||||
or included from another source file,
|
|
||||||
the program uses a predefined macro <code>__INCLUDE_LEVEL__</code>.
|
|
||||||
It is a gcc extention, and also supported by clang.
|
|
||||||
If your compiler does not support it,
|
|
||||||
you cannot use the program as a library.
|
|
||||||
But you can compile and run it as a standalone program, at least.
|
|
||||||
In fact, tcc does not support the macro, but does work.</p>
|
|
||||||
|
|
||||||
<h3>Spoiler (rot13)</h3>
|
|
||||||
|
|
||||||
<p>Gur jubyr cebtenz vf vagrecergrq ol znpeb rkcnafvba.
|
|
||||||
Sbe rknzcyr, <code>F (X V)</code> vf genafyngrq gb n abezny P pbqr, <code>(f)((x)(v))</code>,
|
|
||||||
be fvzcyl <code>f(x(v))</code>.
|
|
||||||
Guvf rkcerffvba ergheaf na nofgenpg flagnk gerr,
|
|
||||||
naq <code>cebt.p</code> rinyhngrf vg.
|
|
||||||
Guvf cebtenz hfrf irel fvzcyr “grez erjevgvat” nccebnpu
|
|
||||||
sbe rinyhngvat FXV pbzovangbe pnyphyhf.
|
|
||||||
Gur erjevgvat ehyrf ner fubja va gur funcr bs gur pbqr.</p>
|
|
||||||
|
|
||||||
<h4>Nohfr bs shapgvba cbvagref</h4>
|
|
||||||
|
|
||||||
<p>Pbafvqre n frdhrapr bs shapgvba nccyvpngvbaf va P:</p>
|
|
||||||
|
|
||||||
<pre><code>f(k)(k)(k)(k)...
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Jung glcr fubhyq <code>f</code> unir?
|
|
||||||
Hasbeghangryl, P qbrf <em>abg</em> cebivqr n “erphefvir glcr”,
|
|
||||||
fhpu nf <code>glcrqrs s (*s)();</code>.
|
|
||||||
Fb, V hfrq n urniyl arfgrq shapgvba cbvagre glcr:</p>
|
|
||||||
|
|
||||||
<pre><code>glcrqrs ibvq *(*(*(*...(*(s))()...)())())
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Guvf yvzvgf ubj znal nethzragf bar shapgvba pna or pbafrphgviryl nccyvrq gb.
|
|
||||||
Ohg lbh pna vapernfr gur ahzore ol gjrnxvat gur qrsvavgvba bs znpeb <code>c</code>.</p>
|
|
||||||
|
|
||||||
<h4>Pbqr qhcyvpngvba ol znpebf</h4>
|
|
||||||
|
|
||||||
<p>Arkg, jr arrq gb rapbqr “pybfherf”.
|
|
||||||
N pybfher vf n shapgvba gbtrgure jvgu na raivebazrag
|
|
||||||
juvpu vf n ersrerapr gb aba-ybpny inevnoyr.</p>
|
|
||||||
|
|
||||||
<p>Va guvf pnfr, jr arrq fbzrguvat gung:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>vf pnyynoyr vgfrys,</li>
|
|
||||||
<li>vagreanyyl cbffrffrf n ersrerapr gb nabgure pybfher nf n aba-ybpny inevnoyr, naq</li>
|
|
||||||
<li>nccyvrf gur vagreany pybfher gb na nethzrag jura vg vf pnyyrq.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Ubjrire, ab glcr va P vf pnyynoyr naq unf n ersrerapr ng gur fnzr gvzr.
|
|
||||||
(Vg vf srnfvoyr ol qlanzvp pbqr trarengvba, ohg vg vf sne sebz cbegnoyr.)</p>
|
|
||||||
|
|
||||||
<p>Fb, V nqqerffrq guvf vffhr ol trarengvat znal shapgvba qrsvavgvbaf
|
|
||||||
fgngvpnyyl ol (no)hfvat znpebf:</p>
|
|
||||||
|
|
||||||
<pre><code>ibvq *k1; ibvq s1(ibvq *l) { erghea nccyl(k1, l); }
|
|
||||||
ibvq *k2; ibvq s2(ibvq *l) { erghea nccyl(k2, l); }
|
|
||||||
ibvq *k3; ibvq s3(ibvq *l) { erghea nccyl(k3, l); }
|
|
||||||
...
|
|
||||||
ibvq *(u[]) = { s1, s2, s3, ... }
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>naq ol nyybgvat rnpu bs gurz jura n pybfher vf arrqrq.</p>
|
|
||||||
|
|
||||||
<p>Guvf yrnqf gb nabgure yvzvgngvba:
|
|
||||||
gur ahzore bs cer-qrsvarq pybfherf yvzvgf
|
|
||||||
ubj znal vaqragvsvref (<code>F</code> <code>X</code> <code>V</code>) bar cebtenz pna hfr.
|
|
||||||
Ohg lbh pna vapernfr guvf ahzore
|
|
||||||
ol gjrnxvat gur qrsvavgvba bs znpeb <code>N</code> <code>O</code> <code>P</code> naq <code>Q</code>.
|
|
||||||
(Abgr gung pybfherf ner nyybggrq bayl jura cnefvat;
|
|
||||||
nsgre gur rinyhngvba fgnegf, “bhg bs pybfher” pnaabg bpphe.)</p>
|
|
||||||
|
|
||||||
<h4>Fubeg pbeqvat</h4>
|
|
||||||
|
|
||||||
<p>Guvf znetva vf gbb aneebj gb pbagnva n qrgnvyrq rkcynangvba.
|
|
||||||
Vafgrnq, V whfg nfx lbh bar dhrfgvba.
|
|
||||||
Pna lbh gryy jung <code>i f[]={0,0,f+6,f+2,f+4,f,f+3,f+5,f+1};</code> vf?
|
|
||||||
V sbhaq guvf ol hfvat FZG fbyire.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most recyclable</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most recyclable</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make endoh2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code> make all
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>You’ll need to have Ruby installed to run all the automated check</p>
|
|
||||||
|
|
||||||
<pre><code>make check
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>cat jpeg.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Look at jpeg.jpg in an image viewer program.</p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This is a program which, when fed its own source, generates a program that almost is its whitespace inverse,
|
|
||||||
which, in its order, generates a JPEG file (speaking of file size abuse, that is about 16.4 times
|
|
||||||
larger than a PBM file with the same image, but the source was also abusing the size counting program…)</p>
|
|
||||||
|
|
||||||
<p>Don’t pay attention to the OCR <del>behind the ruby curtain</del> — it’s a straightforward bitmap comparison.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Highlights</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>LZ77-like compression for font and template data</li>
|
|
||||||
<li>tiny JPEG encoder
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Zig-zag space-filling curve</li>
|
|
||||||
<li>Discrete cosine transform</li>
|
|
||||||
<li>JPEG Huffman encoding (cheeting)</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Notes</h3>
|
|
||||||
|
|
||||||
<p>I picked JPEG instead of PNG, GIF, or BMP
|
|
||||||
because it is the most difficult to generate.
|
|
||||||
I believe that the JPEG encoder is the world’s smallest ever.
|
|
||||||
Nevertheless, the program was too big to meet the IOCCC’s size rule.
|
|
||||||
So I created a smaller bootstrap program that generates the main program.
|
|
||||||
<code>prog.c</code> contains fragments of the main program <em>as a comment</em>
|
|
||||||
which <code>iocccsize -i</code> does <em>not</em> count.
|
|
||||||
I gratefully think the judges for spoiling the size rule this year.</p>
|
|
||||||
|
|
||||||
<p>I think the program will work on any major platforms and compilers.</p>
|
|
||||||
|
|
||||||
<h3>Legal</h3>
|
|
||||||
|
|
||||||
<p>This program uses (a part of) Proggy Tiny Fonts
|
|
||||||
which is distributed in MIT License:</p>
|
|
||||||
|
|
||||||
<pre><code>Copyright (c) 2004, 2005 Tristan Grimmer
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
copy of this software and associated documentation files (the "Software"),
|
|
||||||
to deal in the Software without restriction, including without limitation
|
|
||||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,234 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most tweetable 1-liner</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most tweetable 1-liner</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make endoh3
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./endoh3
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<p>Trying this out will depend on how your system can play sounds. The author’s
|
|
||||||
remarks include some options for different operating systems.</p>
|
|
||||||
|
|
||||||
<p>The simplest way is to create a .wav file and have your system play that.</p>
|
|
||||||
|
|
||||||
<pre><code>echo 'CDEFGABc' | ./endoh3 | ruby wavify.rb > cde.wav
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>There are also some other musical samples, twinkle.abc and menuet.abc.</p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This program can tweet out a tune and is small enough to tweet.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<p>This is a sound synthesizer for a subset of <a href="http://en.wikipedia.org/wiki/ABC_notation">ABC music notation</a>.</p>
|
|
||||||
|
|
||||||
<p>Try:</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -o prog prog.c
|
|
||||||
echo "CDEFGABc" | ./prog > /dev/dsp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>If <code>/dev/dsp</code> is not available on your system, use an OSS sound wrapper such
|
|
||||||
as <code>padsp</code> or <code>aoss</code>:</p>
|
|
||||||
|
|
||||||
<pre><code>echo "CDEFGABc" | ./prog | padsp tee /dev/dsp > /dev/null
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>If you are using Mac OS X, try <a href="http://sox.sourceforge.net/">sox</a>:</p>
|
|
||||||
|
|
||||||
<pre><code>echo "CDEFGABc" | ./prog | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>If they do not work, use the attached script to convert the output
|
|
||||||
into a wave file format:</p>
|
|
||||||
|
|
||||||
<pre><code>echo "CDEFGABc" | ./prog | ruby wavify.rb > cde.wav
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>and play <code>cde.wav</code>.</p>
|
|
||||||
|
|
||||||
<p>You can enjoy some music scores that I attached:</p>
|
|
||||||
|
|
||||||
<pre><code>cat twinkle.abc | ./prog > /dev/dsp
|
|
||||||
cat menuet.abc | ./prog > /dev/dsp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Obfuscation</h3>
|
|
||||||
|
|
||||||
<p>The following sequence of questions may be helpful to understand the program.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>How does it convert ABC notes into the frequency?</li>
|
|
||||||
<li>What is <code>89/84.</code>? I found it by using Stern-Brocot tree.</li>
|
|
||||||
<li>How does it generate a wave? Hint: it generates a saw wave.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Limitation</h3>
|
|
||||||
|
|
||||||
<p>The following features are supported:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Notes:
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>C</code> <code>D</code> <code>E</code> <code>F</code> <code>G</code> <code>A</code> <code>B</code> (in low octave)</li>
|
|
||||||
<li><code>c</code> <code>d</code> <code>e</code> <code>f</code> <code>g</code> <code>a</code> <code>b</code> (in high octave)</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li>Rests: <code>z</code></li>
|
|
||||||
<li>Note lengths:
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>A</code> (an eighth note)</li>
|
|
||||||
<li><code>A2</code> (a quarter note)</li>
|
|
||||||
<li><code>A3</code> (a dotted quarter note)</li>
|
|
||||||
<li><code>A4</code> (a half note)</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The following features are <em>not</em> supported:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Sharp and flat: <code>^C</code> <code>_C</code>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>But it is possible to emit the half tones. Do you see how?</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li>Shorter note lengths than 1: <code>C1/2</code>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>But you can use <code>C0.5</code> instead.</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li>Higher and lower notes: <code>c'</code> <code>C,</code></li>
|
|
||||||
<li>Any meta fields: <code>T:title</code> <code>L:1/4</code></li>
|
|
||||||
<li>Bar line, repeat, ties and slurs, and everything else.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Known Bugs</h3>
|
|
||||||
|
|
||||||
<p>You can <em>not</em> write a note length immediately followed by a note <code>E</code>,
|
|
||||||
such as <code>C2E2</code>.
|
|
||||||
Can you know why?
|
|
||||||
You can work it around by inserting a whitespace: <code>C2 E2</code>.</p>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>I tested it on:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Ubuntu 13.10 with gcc 4.7.3, clang 3.2, and tcc 0.9.25.</li>
|
|
||||||
<li>Mac OS X 10.6 with gcc 4.2.1 and clang 1.7.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Legal</h3>
|
|
||||||
|
|
||||||
<p>I believe that all the scores that I attached are out-of-copyright.</p>
|
|
||||||
|
|
||||||
<p>I did write a score of the Happy Birthday song too.
|
|
||||||
(It does not matter because the song is out-of-copyright in my country.)
|
|
||||||
But I do not attach it to protect you from W****r.</p>
|
|
||||||
|
|
||||||
<p>For the same reason, do not play a score that contains only <code>z1092</code>.
|
|
||||||
You know, it is <a href="http://en.wikipedia.org/wiki/4%E2%80%B233%E2%80%B3">“the famous song”</a>.</p>
|
|
||||||
|
|
||||||
<h3>Spoiler (rot13)</h3>
|
|
||||||
|
|
||||||
<p>Urer vf n zntvpny rkcerffvba juvpu V sbhaq ol oehgr-sbepr:</p>
|
|
||||||
|
|
||||||
<pre><code>(p % 32 + 5) * 9 / 5 % 13 + a / 32 * 12 - 22
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Vagrerfgvatyl, vg pbairegf na NFPVV ahzore bs NOP abgrf
|
|
||||||
gb gur pbeerfcbaqvat gbar ahzore.</p>
|
|
||||||
|
|
||||||
<pre><code>'P' (NFPVV 67) => 3
|
|
||||||
'Q' (NFPVV 68) => 5
|
|
||||||
'R' (NFPVV 69) => 7
|
|
||||||
'S' (NFPVV 70) => 9
|
|
||||||
'T' (NFPVV 71) => 10
|
|
||||||
'N' (NFPVV 65) => 12
|
|
||||||
'O' (NFPVV 66) => 14
|
|
||||||
'p' (NFPVV 99) => 15
|
|
||||||
'q' (NFPVV 100) => 17
|
|
||||||
'r' (NFPVV 101) => 19
|
|
||||||
's' (NFPVV 102) => 20
|
|
||||||
't' (NFPVV 103) => 22
|
|
||||||
'n' (NFPVV 97) => 24
|
|
||||||
'o' (NFPVV 98) => 26
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Ol gur jnl, lbh pna jevgr n unys-gbar ol gur sbyybjvat punenpgref.</p>
|
|
||||||
|
|
||||||
<pre><code>'X' => 4 (= P#)
|
|
||||||
'Y' => 6 (= Q#)
|
|
||||||
'H' => 8 (= S#)
|
|
||||||
'I' => 11 (= T#)
|
|
||||||
'C' => 13 (= N#)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Abgr gung gur gbar ahzoref fvzcyl rahzrengr gur frzv-gbar fgrcf.
|
|
||||||
Fb jr pna pnyphyngr gur serdhrapl rnfvyl: <code>cbj(2, a / 12.0)</code>.
|
|
||||||
Gura, ubj pna jr pnyphyngr <code>cbj</code> jvgubhg <code>zngu.u</code>?
|
|
||||||
<code>cbj(2, 1.0 / 12.0)</code> vf nccebkvzngrq ol <code>89/84.</code>.
|
|
||||||
(V sbhaq guvf nccebkvzngvba ol hfvat <a href="uggc://ra.jvxvcrqvn.bet/jvxv/Fgrea%R2%80%93Oebpbg_gerr">Fgrea-Oebpbg gerr</a>.)
|
|
||||||
Jr pna tnva gur serdhrapl ol zhygvcylvat gur inyhr <code>a</code> gvzrf.</p>
|
|
||||||
|
|
||||||
<p>Svanyyl, gur sbyybjvat pbqr trarengrf n fnj jnir:</p>
|
|
||||||
|
|
||||||
<pre><code>sbe(p = 0; p < yra; p++) chgpune(n = a * Q);
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>jurer <code>Q</code> vf n serdhrapl naq <code>n</code> vf n inevnoyr jubfr glcr vf pune.
|
|
||||||
Ol nffvtavat sybng gb pune inevnoyr, gur vzcyvpvg glcr pbairegvba vf cresbezrq sebz sybng gb pune (zbqhyb 256).
|
|
||||||
(Fgevpgyl fcrnxvat, guvf orunivbe vf haqrsvarq nppbeqvat gb 6.3.1.4 va P99;
|
|
||||||
lbh pna ercynpr vg jvgu <code>(ybat)(a*Q)</code> vs lbh ner crqnagvp.)</p>
|
|
||||||
|
|
||||||
<p>Nyy gung jnf yrsg jnf gb pbzovar naq pbaqrafr gur pbzcbaragf.
|
|
||||||
Gur xrl vf fdhnfuvat gurz vagb whfg bar sbe-ybbc.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most solid</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most solid</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make endoh4
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./endoh4
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<p>NOTE: The author recommends the use of xterm.</p>
|
|
||||||
|
|
||||||
<pre><code>./endoh4 < cube.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>For example, if you are a soccer fan, try:</p>
|
|
||||||
|
|
||||||
<pre><code>make all
|
|
||||||
./endoh4 < solids/archimedian-solid/a11-truncated-icosahedron.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This program is formatted as the net for a tetrahedron. (hint, try feeding the
|
|
||||||
program it’s own source code). When it runs there is an animation for the
|
|
||||||
computation to work out the convex hull.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Spec</h3>
|
|
||||||
|
|
||||||
<p>This is a convex polyhedron viewer, which:</p>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li>reads three-dimentional vertices (3N float values) from stdin,</li>
|
|
||||||
<li>calculates a convex hull of them, and</li>
|
|
||||||
<li>renders it.</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<p>This simple spec involves many details.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>3D convex hull calculation
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>recursive gift wrapping algorithm</li>
|
|
||||||
<li>automatical merging of (almost) co-planar faces
|
|
||||||
(i.e., faces are not triangulated)</li>
|
|
||||||
<li>random perturbation for robustness</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li>3D rendering
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>perspective projection</li>
|
|
||||||
<li>ASCII line drawing: <code>"',;;;,;'"</code></li>
|
|
||||||
<li>camera in a spherical spiral orbit</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>(Note that this program does not use <code>math.h</code>.)</p>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>I think it conforms with both C89 and C99.
|
|
||||||
I confirmed that it worked on gcc, clang, and tcc.
|
|
||||||
It should not be warned with -pedantic and -Wextra.</p>
|
|
||||||
|
|
||||||
<h3>Tips</h3>
|
|
||||||
|
|
||||||
<p>You may want to use <code>tput</code> to hide a terminal cursor.</p>
|
|
||||||
|
|
||||||
<pre><code>tput civis
|
|
||||||
./endoh4 < cube.txt
|
|
||||||
tput cnorm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Bonuses</h3>
|
|
||||||
|
|
||||||
<p>You can change the screen size. Let the aspect ratio be about 3:1.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -DS=120,40 -o endoh4 endoh4.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The shape of this code is the geometric net of a regular tetrahedron.
|
|
||||||
So, try:</p>
|
|
||||||
|
|
||||||
<pre><code>./endoh4 < endoh4.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The solids.tbz2 file includes various solid data:
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Platonic_solid">Platonic solids</a>,
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Archimedean_solid">Archimedean solids</a>,
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Prism_%28geometry%29">Prisms</a>,
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Antiprism">Antiprisms</a>,
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Bipyramid">Bipyramids</a>,
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Trapezohedron">Trapezohedrons</a>, and
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Johnson_solid">Johnson solids</a>.</p>
|
|
||||||
|
|
||||||
<p>I created the files by using the POV-Ray scripts
|
|
||||||
(<a href="http://en.wikipedia.org/wiki/File:Poly.pov">1</a> and
|
|
||||||
<a href="http://en.wikipedia.org/wiki/User:AndrewKepert/poly.pov">2</a>)
|
|
||||||
in Wikipedia.
|
|
||||||
They are copyrighted in CC BY-SA 3.0
|
|
||||||
by “User:Cyp” and “User:AndrewKepert”.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best use of 1 Infinite Loop</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best use of 1 Infinite Loop</h1>
|
|
||||||
|
|
||||||
<p>Qiming Hou<br>
|
|
||||||
<a href="mailto:hqm03ster@gmail.com">hqm03ster@gmail.com</a><br>
|
|
||||||
<a href="http://www.houqiming.net">http://www.houqiming.net</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make hou
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hou [scene-file-name] [options]
|
|
||||||
|
|
||||||
Follow the instructions in stdout, preferably with an auto-refreshing PPM image viewer ready.
|
|
||||||
Refresh the image every time the output refreshes, all effects should be more or less recognizable when you see 16.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./hou BIG
|
|
||||||
./hou old_default.scene BIG
|
|
||||||
./hou otherroom.scene
|
|
||||||
./hou otherroom.scene NAIVE
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>You could consider that this program violates the source code size
|
|
||||||
limit. This is because the first compliation of this program is
|
|
||||||
really just a decompressor to generate the real source code of the
|
|
||||||
program.</p>
|
|
||||||
|
|
||||||
<p>This program will loop infinitely while progressivly refining a
|
|
||||||
raytraced image.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Using hou</h3>
|
|
||||||
|
|
||||||
<p>This program is a programmable rendering engine with a built-in default scene. The standard command line is:</p>
|
|
||||||
|
|
||||||
<pre><code>./hou [scene-file-name] [options]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>As hou runs, it writes a progressively refining image to a ppm file specified in the scene. The initialization may take a while, but once it’s done, a rough preview should be available in seconds. Leave hou running for the night, and you get a high quality result like the attached *.jpg files. Kill hou manually after you’re satisfied with the image quality.</p>
|
|
||||||
|
|
||||||
<p>To save time and energy for the judges, rendered images for all provided scenes are provided as attached files.</p>
|
|
||||||
|
|
||||||
<h3>Features</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>Fully programmable: Almost every stage of the renderer is programmable with a shader, i.e., a short script that does something rendering-related. In particular, each scene consists of one or more geometry shaders, a camera shader, and one or more material shaders. Shaders are written in an interpreted language that supports basic arithmetic, a few math functions, variables and procedural call in the CPS (Continuation Passing Style).</p></li>
|
|
||||||
<li><p>Fast preview: This renderer isn’t just a naive path tracer, it actually uses a modern global illumination algorithm which is robust against challenging scene configurations. You can mostly place light sources and specify surface properties as you please without worrying too much about the convergence speed – you always get a nice fast preview within one or two minutes. As proof, there is a comparison: “./hou otherroom.scene” gives a rough idea about the overall illumination at 16 samples per pixel (i.e., when the program prints 16), whereas the naive approach “./hou otherroom.scene NAIVE” only produces a mess of white dots.</p></li>
|
|
||||||
<li><p>Rich visual effects: The algorithm samples all light path types so most physically based effects can be produced. The default scene demonstrates quite a few of them: reflection, area light, soft shadows, color bleeding, caustics, and depth-of-field blur. Of course, one can also get programmable-shading effects like procedural texturing and approximated Fresnel terms.</p></li>
|
|
||||||
<li><p>Accelerated ray tracing: The ray tracing part uses an algorithm better than the brute-force intersection of everything. The renderer even builds an acceleration data structure! Despite the double precision and the single-threaded-ness, it still runs at about 0.5 million rays per second on the author’s machine.</p></li>
|
|
||||||
<li><p>Pause and resume: Can’t run ./hou overnight? No problem! You can kill and resume a rendering session whenever you want. The renderer automatically saves the progress every 16 samples and resumes where it’s left off when restarted. Also, each scene/parameter combination gets a different saved session so you don’t have to worry about conflicts.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Abuse of the rules</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>hou.c uses compression to get around the size limit. The compression fully complies with the rules and the guidelines (at least the portion that shows up in grep “size limit”). Please see the “Self-imposed restrictions” section below for more details.</p></li>
|
|
||||||
<li><p>hou does not terminate (as suggested by the second line of rule 6).</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Self-imposed restrictions</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>The building process does not involve any OS tool beyond cc and make. No gzip compression! a.c.gz doesn’t fit in 2053 bytes, anyway.</p></li>
|
|
||||||
<li><p>Neither hou.c nor a.c (the <em>real</em> decompressed source) uses #define (or cc -D) at all.</p></li>
|
|
||||||
<li><p>The source code is not required at runtime.</p></li>
|
|
||||||
<li><p>a.c does not drop optional features to reduce size. There are pure optimization code that can be dropped without affecting the converged output (only affecting the ray tracing speed / convergence rate). All files are properly fopened with “rb” / “wb” for Windows compatibility. The PPM header has a comment line for non-standard-compliant viewers (specifically, my old HDRShop 1.0). And there is a nice text message saying “please wait…”.</p></li>
|
|
||||||
<li><p>Despite the messy look, a.c and hou.c compiles warning-free (hou.c even wastes 18 bytes on #include<stdio.h> just for putchar). a.c compiles mostly clean in the C99/ANSI modes of clang and gcc (with -Wall –pedantic). The only warning generated is a pedantic one: “string constant too long”.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Comments and why obfuscated</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>Both the compression and the rendering use mathematically involved algorithms. Understanding the C doesn’t help much if one isn’t familiar with the math.</p></li>
|
|
||||||
<li><p>Modern renderers provide shader access to just about any internal state. This one follows suit and reuses the same shader-accessible array for all important internal states.</p></li>
|
|
||||||
<li><p>Infinity and not-a-number are used during normal course of execution.</p></li>
|
|
||||||
<li><p>Previous image-generating entries may take care to hide the “IOCCC” string in the code, but they leave the text clear in the <em>result</em>. This entry takes it further and obfuscates the output image as well. Can you find the text in the image? Hint: look up.</p></li>
|
|
||||||
<li><p>a.c leaves all shaders in plain text, but the plain text shader code can’t be taken for its face value – the arithmetic rules subtly diverge from our common sense.</p></li>
|
|
||||||
<li><p>a.c is less portable than hou.c itself. hou.c only depends on ASCII and should run just fine on 16-bit, small memory, or float-incapable machines. a.c, while still reasonably portable, is quite memory consuming, requires IEEE754-compliant double, and assumes int to be 32-bit.</p></li>
|
|
||||||
<li><p>Though technically endian-dependent, a.c remains portable providing that one doesn’t copy saved sessions across endians.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Spoiler</h3>
|
|
||||||
|
|
||||||
<pre><code> 3225 3225 3225 9 9 3225 3225
|
|
||||||
1 1 1 1 1 1 1 1 1 1
|
|
||||||
4225 1226 1 1 1 1 1222 1226
|
|
||||||
1 1 1 1 1 1 1 1 1
|
|
||||||
4226 1 4226 8 4222 4226 1 1
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p> The program consists of a recursive-descend interpreter, a 3DDDA (3D Discrete Differential Analysis) ray tracer, a PSSMLT (Primary Sample Space Metropolis Light Transport) light path sampler, all squeezed into the size limit using a PPM compressor (Prediction by Partial Matching, and yes, the output format is chosen for the pun).</p>
|
|
||||||
|
|
||||||
<p> PSSMLT uses the Metropolis-Hasting algorithm to sample a 32D unit hypercube. Each point in the hypercube is interpreted as a sequence of random numbers, and is sent to a path tracer to generate a light path. The point’s Metropolis-Hasting energy is then defined as the corresponding path’s contribution value to the final image. Since each path is sampled with a probability proportional to its energy, the sample distribution directly corresponds to the final image, which can then be produced as a simple per-pixel histogram of all generated paths. The robustness comes from a state mutation strategy that actively tries to explore the neighborhood of high energy peaks (e.g. paths that happen to hit the light source in otherroom.scene). In addition, a rudimentary form of lens path stratification is added to balance the attention each pixel receives. The Metropolis-Hasting process completely avoids the tell-tale pixel sampling loop required in most other image generation methods.</p>
|
|
||||||
|
|
||||||
<p> The 3DDDA tracer is chosen for scalability: its performance doesn’t get much worse as scene complexity increases. Another benefit is that with the DDA code in place one can naturally use hierarchical grids as an acceleration structure. The downside, of course, is that the setup involves quite a few divisions, which naturally turns into division-by-zeros. Fortunately, the IEEE754 standard has a nice set of rules just for this purpose and the arithmetics are organized in a specific way to take advantage of this. The shader interpreter component is relatively straightforward, just an expression evaluator stripped to the bare minimum – it doesn’t even support numerical constants natively. A final little bit is a just-good-enough PRNG (Pseudo Random Number Generator) to replace the low precision Windows rand() and the non-C99 Unix drand48(). An overnight session would run through its short period many times, but that doesn’t necessarily map to the same set of paths in PSSMLT. After all, Metropolis et al. used an even worse PRNG in their 1953 paper.</p>
|
|
||||||
|
|
||||||
<p> The PPM compressor uses statically weighted fixed order contexts with an arithmetic encoder tweaked for iocccsize. The encoder emits octet-space pairs where each octet encodes ~6.5 bits of information and each space encodes 2 bits (thanks to the generous definition of “space” in iocccsize.c). The compressor actively shuffles the variable names around until the compressed string happens to contain enough “{}; ” to pass the final iocccsize test. There are a few other tweaks:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>The PPM model uses mostly whitespace characters for weights.</p></li>
|
|
||||||
<li><p>The encoder never emits ‘“’ and ‘\’.</p></li>
|
|
||||||
<li><p>The decoder uses an O(n<sup>2</sup>) algorithm to avoid the gigabytes-sized hash table frequently found in other PPM implementations.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most timely rendered</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most timely rendered</h1>
|
|
||||||
|
|
||||||
<p>Christopher Mills<br>
|
|
||||||
<a href="mailto:mrxo@sonic.net">mrxo@sonic.net</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make mills
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./mills
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./mills &
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>While that is running, point your favorite browser at: <a href="http://localhost:8224">http://localhost:8224</a></p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Who will be the first to post an image rendered during a leap-second?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>The Program</h1>
|
|
||||||
|
|
||||||
<p>This program is a handy graphical clock. Simply run the program, click <em>OK</em> to
|
|
||||||
any annoying security dialogs that pop up (aren’t those annoying?), then fire
|
|
||||||
up your web browser and type in the following URL:</p>
|
|
||||||
|
|
||||||
<blockquote><p> <a href="http://localhost:8224">http://localhost:8224</a></p></blockquote>
|
|
||||||
|
|
||||||
<p>You will soon be presented with a lovely dynamically rendered 3D scene that
|
|
||||||
also convienently tells you the current time!</p>
|
|
||||||
|
|
||||||
<h2>Usage Notes</h2>
|
|
||||||
|
|
||||||
<p>The program will continue to give you the time of day as it changes by
|
|
||||||
reloading the page as often as it can render. If you grow tired of watching
|
|
||||||
your life slip by, hit <code>Control-C</code> in the original window. Note that if you
|
|
||||||
want to restart the program again, you should wait a minute or two before
|
|
||||||
doing so. For details as to why this is necessary, feel free to Google
|
|
||||||
<code>TIME_WAIT</code>. And while you are there, click on an ad. They could use the
|
|
||||||
money.</p>
|
|
||||||
|
|
||||||
<p>It would be possible to fix this by adding</p>
|
|
||||||
|
|
||||||
<pre><code>n=1,setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&n,sizeof n),
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>at an appropriate spot in the code (an exercise left to the reader). However,
|
|
||||||
as this limitation is documented, it is not techinally a bug.</p>
|
|
||||||
|
|
||||||
<h2>Details of Operation</h2>
|
|
||||||
|
|
||||||
<p>The program wears many hats (not literally). It is</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>a web server</li>
|
|
||||||
<li>a PNG encoder</li>
|
|
||||||
<li>a ray tracer</li>
|
|
||||||
<li>a clock</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>It replies to web requests with a PNG image that uses the
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Adam7_algorithm">Adam7</a>
|
|
||||||
encoding to return data progressively. Since the data is returned in Adam7
|
|
||||||
format, the scene is displayed initally at a lower resolution and allowed to
|
|
||||||
be progressively refined as time goes on. The ray tracer is integrally tied
|
|
||||||
to the PNG encoder, casting rays in the Adam7 order. The web server uses
|
|
||||||
PNG primarily because of PNG’s ability to return data progressively, and not
|
|
||||||
as you might think because the PNG standard is so obfuscated as to require
|
|
||||||
both little- and big-endian encodings at different spec layers.</p>
|
|
||||||
|
|
||||||
<p>Since ray-tracing was an obvious choice to return to a web server, I needed
|
|
||||||
something to ray-trace. A static scene would be uninteresting. I took
|
|
||||||
inspiration (as I often do) from the IOCCC remarks file which says</p>
|
|
||||||
|
|
||||||
<blockquote><p> At least one judge prefers to maintain the use of the leap-second
|
|
||||||
as part of the world’s time standard.</p></blockquote>
|
|
||||||
|
|
||||||
<p>Then it was obvious; The code should display the time. It is believed (but
|
|
||||||
not confirmed) that the code will, in fact, display leap seconds correctly.</p>
|
|
||||||
|
|
||||||
<p>To display the time, of course we would need a font. This font is encoded
|
|
||||||
as a string, using only the C whitespace characters. Clearly, the judges
|
|
||||||
intended this use of whitespace for data compression, since their tool
|
|
||||||
doesn’t count whitepsace in strings differently than whitespace outside of
|
|
||||||
them.</p>
|
|
||||||
|
|
||||||
<h2>User-modifyable Features</h2>
|
|
||||||
|
|
||||||
<p>The code can be user-modified simply by changing the build command line.
|
|
||||||
The following symbols are defined in the build file:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p><code>-DLT=x1,y1,z1,x2,y2,z2,...</code></p>
|
|
||||||
|
|
||||||
<p>Defines the coordinates of the lights in the scene. It should be a
|
|
||||||
comma-separated list of coordinates (x, y, z), three per light.</p></li>
|
|
||||||
<li><p><code>-DNL=n</code></p>
|
|
||||||
|
|
||||||
<p>Defines the number of lights. Should be equal to the length of the list
|
|
||||||
above (three times the number of lights).</p></li>
|
|
||||||
<li><p><code>-DEY=x,y,z</code></p>
|
|
||||||
|
|
||||||
<p>Defines the position of the viewer (the eyepoint) for the scene. The eye
|
|
||||||
is looking at the origin (0, 0, 0).</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Other Build Flags</h2>
|
|
||||||
|
|
||||||
<p>The original program bound the server to <code>INADDR_ANY</code> to allow everyone to
|
|
||||||
experience the server’s output. The Judges suggested that I instead restrict
|
|
||||||
the bind to <code>INADDR_LOOPBACK</code> to reduce security alarms. As a compliant veteran
|
|
||||||
of innumerable post-ship late feature additions, I have modified the <code>Makefile</code>
|
|
||||||
to inject the new code without destroying the beautiful spherical symmetry of
|
|
||||||
the source code. In addition, I have altered the word <code>sin_port</code> to the more
|
|
||||||
family-friendly version <code>win_port</code> to protect against curious impressionable
|
|
||||||
youth trying to learn about sockets on Internet.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,295 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most catty</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most catty</h1>
|
|
||||||
|
|
||||||
<p>Don Yang<br>
|
|
||||||
<a href="mailto:omoikane@uguu.org">omoikane@uguu.org</a><br>
|
|
||||||
<a href="http://uguu.org/">http://uguu.org/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make misaka
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This will build a bunch of versions of the code. See the author’s details for information on all of these builds.</p>
|
|
||||||
|
|
||||||
<p>To understand the various intermediate source files that are built, try:</p>
|
|
||||||
|
|
||||||
<pre><code>make understanding
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./horizontal_cat [files...] > [output]
|
|
||||||
./vertical_cat [files...] > [output]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>NOTE: Use - for standard input. For example:</p>
|
|
||||||
|
|
||||||
<pre><code>./vertical_cat - -
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>seq 1 12 | ./horizontal_cat - - -
|
|
||||||
|
|
||||||
./long_cat
|
|
||||||
./long_faat_cat
|
|
||||||
./long_fat_cat
|
|
||||||
./loong_cat
|
|
||||||
./loooong_cat
|
|
||||||
./loooooooong_cat
|
|
||||||
|
|
||||||
seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>There is more to cat than <a href="http://cheezburger.com/1680494336">mere cats</a>.<br>
|
|
||||||
Be they tall, fat, long or squat, this source code is sure to amuse.</p>
|
|
||||||
|
|
||||||
<h4>Slight diversion</h4>
|
|
||||||
|
|
||||||
<p>While one of the judges was reviewing this entry on the stern of the
|
|
||||||
<a href="http://www.noble-caledonia.co.uk/information/detail.asp?id=2&spid=76">Island Sky</a>
|
|
||||||
in the middle of the Atlantic Ocean waiting the
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Solar_eclipse_of_November_3,_2013">total solar eclipse of 2013</a>
|
|
||||||
the judge was stuck by a
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Flying_fish">flying fish</a>.
|
|
||||||
While result the impact was that the
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Port_wine">Port</a> from Portugal was lost, the
|
|
||||||
<a href="http://www.travelforpassion.com/grog-factory-cape-verde-santo-antao-cape-verde-1602-photo">Grog</a> from Cape Verde
|
|
||||||
and the laptop containing this entry was saved.</p>
|
|
||||||
|
|
||||||
<p>While I’m sure most cats would have preferred otherwise,
|
|
||||||
the flying fish was returned to <em>em</em>swim with the fishes<em>em</em>. :-)
|
|
||||||
No cats were harmed in the process of judging this entry.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Overview</h1>
|
|
||||||
|
|
||||||
<p>Misaka is a file concatenation utility, with at least two modes of
|
|
||||||
operation:</p>
|
|
||||||
|
|
||||||
<pre><code>gcc misaka.c -o horizontal_cat
|
|
||||||
./horizontal_cat [files...] > [output]
|
|
||||||
|
|
||||||
./horizontal_cat misaka.c misaka.c > misaka2.c
|
|
||||||
gcc misaka2.c -o vertical_cat
|
|
||||||
./vertical_cat [files...] > [output]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Where [files…] are a list of text file names. Use “-” to read from stdin.</p>
|
|
||||||
|
|
||||||
<h1>Details</h1>
|
|
||||||
|
|
||||||
<h2>Horizontal cat</h2>
|
|
||||||
|
|
||||||
<p>One of my favorite unix utilities is <em>cat</em>. The best thing about it was
|
|
||||||
that it was named “cat”. That, and it’s useful for quickly showing contents
|
|
||||||
of a file. Though it was primary meant for concatenating files, that
|
|
||||||
function only seem to work if I wanted to concatenate files vertically.</p>
|
|
||||||
|
|
||||||
<p>I thought the lack of horizontal concatenation must have been an oversight,
|
|
||||||
so I implemented this utility:</p>
|
|
||||||
|
|
||||||
<pre><code>gcc misaka.c -o horizontal_cat
|
|
||||||
./horizontal_cat files...
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p><em>horizontal_cat</em> concatenates files horizontally and write the output to
|
|
||||||
stdout. Each input file is padded with spaces on the right so that the
|
|
||||||
original text alignments are preserved.</p>
|
|
||||||
|
|
||||||
<p>If “-” is specified as a file name, <em>horizontal_cat</em> will read from stdin.
|
|
||||||
Unlike <em>cat</em>, <em>horizontal_cat</em> loads all input to memory first. Thus you
|
|
||||||
can specify “-” multiple times to get stdin multiplied horizontally. For
|
|
||||||
example, if you have seq(1) in your shell, you can add line numbers to both
|
|
||||||
sides of misaka.c like this:</p>
|
|
||||||
|
|
||||||
<pre><code>seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c -
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Vertical cat</h2>
|
|
||||||
|
|
||||||
<p>Because <em>horizontal_cat</em> must know the maximum width of all files before
|
|
||||||
writing any output, all files must be processed at least twice. To support
|
|
||||||
stdin, file must be buffered to memory. This lead to the feature that
|
|
||||||
<em>horizontal_cat</em> can be used to duplicate stdin.</p>
|
|
||||||
|
|
||||||
<p>Seems like the stdin doubling feature might be useful even for concatenating
|
|
||||||
files vertically, so I included a vertical mode. But supporting vertical
|
|
||||||
mode with command line options would be no fun. Instead, vertical mode is
|
|
||||||
enabled by concatenating the source code horizontally:</p>
|
|
||||||
|
|
||||||
<pre><code>./horizontal_cat misaka.c misaka.c > misaka2.c
|
|
||||||
gcc misaka2.c -o vertical_cat
|
|
||||||
./vertical_cat files...
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p><em>vertical_cat</em> works more or less like <em>cat</em>, except you can use
|
|
||||||
<em>vertical_cat</em> to duplicate stdin:</p>
|
|
||||||
|
|
||||||
<pre><code>./vertical_cat - -
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Long cat</h2>
|
|
||||||
|
|
||||||
<p>After <em>horizontal_cat</em> and <em>vertical_cat</em>, I thought, maybe all I really
|
|
||||||
wanted was just more cats. So I implemented one more mode, this one is
|
|
||||||
enabled by concatenating misaka.c vertically:</p>
|
|
||||||
|
|
||||||
<pre><code>./vertical_cat misaka.c misaka.c > misaka3.c
|
|
||||||
gcc misaka3.c -o long_cat
|
|
||||||
./long_cat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p><em>long_cat</em> outputs ASCII art of a cat to stdout. You can make this cat
|
|
||||||
exponentially longer by concatenating more files vertically (up to 31 levels
|
|
||||||
high, depending on sizeof(int) for your compiler):</p>
|
|
||||||
|
|
||||||
<pre><code>./vertical_cat misaka.c misaka.c misaka.c > misaka4.c
|
|
||||||
gcc misaka4.c -o loong_cat
|
|
||||||
|
|
||||||
./vertical_cat misaka.c misaka.c misaka.c misaka.c > misaka5.c
|
|
||||||
gcc misaka5.c -o loooong_cat
|
|
||||||
|
|
||||||
./vertical_cat misaka.c misaka.c misaka.c misaka.c misaka.c > misaka6.c
|
|
||||||
gcc misaka6.c -o loooooooong_cat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>If your terminal has really thin fonts, you can also make this output fatter
|
|
||||||
by concatenating files horizontally:</p>
|
|
||||||
|
|
||||||
<pre><code>./vertical_cat misaka.c misaka.c | ./horizontal_cat - - > misaka7.c
|
|
||||||
gcc misaka7.c -o long_fat_cat
|
|
||||||
|
|
||||||
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - - > misaka8.c
|
|
||||||
gcc misaka8.c -o long_faat_cat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Output width is determined by the first level of stacked programs, so a
|
|
||||||
triangle like the following will not have horizontally expanded output:</p>
|
|
||||||
|
|
||||||
<pre><code>./horizontal_cat misaka.c misaka.c | ./vertical_cat misaka.c - > misaka9.c
|
|
||||||
gcc misaka9.c -o same_as_long_cat
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Finally, if you lost track of how many misaka.c you have stacked together,
|
|
||||||
you can feed the source to a brainfuck interpreter to get a overview of how
|
|
||||||
the programs are stacked. Example:</p>
|
|
||||||
|
|
||||||
<pre><code>perl bf.pl misaka9.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This outputs:</p>
|
|
||||||
|
|
||||||
<pre><code>MISAKA
|
|
||||||
MISAKA MISAKA
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h1>Return value</h1>
|
|
||||||
|
|
||||||
<p><em>horizontal_cat</em> and <em>vertical_cat</em> will exit with zero status on success.</p>
|
|
||||||
|
|
||||||
<p>If any input file fails to open, <em>horizontal_cat</em> and <em>vertical_cat</em> will
|
|
||||||
report the offending file name to stdout, and exit with nonzero status.</p>
|
|
||||||
|
|
||||||
<p>If <em>horizontal_cat</em> and <em>vertical_cat</em> ran out of memory, they will exit
|
|
||||||
with nonzero status without outputting anything.</p>
|
|
||||||
|
|
||||||
<h1>Compatibility</h1>
|
|
||||||
|
|
||||||
<p><em>horizontal_cat</em> makes the following assumptions about input files:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> ASCII with LF end of line sequences. If CR-LF sequences are used, CR
|
|
||||||
characters will appear in the middle of output lines.</li>
|
|
||||||
<li> All characters are of equal width, even tab characters.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Misaka has been verified to work on these following compiler+OS
|
|
||||||
combinations:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> gcc 4.6.3 on Linux 3.5.0-41</li>
|
|
||||||
<li> gcc 4.4.5 on Linux 2.6.32-5</li>
|
|
||||||
<li> gcc 4.3.5 on JS/Linux 2.6.20</li>
|
|
||||||
<li> gcc 4.8.1 on Windows (Cygwin and MingW)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Misaka requires a C99 compiler due to the use of single line comments.
|
|
||||||
Misaka does not depend on any other C99 features.</p>
|
|
||||||
|
|
||||||
<h1>Obfuscation</h1>
|
|
||||||
|
|
||||||
<p>Main obfuscation is in having a C program that compiles when tiled
|
|
||||||
horizontally and vertically, while using single line comments in less than
|
|
||||||
half of the lines. <em>And</em> maintaining a meaningful layout while doing that.</p>
|
|
||||||
|
|
||||||
<p>There are other challenges too, of course, like getting a Brainfuck program
|
|
||||||
to tile horizontally and vertically. Really, tiling code of any sort
|
|
||||||
horizontally is an interesting exercise, I encourage everyone to try this
|
|
||||||
once.</p>
|
|
||||||
|
|
||||||
<p>Other features to look for:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> Peculiar bits that switches horizontal cat to vertical cat.</li>
|
|
||||||
<li> Run-length encoded long cat.</li>
|
|
||||||
<li> Symmetric and recycled variable names.</li>
|
|
||||||
<li> CRC of the source code in the source code.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>“gcc -Wall” should provide a hint to where the mode switch happens, it
|
|
||||||
does not output any irrelevant other warnings (verified on 4.6.3).</p>
|
|
||||||
|
|
||||||
<h1>Extra files</h1>
|
|
||||||
|
|
||||||
<p>Extra files included in my submission are informational only, they are not
|
|
||||||
needed for the program to work.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> bf.pl = a brainfuck interpreter, in case if you don’t have one handy.</li>
|
|
||||||
<li> spoiler.html = making of this program.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>About Misaka</h1>
|
|
||||||
|
|
||||||
<p>The name, layout, and functionality of Misaka is inspired by a particular
|
|
||||||
stackable figure:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> <a href="http://google.co.jp/search?q=%E3%83%9F%E3%82%B5%E3%82%AB%E7%9B%9B%E3%82%8A&tbm=isch">Google images</a></li>
|
|
||||||
<li> <a href="http://main.kotobukiya.co.jp/figure/tsubucole_tmi_misakamori/">Kotobukiya</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Smallest large system simulator</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Smallest large system simulator</h1>
|
|
||||||
|
|
||||||
<p>Yves-Marie Morgan<br>
|
|
||||||
<a href="mailto:yves-marie.morgan@parrot.com">yves-marie.morgan@parrot.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make morgan1
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo "2013/10/03" | ./morgan1
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo "1985/10/28" | ./morgan1
|
|
||||||
|
|
||||||
echo "1996/12/31" | ./morgan1
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Try pressing the arrow keys when your focus is in the window.</p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>To verify the output, try echoing the date of an evening with a clear sky.
|
|
||||||
Use binoculars and/or telescope as needed. In some cases you may need
|
|
||||||
to wait for a better time of the evening. In a few cases, such as
|
|
||||||
the South Pole in the summer, you may need to move to a different
|
|
||||||
observing site.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>Instructions</h1>
|
|
||||||
|
|
||||||
<p>It displays the position of the 8 planets of the solar system around the sun.
|
|
||||||
The date given in the command line is in the format YYYY/MM/DD (year, month and
|
|
||||||
day). The direction keys can be used to move in time :
|
|
||||||
Left : go back 1 day.
|
|
||||||
Right : go forward 1 day.
|
|
||||||
Down : go back 20 days.
|
|
||||||
Up : go forward 20 days.</p>
|
|
||||||
|
|
||||||
<p>It handles correctly all leap years and the switch between julian calendar and
|
|
||||||
gregorian calendar (10 days missing between 1582/10/04 and 1582/10/15).</p>
|
|
||||||
|
|
||||||
<p>The scale is logarithmic to be able to display the 8 planets without having
|
|
||||||
Mercury, Venus, Earth and Mars squizzed around the sun.</p>
|
|
||||||
|
|
||||||
<p>The size is not proportinal either.</p>
|
|
||||||
|
|
||||||
<h1>Bonus</h1>
|
|
||||||
|
|
||||||
<p>It also displays the position of 2 famous comets during their last approach :
|
|
||||||
- The first one arround the third IOCCC.
|
|
||||||
- The second one between the thirteenth and fourteenth IOCCC.</p>
|
|
||||||
|
|
||||||
<h1>Limitations</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>ASCII character set is assumed.</li>
|
|
||||||
<li>a c99 compiler is required (for some math.h functions).</li>
|
|
||||||
<li>The position should be correct for years between (-1000; +3000)</li>
|
|
||||||
<li>The approximations done in the formula are OK for displaying the
|
|
||||||
position around the sun but not for other applications like ephemeride or
|
|
||||||
sky view from Earth (angles may be off by 1 or 2 degrees sometimes).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Obfuscation</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Reuse of 1 letter variables.</li>
|
|
||||||
<li>Only the main function with some for loops.</li>
|
|
||||||
<li>Constants for orbital elements encoded in a string.</li>
|
|
||||||
<li>Hexadecimal and decimal values used inconsitentely.</li>
|
|
||||||
<li>Comparisons order are not consitent.</li>
|
|
||||||
<li>A lot of stuff is done in the different parts of the for loop.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Compilation warnings</h1>
|
|
||||||
|
|
||||||
<p>with gcc 4.7.2 on Linux Ubuntu 12.10 :
|
|
||||||
* prog.c:38:3: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
|
||||||
* prog.c:40:34: warning: value computed is not used [-Wunused-value]
|
|
||||||
* prog.c:56:6: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
|
||||||
* prog.c:58:50: warning: value computed is not used [-Wunused-value]
|
|
||||||
* prog.c:61:5: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]</p>
|
|
||||||
|
|
||||||
<p>with clang 3.1 on Linux Ubuntu 12.10 :
|
|
||||||
* prog.c:38:49: warning: ‘&&’ within ‘||’ [-Wlogical-op-parentheses]
|
|
||||||
* prog.c:38:27: warning: ‘&&’ within ‘||’ [-Wlogical-op-parentheses]
|
|
||||||
* prog.c:55:13: warning: ‘&&’ within ‘||’ [-Wlogical-op-parentheses]
|
|
||||||
* prog.c:56:14: warning: ‘&&’ within ‘||’ [-Wlogical-op-parentheses]</p>
|
|
||||||
|
|
||||||
<p>Due to most parentheses and braces removed when unecessary.</p>
|
|
||||||
|
|
||||||
<p>To verify the display, you can look at one of this programs :
|
|
||||||
* xephem : http://www.clearskyinstitute.com/xephem/
|
|
||||||
* homeplanet : http://www.fourmilab.ch/homeplanet/
|
|
||||||
* http://www.theplanetstoday.com/</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most playfully versatile</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most playfully versatile</h1>
|
|
||||||
|
|
||||||
<p>Yves-Marie Morgan<br>
|
|
||||||
<a href="mailto:yves-marie.morgan@parrot.com">yves-marie.morgan@parrot.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code> make morgan2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./morgan2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>For the console version (ncurses)</p>
|
|
||||||
|
|
||||||
<p>or</p>
|
|
||||||
|
|
||||||
<pre><code>./morgan2 X
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>For the graphical version (X11)</p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>The judges enjoyed playing the game almost to completion; if we remember correctly,
|
|
||||||
we managed to place 59 or 60 dominos. We wonder, what would be faster: to play the game to completion
|
|
||||||
or to write an unobfuscated version of it?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This program is a domino game. The goal is to place dominos on the 8x8 grid.
|
|
||||||
Each domino is made of 6 squares of the color red or green. To place a domino,
|
|
||||||
at least one of it side shall match the other side of another domino.</p>
|
|
||||||
|
|
||||||
<h1>How to play</h1>
|
|
||||||
|
|
||||||
<h2>Start of the game</h2>
|
|
||||||
|
|
||||||
<p>At the start of the game, the first domino is placed randomly on the grid. You
|
|
||||||
get another domino to place by selecting one empty position in the stack on the
|
|
||||||
right. You can have to 8 dominos pending at any time.</p>
|
|
||||||
|
|
||||||
<h2>Moving in the stack</h2>
|
|
||||||
|
|
||||||
<p>Use <code>Up</code> and <code>Down</code> key to move the cursor in the stack. Press <code>Enter</code> to either</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>reveal a new domino if the position was empty.</li>
|
|
||||||
<li>select the domino to try to place it if the position was not empty.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The currently selected domino is indicated on the top right.</p>
|
|
||||||
|
|
||||||
<h2>Placing a domino</h2>
|
|
||||||
|
|
||||||
<p>Once a domino has been selected, the cursor moves to the grid. Use <code>Up</code>, <code>Down</code>,
|
|
||||||
<code>Left</code> and <code>Right</code> keys to move in the grid. Press <code>Enter</code> on an empty position
|
|
||||||
to place the domino.</p>
|
|
||||||
|
|
||||||
<p>To go back to selection mode, press <code>Enter</code> on an occupied position.</p>
|
|
||||||
|
|
||||||
<p>The domino can be place in an empty position if all its neighbour have matching
|
|
||||||
sides and the domino has at least one neighbour.</p>
|
|
||||||
|
|
||||||
<h2>Scoring</h2>
|
|
||||||
|
|
||||||
<p>First, depending on the number of dominos pending in the stack, a bonus is
|
|
||||||
accorded :
|
|
||||||
* 1 domino in the stack : 8 points.
|
|
||||||
* 2 dominos in the stack : 4 points.
|
|
||||||
* 3 or 4 dominos in the stack : 2 points.
|
|
||||||
* 5 or more dominos in the stack : 0 point.</p>
|
|
||||||
|
|
||||||
<p>Then the bonus is multiplied by the number of matching neighbor the placed domino
|
|
||||||
has (1, 2, 3 or 4). This is added to the score.</p>
|
|
||||||
|
|
||||||
<p>Finally, the total score is divided by the number of dominos placed (1 - 64).</p>
|
|
||||||
|
|
||||||
<p>The 3 numbers on display represent : the total score, the fill count and the
|
|
||||||
final score (total score divided by fill count).</p>
|
|
||||||
|
|
||||||
<h2>End of the game</h2>
|
|
||||||
|
|
||||||
<p>The game is finished when no more domino can be placed and you either :
|
|
||||||
* filled the complete grid.
|
|
||||||
* have 8 pending dominos in the stack.
|
|
||||||
* no more domino can be revealed in the stack (more than 56 dominos placed on
|
|
||||||
the grid).</p>
|
|
||||||
|
|
||||||
<p><strong>Note</strong> There is no real end of game detection implemented in the program,
|
|
||||||
simply press <code>q</code> when you have finished…</p>
|
|
||||||
|
|
||||||
<h2>Strategy</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Try to minimize the number of dominos revealed in the stack. The lower the number,
|
|
||||||
the higher the bonus.</li>
|
|
||||||
<li>Each domino is unique and all combination of colors exists, so keep track
|
|
||||||
of what is already place and what is left.</li>
|
|
||||||
<li>Make sure you don’t render dead some positions by preventing a future placement
|
|
||||||
If the corner of domino does not match another corner in diagonal, the move
|
|
||||||
is valid but will prevent some future moves.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Limitations</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>ASCII character set is assumed.</li>
|
|
||||||
<li>Requires both ncurses and X11 at compilation and runtime, but selection could
|
|
||||||
be done at compilation with some extra code (mainly empty stubs).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Obfuscation</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>1 letter identifier, reused when possible.</li>
|
|
||||||
<li>1 algorithm, 2 different kind of display (ncurses and X11) mixed.</li>
|
|
||||||
<li>No parameters to functions, all variables are global and shared.</li>
|
|
||||||
<li>Some variables are not initialized if they have a known value at the time of use.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Compilation warnings</h1>
|
|
||||||
|
|
||||||
<p>with gcc 4.7.2 on Linux Ubuntu 12.10 :
|
|
||||||
* prog.c:46:65: warning: value computed is not used [-Wunused-value]</p>
|
|
||||||
|
|
||||||
<p>with clang 3.1 on Linux Ubuntu 12.10 :
|
|
||||||
* prog.c:23:24: warning: adding ‘int’ to a string does not append to the string [-Wstring-plus-int]</p>
|
|
||||||
|
|
||||||
<p><strong>!!!!! HAVE FUN !!!!!</strong></p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most poetic use of strings</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most poetic use of strings</h1>
|
|
||||||
|
|
||||||
<p>Arch D. Robison<br>
|
|
||||||
<a href="mailto:arch.d.robison@gmail.com">arch.d.robison@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make robison
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./robison
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo '1*2*3*4*5*6*7*8*9%1000' | ./robison
|
|
||||||
echo '100000000000000000000*(20*(1+(99477941840441*50)))/31664812345028528' | ./robison
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Of integers this prog does a lot,
|
|
||||||
plus minus, div times (and what not).</p>
|
|
||||||
|
|
||||||
<p>And modulus if remainders the needing,
|
|
||||||
on standard input percent be feeding.</p>
|
|
||||||
|
|
||||||
<p>More than one line can thru give input,
|
|
||||||
when interactive one values more than thruput.</p>
|
|
||||||
|
|
||||||
<p>With cut and paste and some time,
|
|
||||||
one can compute M(23209).</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>Oh, The Strings You Can C!</h2>
|
|
||||||
|
|
||||||
<p>I love the C language; its tersness is tops.<br>
|
|
||||||
But the thing I abhor is numerical ops!</p>
|
|
||||||
|
|
||||||
<p>No shifting, division, remainder, or times.<br>
|
|
||||||
No increment, decrement, or subscripting blech,<br>
|
|
||||||
No addition, subtraction, or bitwise bool glop.<br>
|
|
||||||
As for pointer arithmetic – totally yech!</p>
|
|
||||||
|
|
||||||
<p>But I do have a pref'rence, for pointer deref'rence.<br>
|
|
||||||
I find NOTS are a bang, and relations a ball.<br>
|
|
||||||
I like calling routines, and recursions in essence. <br>
|
|
||||||
But the thing I like MOST is a string dot h CALL!</p>
|
|
||||||
|
|
||||||
<p>With mem copy I copy, and mem set I clear. <br>
|
|
||||||
Take string len of this, and string copy that.<br>
|
|
||||||
From my keyboard I pause, to hear subroutines dear: <br>
|
|
||||||
The bark of string chrr, and the purr of string CAT!</p>
|
|
||||||
|
|
||||||
<p>One tiny detail that could lead to defeat.<br>
|
|
||||||
From where an arg points: string calls only go forth,<br>
|
|
||||||
So how to go back, to be Turing complete?<br>
|
|
||||||
From standard dot H, to the rescue, q SORT!</p>
|
|
||||||
|
|
||||||
<p>My fixation might hint at a textual bent. <br>
|
|
||||||
Does my program compose a tatoo for your shin? <br>
|
|
||||||
Play crosswords or translate from Urdu to Tzouby?<br>
|
|
||||||
To give it a whirl, just punch 2 + 2 in.</p>
|
|
||||||
|
|
||||||
<p>You can add, do division, and multiply too.<br>
|
|
||||||
Take unary minus and also subtract.<br>
|
|
||||||
Summing hairs of a walrus? No longer a fuss.<br>
|
|
||||||
Parenthetical grouping – no pushing a stack!</p>
|
|
||||||
|
|
||||||
<p>Try dividing a googol by one forty three, <br>
|
|
||||||
Subtract an octillion - it’s simply divine.<br>
|
|
||||||
To compute a remainder, inscribe a percent.<br>
|
|
||||||
For the sign of the answer, see C ninety nine!</p>
|
|
||||||
|
|
||||||
<p>A hundred and twenty five digits or so,<br>
|
|
||||||
Are the lengthiest figures the program can gnash.<br>
|
|
||||||
Go over that limit, by even a digit: <br>
|
|
||||||
Risk incorrect answers, or witness a crash!</p>
|
|
||||||
|
|
||||||
<p>Say, say, does it have octal or binary zen?<br>
|
|
||||||
What about duodecimal, ternary, hex? <br>
|
|
||||||
Try the base as an option (of course in base ten)<br>
|
|
||||||
Any base two to twenty – for that is the specs.</p>
|
|
||||||
|
|
||||||
<p>Use lowercase in trans-decimal radix, <br>
|
|
||||||
Divide <em>babbage</em> (in base seventeen) by <em>cafe</em> – <br>
|
|
||||||
a nice <em>fad</em>, but avoid a division by nix: <br>
|
|
||||||
No errant result, but you could wait all day!</p>
|
|
||||||
|
|
||||||
<p>To grok the internals, ask Queen Cleopatra,<br>
|
|
||||||
or King Tutankhamun; for him it’s a romp. <br>
|
|
||||||
Addition by cats, and if given two figures,<br>
|
|
||||||
to tell which is bigger, sort down and string CMP!</p>
|
|
||||||
|
|
||||||
<p>Unlawful subtraction, a grade school infraction, <br>
|
|
||||||
starts at the left and works to the right. <br>
|
|
||||||
Yet more innovation: like Henry Ford’s cars,<br>
|
|
||||||
With a pound and define, mass production of vars!</p>
|
|
||||||
|
|
||||||
<p>The moral is clear, for programmers out there: <br>
|
|
||||||
With the C lib for strings, you can hack with a flair.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best use of port 1701</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best use of port 1701</h1>
|
|
||||||
|
|
||||||
<p>Michael Birken<br>
|
|
||||||
<a href="mailto:o__1@hotmail.com">o__1@hotmail.com</a><br>
|
|
||||||
<a href="http://www.meatfighter.com/">http://www.meatfighter.com/</a></p>
|
|
||||||
|
|
||||||
<p>Alexander Prishchepov<br>
|
|
||||||
<a href="https://github.com/sans17/">https://github.com/sans17/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog < some_secret_or_something
|
|
||||||
|
|
||||||
./prog http://host[:port]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog.c
|
|
||||||
|
|
||||||
./prog http://127.0.0.1:1701
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Port 1701? Well this is not the l2f registered TCP/1701 protocol.
|
|
||||||
Sniff the traffic to/from that port. You will see HTTP client
|
|
||||||
and server traffic. The HTML content you may see is static and
|
|
||||||
immutable. Nothing funny with the HTTP status codes. Even the
|
|
||||||
timestamp cookie, once set, remains static throughout the
|
|
||||||
session. The data appears to not be transmitted within the
|
|
||||||
binary content communicated between client and server.</p>
|
|
||||||
|
|
||||||
<p>So how does this program do it? A trek though the cloak of
|
|
||||||
obfuscation awaits the reader of the source!</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Abstract</h3>
|
|
||||||
|
|
||||||
<p>When launched in web server mode, this application appears to deliver nothing more than a static HTML page. But, in actuality, it provides covert file transfer over the Internet. This is demonstrated by starting the application as a client-side downloader. The hidden transmitted data cannot be reconstructed or even detected from the binary content of the traffic between the client and the server.</p>
|
|
||||||
|
|
||||||
<h3>To run web server</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog < secret_file_to_be_downloaded
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Try using the program’s source code as the secret file:</p>
|
|
||||||
|
|
||||||
<pre><code>./prog < prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run client-side downloader</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog http://host[:port]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The optional port defaults to 1701. If the web server instance is started on the same box, try:</p>
|
|
||||||
|
|
||||||
<pre><code>./prog http://127.0.0.1:1701
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>It will incrementally display the contents of the hidden file at a rate of approximately 1 baud.</p>
|
|
||||||
|
|
||||||
<p>The client-side downloader will automatically terminate if the web server is bounced.</p>
|
|
||||||
|
|
||||||
<h3>HTML content</h3>
|
|
||||||
|
|
||||||
<p>Plug the URL into a browser to view a static HTML page containing ASCII artwork.</p>
|
|
||||||
|
|
||||||
<h3>Exploration</h3>
|
|
||||||
|
|
||||||
<p>Studying the network traffic will reveal that the HTML content is static and immutable, the HTTP request and response fields do not contain anything remarkable, HTTP status and error codes are not exploited, no unusual or deprecated features of HTTP are used, and while the cookie is based on a timestamp, its value also remains unchanged throughout the session. As mentioned in the abstract, the data is not transmitted within the binary content communicated between the client and the server. A full explanation of the protocol appears below, but feel free to explore before reading further.</p>
|
|
||||||
|
|
||||||
<h3>Inspiration</h3>
|
|
||||||
|
|
||||||
<p>The inspiration for this program comes from <em>Star Trek VI: The Undiscovered Country</em>, specifically the final confrontation between the <em>Enterprise</em> and the enhanced prototype Klingon Bird of Prey. The definitive feature of the prototype was its ability to fire while cloaked. But, perhaps even more impressive was its able to keep an open communication channel with the <em>Enterprise</em> throughout the battle, enabling the antagonist Chang to taunt Captain Kirk with Shakespearian quotes while he slowly pelted his ship with torpedoes. Normally, cloaked vessels must maintain silent running to avoid detection.</p>
|
|
||||||
|
|
||||||
<p>The battle is commemorated in the form of ASCII artwork depicting the ships faced head-to-head in the page delivered by the web server. Plus, the program source code is formatted in the shape of a Klingon Bird of Prey. The code itself includes a number of Star Trek references: the registry number of the <em>Enterprise</em> (NCC-1701) is defined as a constant; variable names spell out Cpt. James T. Kirk and Odo (the Deep Space 9 character was played by René Auberjonois who also appeared as Colonel West in <em>Star Trek VI</em>); the STARDATE constant makes timing configurable; and, the constant k stands for Khan (in the final engagement in <em>Star Trek II: The Wrath of Khan</em>, the damaged <em>Enterprise</em> managed to disable the USS <em>Reliant</em>’s shield generator by accessing its prefix code: 16309).</p>
|
|
||||||
|
|
||||||
<h3>Secondary size limit</h3>
|
|
||||||
|
|
||||||
<p>As obligated by a program that employs 23rd century cloaking technology, when the source is fed as input to IOCCC size tool version 2014-09-23-v19, and the -i command line option is used, the value printed is 0.</p>
|
|
||||||
|
|
||||||
<h3>Transmission protocol revealed</h3>
|
|
||||||
|
|
||||||
<p>The client-side downloader relies on the response time of the web server rather than the binary content of the response. The server transmits 1 nibble at a time by counting to the nibble value via a sequence of rapid responses terminated by a long response. For instance, the value 5 would be transmitted by making a series of requests that result in 5 near instantaneous responses followed by a half-second delayed response. The long delay is skipped in the case of 15, the maximal nibble value. With the aid of an ASCII table, it is actually possible to read the nibbles by repeatedly pressing the refresh button within a browser and observing the page refresh delay.</p>
|
|
||||||
|
|
||||||
<p>Nibble Count Coding (file transfer protocol NCC-1701) is faster than transmitting each individual bit as a short or long delay because it sends each byte with 2 long delays whereas communicating individual bits requires 8 long delays in the worst case scenario. In fact, Nibble Count Coding is faster than applying Huffman Coding since that is designed to produce compact codes under the assumption that the bit value does not affect transmission time.</p>
|
|
||||||
|
|
||||||
<p>The server relies on the cookie to identify each client uniquely, enabling it to transfer the sequence independently to each client.</p>
|
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
|
||||||
|
|
||||||
<p>As with all network communication, accurate transmission of data relies on the nature of hardware revealed through statistics and timeouts set accordingly. The long delay is arbitrarily set to 0.5 seconds. This is microsecond tunable via the STARDATE constant defined at the top of the source code. Increase the value in the event of transmission errors. Decrease the value to download faster and less reliably.</p>
|
|
||||||
|
|
||||||
<p>The NCC constant is the web server port number.</p>
|
|
||||||
|
|
||||||
<h3>Obfuscations</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The ASCII artwork is compressed using run-length encoding.</li>
|
|
||||||
<li>One long string stores a series of strings concatenated together and referenced via pointers.</li>
|
|
||||||
<li>The long string is shift encrypted.</li>
|
|
||||||
<li>Short and meaningless identifiers are used throughout.</li>
|
|
||||||
<li>Reversed array indexing was applied immoderately.</li>
|
|
||||||
<li>Minus is used in place of not-equals.</li>
|
|
||||||
<li>O and l were selected for their resemblance to 0 and 1 respectively.</li>
|
|
||||||
<li>Standard constants and ASCII characters were replaced with their respective numerical values.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Compiler warnings</h3>
|
|
||||||
|
|
||||||
<p>For space considerations, the following include statements were dropped resulting in compiler warnings:</p>
|
|
||||||
|
|
||||||
<pre><code>#include <asm/byteorder.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/unistd.h>
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>It may be necessary to restore some of these under certain environments.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most underscored argument</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most underscored argument</h1>
|
|
||||||
|
|
||||||
<p>Ferenc Deak<br>
|
|
||||||
<a href="mailto:fritzone@gmail.com">fritzone@gmail.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make deak
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>Changing bounding box coordinates in the source to explore
|
|
||||||
various regions of the fractal.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>We consider this entry a tribute to all “Abuse of the C preprocessor”
|
|
||||||
and Mandelbrot fractal drawing entries we’ve seen over the years.</p>
|
|
||||||
|
|
||||||
<p>We liked the use of unary notation facilitated by variadic macros.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>The application was written on a standard Ubuntu 14.04 and tested with
|
|
||||||
gcc 4.9.1 and clang 3.5 on 64 bit system (though this should not matter).
|
|
||||||
The application makes no assumption regarding any system specific settings,
|
|
||||||
and it only needs a console to run. The provided Makefile is just to have
|
|
||||||
an easy compilation. I don’t see any problems porting it to different
|
|
||||||
compiler/system as long as it supports the C99 standard.</p>
|
|
||||||
|
|
||||||
<h3>The application</h3>
|
|
||||||
|
|
||||||
<p>The purpose of the application is mainly to illustrate the weird possibilities
|
|
||||||
of the C preprocessor, than to be a full featured console mode Mandelbrot
|
|
||||||
drawer. There are tools much better suited for drawing fractals.</p>
|
|
||||||
|
|
||||||
<p>The usage of recognizable elements from the C programming language in the
|
|
||||||
application source code is intentionally kept to a bare minimum. If this phrase
|
|
||||||
would not be true, the application would be the following:</p>
|
|
||||||
|
|
||||||
<pre><code> double _[]={-2
|
|
||||||
,1,-1.3 ,1.3, 0, 0,0,0
|
|
||||||
,0 ,0,50, 80, 0,0,0 ,255
|
|
||||||
, 8,0}; int main (
|
|
||||||
int j) {if (j== 1 ){ if(
|
|
||||||
_[12] >_[10] )_[17]=1 ;} if
|
|
||||||
(_[13] >_[11 ] ||_[17]==1) return
|
|
||||||
;_[6] = _ [13] / _[11]*(_[1]-_[ 0])
|
|
||||||
+_[ 0]; _ [7]=_[12]/_[10]*(_[3]-_[2] )+_
|
|
||||||
[2];_[8]=_[9]=_[14]=0;l2:_[4]=_[8] * _ [8]
|
|
||||||
;_[ 5]= _ [9]*_[9];_[9]=2*_[8]*_[9]+ _[7
|
|
||||||
];_[8 ] = _ [ 4 ]-_[5]+_[6];_[14 ]++
|
|
||||||
;if((_ [14]< _ [15])&&(_[4]+ _[ 5]
|
|
||||||
<_[16 ])) goto l2; putchar(
|
|
||||||
" #@*+ "[( int) _[14]%
|
|
||||||
5 ]);_ [13 ] ++ ; main (
|
|
||||||
0) ;_[12]++; _[13] =0
|
|
||||||
;if(_ [17] !=1) putchar
|
|
||||||
(0xa); main(1);}
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The application expects no parameters, the only way you can change the behaviour
|
|
||||||
is to modify the source code at the indicated location: the line
|
|
||||||
<code>/* <-- Configure here: X1, X2, Y1, Y2 */</code> is intentionally not obfuscated so
|
|
||||||
that the adventurous programmer can manually modify the coordinates of the
|
|
||||||
fractal to be drawn on the screen.</p>
|
|
||||||
|
|
||||||
<h3>Compiler warnings</h3>
|
|
||||||
|
|
||||||
<p>Yes, unfortunately there are compiler warnings of the kind “initialization makes
|
|
||||||
integer from pointer without a cast” the provided Makefile automatically
|
|
||||||
disables them.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most square (YODA award)</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most square (YODA award)</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog > foo.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog > main.c
|
|
||||||
|
|
||||||
make main
|
|
||||||
./main Hello
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Big terminals with tiny fonts have their uses in certain cases.
|
|
||||||
One of them is:</p>
|
|
||||||
|
|
||||||
<pre><code>./prog < prog.c > treacle.c
|
|
||||||
make treacle
|
|
||||||
# or instead of make: cc -Wno-empty-body -funsigned-char treacle.c -o treacle
|
|
||||||
./treacle
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>When using a smart phone to read the output, you may need to
|
|
||||||
step back to see the bigger picture because that picture is worth
|
|
||||||
more than 1000 words.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<p>You may want to use a large display with a very small-font terminal.</p>
|
|
||||||
|
|
||||||
<h3>Spoiler</h3>
|
|
||||||
|
|
||||||
<p>Decompress <code>src.zip</code> if you need explanation.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best use of bioinformatics</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best use of bioinformatics</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog < input > output
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo Hello | ./prog
|
|
||||||
|
|
||||||
echo Hello | ./prog > hello.c
|
|
||||||
make hello
|
|
||||||
./hello
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>If you look closely at the source, you will see code that appears
|
|
||||||
to puts C code that includes itself. How and why? Perhaps it is
|
|
||||||
in the DNA code of the code? Perhaps there are 23 reasons? :-)</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<p>This chromosome program synthesizes a double helix.
|
|
||||||
The helix can also be compiled as a C program.</p>
|
|
||||||
|
|
||||||
<p>Enjoy DNA programming!</p>
|
|
||||||
|
|
||||||
<h3>For more information / backgroud reading:</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>This program was inspired by Acme::DoubleHelix:
|
|
||||||
http://search.cpan.org/~xern/Acme-DoubleHelix-0.01/</p></li>
|
|
||||||
<li><p>The synthesized helix just includes the original program at the head.
|
|
||||||
Do you see how <code>prog.c</code> determines whether it was invoked as a standalone program or included as a header file?
|
|
||||||
Note that it does not use any gcc extension such as <code>__INCLUDE_LEVEL__</code>.</p></li>
|
|
||||||
<li><p>The synthesized helix of course follows the base-pairing rules for DNA:
|
|
||||||
A is bonding only to T, and C is bonding only to G.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,321 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Homage to a classic game</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Homage to a classic game</h1>
|
|
||||||
|
|
||||||
<p>Sandro Maffiodo<br>
|
|
||||||
<a href="mailto:smaffer@gmail.com">smaffer@gmail.com</a><br>
|
|
||||||
<a href="http://www.assezeta.com/sandromaffiodo">http://www.assezeta.com/sandromaffiodo</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>cat giana.level | ./prog 320 200 1000 300 192 168 giana.rgba giana8.wav 5459393
|
|
||||||
|
|
||||||
cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679 && telnet towel.blinkenlights.nl
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>A classic for a particular generation. Like all good programs, being data
|
|
||||||
driven means you can do fun things in small spaces.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<p>Use tabsize=4 to see the magic</p>
|
|
||||||
|
|
||||||
<pre><code>./expand -t 4 < prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The program returns 0 if the user win or <em>not-zero</em> if loose so you can test it and make something useful (or not), like that:</p>
|
|
||||||
|
|
||||||
<pre><code>cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679 && telnet towel.blinkenlights.nl
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This is an engine for <strong>Platform Games</strong>. It can be used to create games like the legendary <a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Super Mario Bros</a>.
|
|
||||||
With this simple and clear sourcecode you can create all the games you want, for free!</p>
|
|
||||||
|
|
||||||
<p>In my two tests i tried to create one level of <a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Super Mario Bros</a> and one of <a href="http://en.wikipedia.org/wiki/The_Great_Giana_Sisters">The Great Giana The Sisters</a>.
|
|
||||||
Both games are classic <em>platform games</em> and both share the same fundamental rules:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>there is a player</li>
|
|
||||||
<li>there is a powerup that can change the look of the player and/or give to him/her more power!</li>
|
|
||||||
<li>there are walls, floors and ceilings. the player can move and jump over these type of obstacles but cannot walk through them</li>
|
|
||||||
<li>there are enemies and, if the player collides with an enemy, the player dies or loses its powers</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Regards running under Mac OS X</h3>
|
|
||||||
|
|
||||||
<p>The color of the sky is wrong on MacOS. You need to flip some bytes from the last parameter of the program:</p>
|
|
||||||
|
|
||||||
<pre><code>MARIO LAST PARAMETER: 4292124159
|
|
||||||
|
|
||||||
GIANA LAST PARAMETER: 3243070463
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Regarding how to compile</h3>
|
|
||||||
|
|
||||||
<p>The code requires libSDL1.X.</p>
|
|
||||||
|
|
||||||
<p>The build process will generate some warnings (60~ on clang) about:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><strong>incompatible pointer types</strong>: because all pointers are declared to <em>int</em> or <em>char</em>, to save tokens</li>
|
|
||||||
<li><strong>type specifier missing, defaults to ‘int’</strong>: because i need to save tokens</li>
|
|
||||||
<li><strong>using the result of an assignment as a condition without parentheses</strong>: because while(c=getchar()) is not evil</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>How it works</h3>
|
|
||||||
|
|
||||||
<h2>Parameters</h2>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li>Window width</li>
|
|
||||||
<li>Window height</li>
|
|
||||||
<li>Level width</li>
|
|
||||||
<li>Level height</li>
|
|
||||||
<li>Sprites image width</li>
|
|
||||||
<li>Sprites image height</li>
|
|
||||||
<li>Filename of the sprites image (raw RGBA image)</li>
|
|
||||||
<li>Filename of the music (WAVE 8000 Hz 8bit Mono)</li>
|
|
||||||
<li>Sky color. This number depends on the system where you run the program. See <strong>NOTE on MacOS</strong></li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Sprites</h2>
|
|
||||||
|
|
||||||
<p>The program read a single image that contains all the game sprites. The image must be a grid of 8xN sprites. The size of a single sprite must be square. The program calculates the size in this way:</p>
|
|
||||||
|
|
||||||
<pre><code>sprite_size = image_width / 8
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Each sprite is identified by its position inside the grid, counting line by line, from left to right (for example sprite 0 is the top left sprite in the grid, sprite 8 is the first sprite of the second row of the grid).</p>
|
|
||||||
|
|
||||||
<p>Some positions of the grid have a predefined purpose:</p>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th align="left">Position </th>
|
|
||||||
<th align="left"> Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td align="left">0 </td>
|
|
||||||
<td align="left"> Player stand right</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">1 </td>
|
|
||||||
<td align="left"> Player walk right frame 0</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">2 </td>
|
|
||||||
<td align="left"> Player walk right frame 1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">3 </td>
|
|
||||||
<td align="left"> Player jump right</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">4 </td>
|
|
||||||
<td align="left"> Player stand left</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">5 </td>
|
|
||||||
<td align="left"> Player walk left frame 0</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">6 </td>
|
|
||||||
<td align="left"> Player walk left frame 1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">7 </td>
|
|
||||||
<td align="left"> Player jump left</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">8 <em>(second row)</em> </td>
|
|
||||||
<td align="left"> Super player stand right</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">9 </td>
|
|
||||||
<td align="left"> Super player walk right frame 0</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">10 </td>
|
|
||||||
<td align="left"> Super player walk right frame 1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">11 </td>
|
|
||||||
<td align="left"> Super player jump right</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">12 </td>
|
|
||||||
<td align="left"> Super player stand left</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">13 </td>
|
|
||||||
<td align="left"> Super player walk left frame 0</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">14 </td>
|
|
||||||
<td align="left"> Super player walk left frame 1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">15 </td>
|
|
||||||
<td align="left"> Super player jump left</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">24 </td>
|
|
||||||
<td align="left"> Player dead</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">32 </td>
|
|
||||||
<td align="left"> Player win</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">40 </td>
|
|
||||||
<td align="left"> Super player win</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
<p>All the others sprites can be used as you want, depending on the game you want to create.</p>
|
|
||||||
|
|
||||||
<h2>Levels</h2>
|
|
||||||
|
|
||||||
<p>The program reads the level description from <strong>stdin</strong>.</p>
|
|
||||||
|
|
||||||
<p>The level description is a sequence of rows where each row describe an object. You can input as many objects as you want but the maximum number of objects handled by the program is 333. You can modify this value by editing the source here:</p>
|
|
||||||
|
|
||||||
<pre><code>C[333*7],d=333;
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Each row have six columns:</p>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li>Screen X: x position of the object in the level</li>
|
|
||||||
<li>Screen Y: y position of the object in the level</li>
|
|
||||||
<li>Sprite: id of the sprite to be used for the object</li>
|
|
||||||
<li>CLASSFLAGS: a bitmask that describe how the object behaves</li>
|
|
||||||
<li>CLASSPARAM0: a parameter that depends on CLASSFLAGS</li>
|
|
||||||
<li>CLASSPARAM1: a parameter that depends on CLASSFLAGS</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<p>CLASSFLAGS must be a combination (bitwise or) of some of these constants:</p>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th align="left">NAME </th>
|
|
||||||
<th align="left"> CONSTANT </th>
|
|
||||||
<th align="left"> CLASS</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td align="left">ENEMY </td>
|
|
||||||
<td align="left"> 1 </td>
|
|
||||||
<td align="left"> An enemy. CLASSPARAM0 can be 0 if the enemy don’t move, 1 if the initial move direction is right, -1 if direction is left. All enemies that walk will change its direction after 20 pixels. The sprite of an enemy must have 2 others adjacent sprites: SPRITE-1, used when the enemy die, and SPRITE+1, used when it walks</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">BLOCK </td>
|
|
||||||
<td align="left"> 2 </td>
|
|
||||||
<td align="left"> A wall. Player can walk over the object but can not pass through it</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">GIFT BLOCK </td>
|
|
||||||
<td align="left"> 4 </td>
|
|
||||||
<td align="left"> When the player hits the object from below, a new object is created. CLASSFLAGS of the new object is defined in CLASSPARAM0. The sprite used for the new object is defined in CLASSPARAM1. The sprite of the gift object must have an adjacent sprite: SPRITE+1, used when the block is hit</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">POWERUP </td>
|
|
||||||
<td align="left"> 8 </td>
|
|
||||||
<td align="left"> This is the classic Mario’s mushroom. When the player hit the powerup object, the player become <em>Super player</em>. If CLASSFLAGS has the bit ZOOM, the player height will be doubled.<br>The <em>Super player</em> can hit the enemies without die, but when this happens, the <em>Super player</em> goes back to being normal</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">END </td>
|
|
||||||
<td align="left"> 16 </td>
|
|
||||||
<td align="left"> When the player hits this object the level ends. Player win</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">ZOOM </td>
|
|
||||||
<td align="left"> 32 </td>
|
|
||||||
<td align="left"> This flag can be used with POWERUP to indicate a powerup that will doubles the size of the player (like Mario’s mushroom)</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">DESTROY </td>
|
|
||||||
<td align="left"> 64 </td>
|
|
||||||
<td align="left"> When the player hits the object the object disappear. This is the classic Mario’s coin, but the engine does not counts the points, so, from the user point of view, this object is useless</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">DESTROYUP </td>
|
|
||||||
<td align="left"> 128 </td>
|
|
||||||
<td align="left"> This object is like a BLOCK but when the player hits the object from below, the object disappear</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
<p>If CLASSFLAGS is zero the object has only an aesthetic function.</p>
|
|
||||||
|
|
||||||
<p>The last row of the level descriptor must have all its columns set equal to -1.</p>
|
|
||||||
|
|
||||||
<h3>Limitations</h3>
|
|
||||||
|
|
||||||
<p>Some classical features are missing: throw objects, shoot, multiple lives, points counter. You can add those features if you want!</p>
|
|
||||||
|
|
||||||
<p>The program allow to run one level only. It’s easy to add a menu and multiple levels but the size of the engine will grow too much.</p>
|
|
||||||
|
|
||||||
<p>When the <em>Super player</em> become bigger (ZOOM flag), the player can collide with blocks and get stuck inside them. This is a KNOWN BUG. When your player become bigger, stay away from blocks!</p>
|
|
||||||
|
|
||||||
<p>There is one audio track only (game effects are missing).</p>
|
|
||||||
|
|
||||||
<h3>Credits</h3>
|
|
||||||
|
|
||||||
<p>Some of the sprites used in the examples are identical to those of the original games, others were designed by me.</p>
|
|
||||||
|
|
||||||
<p>The music used in the examples have been resampled, starting from the original versions for the <a href="http://en.wikipedia.org/wiki/Amiga">Commodore Amiga</a> and <a href="http://en.wikipedia.org/wiki/Nintendo_Entertainment_System">Nintendo NES</a>.</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Super Mario Bros</a> is a game created by Nintendo Entertainment, my use of the sprites does not intend to infringe the intellectual property of Nintendo but only demonstrate the operation of the program. From my point of view this is a tribute to the legendary game <a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Super Mario Bros</a>!</p>
|
|
||||||
|
|
||||||
<p><a href="http://en.wikipedia.org/wiki/The_Great_Giana_Sisters">The Great Giana The Sisters</a> is the game created by Time Warp Productions and also for this game worth my previous notes. Long live <a href="http://en.wikipedia.org/wiki/The_Great_Giana_Sisters">The Great Giana The Sisters</a> !! :)</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most tweetable entry</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most tweetable entry</h1>
|
|
||||||
|
|
||||||
<p>Sandro Maffiodo<br>
|
|
||||||
<a href="mailto:smaffer@gmail.com">smaffer@gmail.com</a><br>
|
|
||||||
<a href="http://www.assezeta.com/sandromaffiodo">http://www.assezeta.com/sandromaffiodo</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog arg
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>cat image.rgb | ./prog ' .,:;!$#@'
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>On the face of it :-) given what this program one might wonder what makes this winner special.
|
|
||||||
But when you realize the source is small enough to tweet on twitter you understand.</p>
|
|
||||||
|
|
||||||
<p>Who will be the first to tweet this source? How many re-tweets will such tweet get?
|
|
||||||
And how many people will really understand the tweet?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<p>This program convert an image to an ASCII ART. The program reads a raw RGB image from <strong>stdin</strong> and print the ASCII ART to <strong>stdout</strong>.</p>
|
|
||||||
|
|
||||||
<p>The build process will raise some warnings about:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>declaration specifier missing, defaulting to ‘int’</li>
|
|
||||||
<li>implicitly declaring library function</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The program crash if run without parameters.</p>
|
|
||||||
|
|
||||||
<h3>Screen size</h3>
|
|
||||||
|
|
||||||
<p>If you have a terminal geometry than if different from the common 80x25 you can modify the <em>output width</em> by changing the value of the first variable:</p>
|
|
||||||
|
|
||||||
<pre><code>d=80
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Something to try</h3>
|
|
||||||
|
|
||||||
<p>Type this:</p>
|
|
||||||
|
|
||||||
<pre><code>cat image.rgb | ./prog " .:;Y0"
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>You can use your own image. Convert the image to a raw RGB image, using imagemagick it’s very simple:</p>
|
|
||||||
|
|
||||||
<pre><code>convert -geometry 80x source.jpg image.rgb
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This program require one parameter, or crash. The parameter of the program is the <em>convertion ramp</em>. You can use different ramps or create your own (for ex. using some letters of your name).
|
|
||||||
These are some ramps you can try:</p>
|
|
||||||
|
|
||||||
<pre><code>./prog " :1"
|
|
||||||
./prog " .:;Y0"
|
|
||||||
./prog " .:-=+*#%@"
|
|
||||||
./prog " .,:!-iots&8%#@$"
|
|
||||||
./prog "$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,"^`'. "
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>121 byte version</h3>
|
|
||||||
|
|
||||||
<p>An alternative version of this program is only 121bytes long:</p>
|
|
||||||
|
|
||||||
<pre><code>d=80,e,j;g(){j+=getchar();}main(){for(;;){j=0;g();if(j<0)break;g(g());putchar(" .:#@"[j/3*5>>8]);if(!(++e%d))puts("");}}
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This alternative version have a <strong>fixed ramp</strong>. It’s smaller but it’s not so fun to use…</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most likely to succeed</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most likely to succeed</h1>
|
|
||||||
|
|
||||||
<p>Yves-Marie Morgan<br>
|
|
||||||
<a href="mailto:yves-marie.morgan@parrot.com">yves-marie.morgan@parrot.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog [arg ..]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
cp -f prog morgan
|
|
||||||
./morgan clobber
|
|
||||||
ls
|
|
||||||
|
|
||||||
./morgan all install
|
|
||||||
ls
|
|
||||||
|
|
||||||
./prog love haste waste supernova
|
|
||||||
ls
|
|
||||||
|
|
||||||
make
|
|
||||||
./prog magic
|
|
||||||
ls
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Think of this as a Maker Faire’s make. :-)</p>
|
|
||||||
|
|
||||||
<p>It works reasomably well. While not super ultra-featured, it does fair well with the Makefile we supplied.
|
|
||||||
Not only that, it helped uncover a bug we had in our special Makefile rules.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<p>This program is a tiny <code>make</code> clone.</p>
|
|
||||||
|
|
||||||
<p>It is able to parse a subset of the <code>make</code> syntax and will execute rules for
|
|
||||||
goals given in arguments if they need to (based on timestamp of dependencies
|
|
||||||
of rule targets).</p>
|
|
||||||
|
|
||||||
<h2>Supported features</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Variable assignments (only recursive ones). Variable references with recursion.</li>
|
|
||||||
<li>Environment variables are available.</li>
|
|
||||||
<li>It is possible to specify variables in command line: <code>name=value</code>.</li>
|
|
||||||
<li>Variables given in command line will have precedence over variables defined
|
|
||||||
in makefile, which will have precedence over environment variables.</li>
|
|
||||||
<li>If no goal given in command line, the first target defined will be used.</li>
|
|
||||||
<li>Comments, escaped comments, escaped new lines.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>It should be able to build programs of previous years with the provided <code>Makefile</code>
|
|
||||||
found in previous contest archives. Simply use this program instead of <code>make</code>.
|
|
||||||
It will recursively use itself for submake (the <code>MAKE=</code> assignment inside
|
|
||||||
<code>Makefile</code> will be ignored to continue using itself).</p>
|
|
||||||
|
|
||||||
<h2>Limitations / Known issues</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>There is a lot of memory leak (not a single free).</li>
|
|
||||||
<li>The opened file is not closed.</li>
|
|
||||||
<li>The input file shall be named <code>Makefile</code>.</li>
|
|
||||||
<li>No diagnostic message, but the exit status is non zero to indicates failure
|
|
||||||
(failed command in a rule or missing target).</li>
|
|
||||||
<li>Only <code>$<</code> and <code>$@</code> are supported for automatic variables in commands.</li>
|
|
||||||
<li>No parallel execution (<code>-j</code> option).</li>
|
|
||||||
<li>No <code>:=</code> <code>+=</code> <code>?=</code> syntax for variable assignment.</li>
|
|
||||||
<li>No built-in function available.</li>
|
|
||||||
<li>No pattern targets.</li>
|
|
||||||
<li>No pattern substitution variables.</li>
|
|
||||||
<li>No built-in rules.</li>
|
|
||||||
<li>No built-in variables (except the one from environment).</li>
|
|
||||||
<li>No conditional directives.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Compilation warnings</h3>
|
|
||||||
|
|
||||||
<p>with gcc 4.8.2 on Linux Ubuntu 14.04 64-bit :
|
|
||||||
* prog.c:22:15: warning: return makes integer from pointer without a cast [enabled by default]
|
|
||||||
* prog.c:23:72: warning: signed and unsigned type in conditional expression [-Wsign-compare]
|
|
||||||
* prog.c:12:11: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best choice of optimization</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best choice of optimization</h1>
|
|
||||||
|
|
||||||
<p>Don Yang<br>
|
|
||||||
<a href="mailto:omoikane@uguu.org">omoikane@uguu.org</a><br>
|
|
||||||
<a href="http://uguu.org/">http://uguu.org/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make sinon
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>cp sinon.c run.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Then keep running ./glock.sh or ./hecate.sh within a minute with
|
|
||||||
slight pauses between invocations.</p>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>cp sinon.c run.c; ./hecate.sh; ./glock.sh; sleep 3; ./glock.sh; sleep 1; ./hecate.sh
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Try to figure out how this entry determines the optimization level with
|
|
||||||
which it had been compiled. Is this an example of undefined behavior
|
|
||||||
or unspecified behavior?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Summary</h3>
|
|
||||||
|
|
||||||
<p>Sinon is a game of timing, the goal is to eliminate all enemies in
|
|
||||||
under one minute.</p>
|
|
||||||
|
|
||||||
<p>To start, compile and run the program. To resume, compile and run the
|
|
||||||
output repeatedly until you have won/lost the game. For example:</p>
|
|
||||||
|
|
||||||
<pre><code>cp sinon.c run.c
|
|
||||||
gcc -O0 run.c -o run && ./run | tee run.c
|
|
||||||
gcc -O2 run.c -o run && ./run | tee run.c
|
|
||||||
...
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Details</h3>
|
|
||||||
|
|
||||||
<p>Sinon is played by compiling and running the output repeatedly. Two
|
|
||||||
factors determine what actions are taken:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Time since last compilation.</li>
|
|
||||||
<li>Whether compiler optimizations are enabled or not.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>If you fire too quickly, the weapon will jam. If you fire too slowly,
|
|
||||||
you will not be able to eliminate all the enemies in time. Thus the
|
|
||||||
primary objective of the game is to time your compilations just right.</p>
|
|
||||||
|
|
||||||
<p>Sinon has two weapons that are selected based on compiler optimization
|
|
||||||
level:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>“gcc -O2” or “clang -O2” will fire Hecate II, a powerful rifle that
|
|
||||||
requires longer time to cool off.</p></li>
|
|
||||||
<li><p>“gcc -O0” or “clang -O0” will fire Glock 18C, a less powerful pistol
|
|
||||||
that requires less time to cool off.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Because the weapons cool off independently, the best strategy is to
|
|
||||||
alternate between the two weapons. It is fairly easy to win the game
|
|
||||||
with this strategy even with occasional jams.</p>
|
|
||||||
|
|
||||||
<p>If your compiler does not have the right optimizations, only Glock 18C
|
|
||||||
would be available. It is still possible to win, but your timing will
|
|
||||||
need to be more precise. This is effectively playing the game on
|
|
||||||
“hard” mode. It is worth trying this mode even if you have the right
|
|
||||||
compilers.</p>
|
|
||||||
|
|
||||||
<h3>Compatibility</h3>
|
|
||||||
|
|
||||||
<p>Sinon has been tested and verified to work on these platforms:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>gcc 4.4.3 on Linux.</li>
|
|
||||||
<li>gcc 4.4.5 on Linux.</li>
|
|
||||||
<li>gcc 4.8.2 on Linux.</li>
|
|
||||||
<li>gcc 4.8.3 on Cygwin/MingW.</li>
|
|
||||||
<li>clang 3.4-1 on Linux.</li>
|
|
||||||
<li>clang 3.4.2 on Cygwin.</li>
|
|
||||||
<li>gcc 4.3.5 on JS/Linux (playable but likely unwinnable, because it
|
|
||||||
takes too long to compile).</li>
|
|
||||||
<li>tcc 0.9.25 on JS/Linux (no optimization, so only “hard” mode is
|
|
||||||
available).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Sinon is intended to be played in a 80x25 terminal.</p>
|
|
||||||
|
|
||||||
<h3>Miscellaneous features</h3>
|
|
||||||
|
|
||||||
<p>Sinon might be the first game that uses compiler optimization level as
|
|
||||||
a primary input.</p>
|
|
||||||
|
|
||||||
<p>Sinon has a demo mode that plays the game automatically. Make sure
|
|
||||||
that there are no files named “run” and “run.c” in current directory
|
|
||||||
(they will be overwritten) and run:</p>
|
|
||||||
|
|
||||||
<pre><code>perl sinon.c | bash
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>File size and CRC32 of sinon.c are embedded in line 7.</p>
|
|
||||||
|
|
||||||
<p>Process for making Sinon is included in spoiler.html.</p>
|
|
||||||
|
|
||||||
<p>Layout of this code is based on Asada Shino, also known as “Sinon”,
|
|
||||||
from Sword Art Online.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most dynamic</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most dynamic</h1>
|
|
||||||
|
|
||||||
<p>Cel Skeggs<br>
|
|
||||||
<a href="mailto:ioccc@celskeggs.com">ioccc@celskeggs.com</a><br>
|
|
||||||
<a href="http://www.celskeggs.com">http://www.celskeggs.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>HINT: Try pressing the left and right arrow keys as needed.
|
|
||||||
Also try pressing space/enter to select options.
|
|
||||||
Pressing Q or Escape may end the fun before you are ready. :-)</p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>When the code looks like lemons, it is probably because the LEMONPEOPLE,
|
|
||||||
or at least the LEMONLORD was involved. :-)</p>
|
|
||||||
|
|
||||||
<p>Look at some of the C pre-processor macros in the source code.
|
|
||||||
Ask yourself why C source is being passed as arguments to some
|
|
||||||
of those macros.</p>
|
|
||||||
|
|
||||||
<p>Now you may observe, while it is running, that some C source code
|
|
||||||
is being written to a file and then compiled. And yet that compiled
|
|
||||||
code is somehow executed from main. But how? How is main able to
|
|
||||||
call code that was written and compiled just in time for execution?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>TABLE OF CONTENTS</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Backstory</li>
|
|
||||||
<li>Known compiler warnings</li>
|
|
||||||
<li>Obfuscation</li>
|
|
||||||
<li>Troubleshooting guide (IMPORTANT!)</li>
|
|
||||||
<li>Q&A</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>BACKSTORY</h3>
|
|
||||||
|
|
||||||
<p>It was ten yours ago when THE LEMONPEOPLE invaded, juicing all in their path.</p>
|
|
||||||
|
|
||||||
<p>Attempting to free the Earth from their tyranny, you have endured pulpy and
|
|
||||||
sour battles.</p>
|
|
||||||
|
|
||||||
<p>This has now culminated in you reaching the throne room of THE LEMONLORD.</p>
|
|
||||||
|
|
||||||
<p>Armed with your right-facing curly brace, you charge into battle.</p>
|
|
||||||
|
|
||||||
<p>(Use left and right arrow keys and space/enter to select options. Press Q or
|
|
||||||
Escape to quit.)</p>
|
|
||||||
|
|
||||||
<h3>KNOWN COMPILER WARNINGS</h3>
|
|
||||||
|
|
||||||
<p>Unfortunately, it became very difficult to get this entry to fit within the
|
|
||||||
size requirements. It’s currently at 2052 according to iocccsize, and 3994
|
|
||||||
according to wc -c.</p>
|
|
||||||
|
|
||||||
<p>The current size is a third to a half of the original size before compression.</p>
|
|
||||||
|
|
||||||
<p>Due to this, it does LOTS of things that subtly annoy compilers!</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>(10) data argument not used by format string</p>
|
|
||||||
|
|
||||||
<p>This occurs because some of the fprintf invocations don’t use all their
|
|
||||||
parameters. The program should still work fine!</p></li>
|
|
||||||
<li><p>(1) using the result of an assignment as a condition without parentheses</p>
|
|
||||||
|
|
||||||
<p>Somewhere, I needed to set a variable and then branch on the result. The
|
|
||||||
shortest way was to combine them. Some self-proclaimed “EXPERTS” think this
|
|
||||||
is a bad programming practice, but what do they know? :P</p></li>
|
|
||||||
<li><p>(1) implicit declaration of function ‘time’ is invalid in C99</p>
|
|
||||||
|
|
||||||
<p>An <code>#include</code> statement is expensive, and I’m broke.</p></li>
|
|
||||||
<li><p>(1) control may reach end of non-void function</p>
|
|
||||||
|
|
||||||
<p>Turns out that sometimes, a return statement is too much. This will never
|
|
||||||
actually occur, but some C compilers think they know more about my program
|
|
||||||
than I do! :P</p></li>
|
|
||||||
<li><p>(?) Under some systems, <code>-fPIC</code> is irrelevant for shared libraries. If so,
|
|
||||||
you should remove it from the Makefile.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>OBFUSCATION? WHAT OBFUSCATION? THIS IS A PERFECTLY NORMAL C PROGRAM!</h2>
|
|
||||||
|
|
||||||
<h1>THE COOL PART</h1>
|
|
||||||
|
|
||||||
<p>Take a close look at how it works. Notice that it’s passing C code to certain
|
|
||||||
macros…</p>
|
|
||||||
|
|
||||||
<p>Guess what? It’s a very simple kind of JIT compiler, though not used as deeply
|
|
||||||
as would be cool.</p>
|
|
||||||
|
|
||||||
<p>Essentially, it generates C code at runtime, dumps it to a file, and then runs
|
|
||||||
a C compiler on that file, telling the C compiler to generate a shared library.
|
|
||||||
Then it loads the shared library with dlopen, and…</p>
|
|
||||||
|
|
||||||
<p>Ignores the result?</p>
|
|
||||||
|
|
||||||
<p>That can’t be right.</p>
|
|
||||||
|
|
||||||
<p>Well, it is. Instead of using dlsym like a normal programmer, I mark one of the
|
|
||||||
generated functions with <code>__attribute__((constructor))</code>. This means that it
|
|
||||||
gets called immediately on load, so it can make its functions available.</p>
|
|
||||||
|
|
||||||
<p>But wait - how can it link into the main program, either? It has no way to
|
|
||||||
reference anything in the main executable!</p>
|
|
||||||
|
|
||||||
<p>But it does: I’m injecting certain addresses into the generated code, which it
|
|
||||||
then casts to pointers and accesses! It uses this to make certain functions
|
|
||||||
available to the main program, so the main program’s generated code will then
|
|
||||||
enter itself where it’s needed.</p>
|
|
||||||
|
|
||||||
<h1>THE NOT-SO-COOL PART</h1>
|
|
||||||
|
|
||||||
<p>There are also lots of <code>#defines</code>.</p>
|
|
||||||
|
|
||||||
<p>No, these are not obfuscation. These are compression.</p>
|
|
||||||
|
|
||||||
<p>There is a little bit of obfuscation gained from using the stringification
|
|
||||||
operator. (I can never remember what it’s actually called, but it’s the #
|
|
||||||
operator in a preprocessor macro) - this allows me to pass C code in arguments
|
|
||||||
to the macros, meaning that it gets interpreted as C code instead of a string
|
|
||||||
by the iocccsize tool, so it gets counted as smaller! :D</p>
|
|
||||||
|
|
||||||
<h1>A SLIGHTLY COOL PART</h1>
|
|
||||||
|
|
||||||
<p>As part of the JIT compiling, the program hides the fact that it needs ncurses:
|
|
||||||
it just links ncurses with one of the generated shared libraries, and then can
|
|
||||||
access the contents of the ncurses library!</p>
|
|
||||||
|
|
||||||
<h1>WAIT WHAT</h1>
|
|
||||||
|
|
||||||
<p>Also, note where functions start and end…</p>
|
|
||||||
|
|
||||||
<p>I’ve messed with the syntax so that it’s not actually formatted properly. It
|
|
||||||
almost looks like it is, but it isn’t.</p>
|
|
||||||
|
|
||||||
<p>This isn’t significant obfuscation as long as you run it through a C source
|
|
||||||
code beautifier.</p>
|
|
||||||
|
|
||||||
<p>But wait… if you aren’t careful, running it through a C source code
|
|
||||||
beautifier won’t work. Remember how I’m interlacing generated C code with
|
|
||||||
actual C code? Note that this WRECKS some beautifiers. I hope you have a good
|
|
||||||
one!</p>
|
|
||||||
|
|
||||||
<p>(There’s an obvious way around this but I’m not going to spell it out for you.
|
|
||||||
That’d be too easy!)</p>
|
|
||||||
|
|
||||||
<h3>MISCELLANEOUS STUFF</h3>
|
|
||||||
|
|
||||||
<p>Do note that there are some other miscellaneous obfuscations, but they should
|
|
||||||
be easy to understand once you figure out the ones above.</p>
|
|
||||||
|
|
||||||
<h3>TROUBLESHOOTING GUIDE</h3>
|
|
||||||
|
|
||||||
<p>This program is a very easy program to cause to fail!</p>
|
|
||||||
|
|
||||||
<p>Some things to check</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>On line 16, where it says <code>%cinclude "prog.c"</code>, is <code>prog.c</code> the name of the
|
|
||||||
original source code file?</li>
|
|
||||||
<li>Do you have ncurses installed?</li>
|
|
||||||
<li><p>Does your system have <code>ncurses.h</code> (like a nice system) or
|
|
||||||
<code>ncurses/ncurses.h</code> (like a rude system) ?</p>
|
|
||||||
|
|
||||||
<p>If it’s the latter (or some other path), you’ll need to update line 97.</p>
|
|
||||||
|
|
||||||
<p>(I had to do this under Cygwin.)</p></li>
|
|
||||||
<li>Does your system need <code>-fPIC</code> (or other arcane invocations) to compile a
|
|
||||||
shared library? If so, make sure that you include it in the -DCC argument in
|
|
||||||
the build script.</li>
|
|
||||||
<li>Does your system have a vague dislike for <code>-fPIC</code>? (Like Cygwin.) You might
|
|
||||||
need to remove it from the build script.</li>
|
|
||||||
<li>Does your system support <code>__attribute__((constructor))</code>? It needs to.</li>
|
|
||||||
<li>Check the file <code>err</code>. Maybe it will help you figure out why a runtime-
|
|
||||||
generated program failed. The failing program should be found in <code>t.c</code>.</li>
|
|
||||||
<li>Can’t run a beautifier on the source code? I’m not going to help you there.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>I’ve tested it on the following platforms, in case you need to try it on one:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>64-bit Windows 7 32-bit Cygwin with gcc 4.8.2 and standards c89, c90, c99,
|
|
||||||
and c11. Note that the program ran as 32-bit due to the version of cygwin.</li>
|
|
||||||
<li>64-bit Arch Linux with gcc 4.9.1 and standards c89, c90, c99, c11.</li>
|
|
||||||
<li>64-bit Arch Linux with clang 3.5.0 and standards c89 and c11.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>I ran out of time to test it on more systems.</p>
|
|
||||||
|
|
||||||
<h3>Q&A</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>Who am I?</p>
|
|
||||||
|
|
||||||
<p>Yes.</p></li>
|
|
||||||
<li><p>Why doesn’t your program require a pet fish license?</p>
|
|
||||||
|
|
||||||
<p>THE LEMONLORD’s pet LEMONFISH was not rendered in the game, and so does not
|
|
||||||
require a pet fish license.</p></li>
|
|
||||||
<li><p>Was this inspired by anything?</p>
|
|
||||||
|
|
||||||
<p>Yes, this was inspired by a minigame from an open-source codebase of Space
|
|
||||||
Station 13. I didn’t, however, look at the minigame at all during the
|
|
||||||
development of this entry.</p></li>
|
|
||||||
<li><p>What’s the length of this REMARKS file according to the iocccsize tool?</p>
|
|
||||||
|
|
||||||
<p><code>$ ./iocccsize -i <REMARKS.MD</code></p>
|
|
||||||
|
|
||||||
<p><code>5092</code></p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best handling of beeps</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best handling of beeps</h1>
|
|
||||||
|
|
||||||
<p>Daniel Vik<br>
|
|
||||||
<a href="mailto:daniel@vik.cc">daniel@vik.cc</a><br>
|
|
||||||
<a href="http://danielvik.com/">http://danielvik.com/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog > foo.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo 'Want to hear me beep?' | ./prog > audio_file.raw
|
|
||||||
|
|
||||||
echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio -
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This program sets a new tone for obfuscation. But do you understand
|
|
||||||
what it says about obfuscation? Perhaps:</p>
|
|
||||||
|
|
||||||
<pre><code>./prog < prog.c > prog.raw
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>might speak to your coding style? If not, then perhaps:</p>
|
|
||||||
|
|
||||||
<pre><code>./prog < remarks.markdown | mplayer -demuxer rawaudio -
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>might help? :-)</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<p>This program converts ascii text to morse audio file and vice versa. As far as
|
|
||||||
I can tell, there are at least six chocolate references in this program.</p>
|
|
||||||
|
|
||||||
<p>This program can convert text to morse to a raw 44.1kHz stereo audio file.
|
|
||||||
Via streaming to mplayer, you can listen to the morse audio.</p>
|
|
||||||
|
|
||||||
<p>Don’t forget the last ‘-’ as it makes mplayer read from stdin.)</p>
|
|
||||||
|
|
||||||
<h2>Convert audio file with morse signals to text</h2>
|
|
||||||
|
|
||||||
<pre><code>$ ./prog e < audio_file.raw
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>or alternatively pass a .wav file as input.</p>
|
|
||||||
|
|
||||||
<p>The preferred input format 44.1kHz stereo, but it does a decent job on mono
|
|
||||||
input and different frequencies as well.</p>
|
|
||||||
|
|
||||||
<h3>Portability</h3>
|
|
||||||
|
|
||||||
<p>The program is portable to most platforms. The only system dependency is that
|
|
||||||
the program relies on writing binary data to stdout.</p>
|
|
||||||
|
|
||||||
<p>Microsoft compilers adds a carriage return to newlines, and to compile the
|
|
||||||
program with this platform, the following line can be added after the main
|
|
||||||
declaration in order for the program to run correctly:</p>
|
|
||||||
|
|
||||||
<pre><code>_setmode(_fileno(stdout), 0x8000);
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Known Issues</h3>
|
|
||||||
|
|
||||||
<p>The program uses a quite simple algorithm for detecting tone on and off events
|
|
||||||
in the morse signal. Hence the program does not work well with noisy input
|
|
||||||
signals. I have tested it with several samples of man made morse recordings as
|
|
||||||
well as computer generated ones.</p>
|
|
||||||
|
|
||||||
<p>Generally, any recording from ham radio transmissions does not decode due to
|
|
||||||
noise and echoes. Other man made recordings may decode, but some characters
|
|
||||||
can be incorrect due to too big variation in length of tones and pauses.
|
|
||||||
However I found some man made recordings on that decode reasonable well.</p>
|
|
||||||
|
|
||||||
<p>If a recording don’t decode, you could try to pre-process the input with a
|
|
||||||
narrow bandpass filter on the frequency of the transmission.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most functional</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most functional</h1>
|
|
||||||
|
|
||||||
<p>Freek Wiedijk<br>
|
|
||||||
<a href="mailto:freek@cs.ru.nl">freek@cs.ru.nl</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To build:</h3>
|
|
||||||
|
|
||||||
<pre><code>make wiedijk
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To run:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>gcc -E prog.c | indent | sed '1,/5.*prog/d'
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>C11 features definitely help this entry to be as concise as it is.</p>
|
|
||||||
|
|
||||||
<p>The judges would like to think that they had almost understood how this entry works.</p>
|
|
||||||
|
|
||||||
<p>If you win a bet by demonstrating this entry, please let us know.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Remarks</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>computes the factorial function</li>
|
|
||||||
<li>no loops, no explicit recursion</li>
|
|
||||||
<li>untyped C without any casts, using a <code>w</code> word datatype</li>
|
|
||||||
<li>varargs not essential, <code>w(*)(w,w*)</code> works just as well</li>
|
|
||||||
<li>conforming ISO C</li>
|
|
||||||
<li>no warnings when compiled with <code>-std=c99 -Wall -Wextra -pedantic</code></li>
|
|
||||||
<li>comments in the code explain what this really is about</li>
|
|
||||||
<li>C as a functional programming language:
|
|
||||||
untyped lambda calculus compiled to executable C functions</li>
|
|
||||||
<li>untagged closures (just a function pointer followed by some values)</li>
|
|
||||||
<li>recursion implemented through Curry’s paradoxical combinator <code>Y</code></li>
|
|
||||||
<li><p>the readable implementation of <code>Y</code> is on lines 29-30:</p>
|
|
||||||
|
|
||||||
<p> W_f = \x.f(xx)
|
|
||||||
Y = \f.W_f W_f</p></li>
|
|
||||||
<li><p>a mixture of strict and lazy evaluation, with a <code>_</code> force function
|
|
||||||
(John Tromp notes that if Turing’s fixed-point combinator
|
|
||||||
<code>(\xy.y\z.xxyz)(\xy.y\z.xxyz)</code> had been used,
|
|
||||||
all applications could have been strict)</p></li>
|
|
||||||
<li>uses <code>Y</code> to implement factorial on native <code>int</code>s</li>
|
|
||||||
<li>10! seconds = 6 weeks</li>
|
|
||||||
<li>answers the ultimate question of life, the universe and everything</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2015,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Useful</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Useful</h1>
|
|
||||||
|
|
||||||
<p>Dave Burton <a href="mailto:ioccc@snox.net">ioccc@snox.net</a><br>
|
|
||||||
<a href="http://snox.net/ioccc">http://snox.net/ioccc</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog "expression"
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>or</p>
|
|
||||||
|
|
||||||
<pre><code>./prog
|
|
||||||
(input expressions)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog '?0x3343<<2'
|
|
||||||
|
|
||||||
echo '?0x3343<<2' | ./prog
|
|
||||||
|
|
||||||
./prog
|
|
||||||
|
|
||||||
Enter:
|
|
||||||
|
|
||||||
a=0xfeedface
|
|
||||||
b=0xcafe
|
|
||||||
a << 16 + b
|
|
||||||
|
|
||||||
grep '[0-9]' prog.c
|
|
||||||
|
|
||||||
./prog < test.in
|
|
||||||
|
|
||||||
less calc.man
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>“Look, Ma, no <del>hands</del> digits!”</p>
|
|
||||||
|
|
||||||
<p>The place where some arithmetic operations are done, for example,
|
|
||||||
division or modulo, are easy to find. Where are addition and subtraction?</p>
|
|
||||||
|
|
||||||
<p>We were impressed with the level of detail the author “blogged” the obfuscation process.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>calc - an integer expression calculator that outputs in both hex and decimal</h2>
|
|
||||||
|
|
||||||
<p>All useful tools should include sufficient documentation.
|
|
||||||
See the included man page. ;-)</p>
|
|
||||||
|
|
||||||
<h2>Notes</h2>
|
|
||||||
|
|
||||||
<p>This program is named calc. Onomatopoeia of sorts, in the visual realm.
|
|
||||||
The formatting was easier: Form Follows Function (although the 2011 <a href="/2011/hou/hint.html" title="Hou Qiming">Hou</a> entry
|
|
||||||
did this better).
|
|
||||||
It was tempting to call it iCalc, with i for integer (and it was written on an iDevice),
|
|
||||||
but sanity prevailed.</p>
|
|
||||||
|
|
||||||
<p>Printed in 8 pt Courier, it makes aesthetically pleasing 8.5 x 11 wall art.</p>
|
|
||||||
|
|
||||||
<h2>prog.c vs prog.orig.c</h2>
|
|
||||||
|
|
||||||
<p>Dominik Muth observed a syntax error on <code>1+1</code>, <code>1-1</code>, <code>1|1</code>, and <code>1^1</code> when using an
|
|
||||||
ARM based computer, although <code>1*1</code> and others worked correctly.
|
|
||||||
This occurs because some platforms by default treat <code>char</code> as <code>unsigned char</code>.
|
|
||||||
The original code has this weakness, which can be corrected by adding <code>-fsigned-char</code>
|
|
||||||
to the compile line.
|
|
||||||
The modified code is agnostic to <code>char</code> signed-ness.</p>
|
|
||||||
|
|
||||||
<h2>Why is this entry obfuscated/interesting?</h2>
|
|
||||||
|
|
||||||
<p>Yes, this is another calculator program.</p>
|
|
||||||
|
|
||||||
<p>However, unlike any other calculator source code the author is aware of,
|
|
||||||
this one contains no digits. At all. Anywhere. As in</p>
|
|
||||||
|
|
||||||
<pre><code>grep '[0-9]' prog.c || echo no digits!
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Nor are the digits simply obfuscated. There are no character constants.
|
|
||||||
There is only one single, short string, and it does not contain any obfuscated digits.
|
|
||||||
And yet the output is in decimal and hexadecimal, and it accepts octal, decimal, and hex input.</p>
|
|
||||||
|
|
||||||
<p>Flow control is by <code>for</code> and <code>return</code>. It is If-less. Switch-less. While-less. Hope-less. <br>
|
|
||||||
Literally, if not figuratively. ;-)</p>
|
|
||||||
|
|
||||||
<p>The code size is intentionally 2015, as stated by iocccsize -i,
|
|
||||||
and can be reformatted without changes (as in rule2.c) to exactly 4096 octets.</p>
|
|
||||||
|
|
||||||
<p>Finally, calc is interesting, if for no other reason than it is practically useful:
|
|
||||||
Hex/decimal conversion, arithmetic, byte-swapping, bit-shifting, and logical operations with memory,
|
|
||||||
on the command line, or interactively.</p>
|
|
||||||
|
|
||||||
<h2>But the question is why is the entry obfuscated?</h2>
|
|
||||||
|
|
||||||
<p>The code follows many industry best-practices:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>You know what it does just by looking at it.</p></li>
|
|
||||||
<li><p>Numbers and digits have often been used for obfuscation,
|
|
||||||
so in a bid for better clarity, this code has no digits at all.</p></li>
|
|
||||||
<li><p>In the spirit of clarity, most of the variables are declared before use, so they
|
|
||||||
are readily visible, with single letter names that don’t clutter the screen,
|
|
||||||
in a tautological arrangement.</p></li>
|
|
||||||
<li><p>More helpful is the use of <code>typedef</code>s instead of <code>#define</code>, so the types remain useful
|
|
||||||
even in the debugger, and source code beautifiers will not undo careful presentation.</p></li>
|
|
||||||
<li><p><code>#defines</code> are used here in the best spirit of the preprocessor: to shorten
|
|
||||||
repetitive constructs, not for obscurity.</p></li>
|
|
||||||
<li><p>All functions are short (and therefore easy to understand?) and do only one thing, well, ….</p></li>
|
|
||||||
<li><p>Curly braces invite endless holy wars over readability. This code only uses them
|
|
||||||
for function definitions, thereby greatly improving readability, and reducing arguments
|
|
||||||
about said readability.</p></li>
|
|
||||||
<li><p>One of C’s many blessings (until recently) is a modicum of keywords,
|
|
||||||
of which only 8 are used:
|
|
||||||
<code>for</code>, <code>return</code>, <code>typedef</code>, <code>void</code>, <code>char</code>, <code>short</code>, <code>unsigned</code> and <code>long</code>;
|
|
||||||
10 if <code>#include</code> and <code>#define</code> are counted.</p></li>
|
|
||||||
<li><p>The code helpfully declares “syntax_error!” right up front, filling the reader with confidence.</p></li>
|
|
||||||
<li><p>In spite of its inherent clarity, the code was presented to both <em>indent</em>(1) and
|
|
||||||
<em>clang-format</em>(1), after running it through the preprocessor, sustaining its better qualities.</p></li>
|
|
||||||
<li><p>That the code is obfuscated is spelled out two different ways in the source; it helps
|
|
||||||
to reformat the code to see the second spelling.</p></li>
|
|
||||||
<li><p>The author is overly fond of the code that handles input.
|
|
||||||
There is no memory allocation, nor pre-allocation of arrays, so where does the
|
|
||||||
memory come from? The multi-base strtol() code is pretty trick.
|
|
||||||
No special attempt was made to replace operations with obscure mathematical relations,
|
|
||||||
as the (lack of) beauty is in the parsing – ask not where is the modulus operation,
|
|
||||||
but how does it know when to mod – okay, but where is add and subtract?
|
|
||||||
And really, who doesn’t enjoy a setjmp() in the argument list?</p></li>
|
|
||||||
<li><p>Finally, documentation of the source code structure is helpfully provided in rot13 format.
|
|
||||||
But isn’t it unsportsmanlike to rely upon it? However, even with this helpful guide,
|
|
||||||
things like reading input lines remain as tricky to read as they are to write.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Compiler warnings</h2>
|
|
||||||
|
|
||||||
<p>Calc is C99 compliant, and is ANSI/C90 compliant except for wanting 64-bit <code>long long</code>.
|
|
||||||
Changing the two <code>long long</code> typedefs to <code>long</code>, and compiling with <code>gcc -m32</code>
|
|
||||||
yields a program that operates on 32-bit values, with wrap-around of shifts mod 32:</p>
|
|
||||||
|
|
||||||
<pre><code>1<<48
|
|
||||||
65536 0x00010000
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>gcc 4.2.1 without arguments compiles cleanly (e.g. cc prog.c -o prog).
|
|
||||||
This is my workaday compiler. gcc is also clean with -ansi, and -std=c99.</p>
|
|
||||||
|
|
||||||
<p>clang 3.6.0 lives up to its namesake, resounding on non-problems.
|
|
||||||
To stifle these complaints:
|
|
||||||
-Wno-return-type -Wno-parentheses -Wno-empty-body</p>
|
|
||||||
|
|
||||||
<p>When invoked with -ansi -pedantic, there are two warnings, which can be ignored:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>ISO C90 does not support 'long long'</code></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>With -Wall -std=c99, both are quite noisy, and all can be ignored:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>array subscript has type 'char' [-Wchar-subscripts]</code></li>
|
|
||||||
<li><code>value computed is not used [-Wunused-value]</code></li>
|
|
||||||
<li><code>operation on 'j' may be undefined [-Wsequence-point]</code></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Test Suite</h2>
|
|
||||||
|
|
||||||
<p>If the program name begins with an “e”, it echoes stdin to stdout.
|
|
||||||
This allows for a convenient test suite:</p>
|
|
||||||
|
|
||||||
<pre><code>ln -s prog eprog
|
|
||||||
PATH=. eprog < test.in | diff - test.out
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Spoilers</h2>
|
|
||||||
|
|
||||||
<p>If you do not want to puzzle out how it works, see spoilers.markdown.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Crafty</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Crafty</h1>
|
|
||||||
|
|
||||||
<p>Gil Dogon<br>
|
|
||||||
<a href="http://sokoban-gild.com">http://sokoban-gild.com</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog
|
|
||||||
|
|
||||||
press and hold the Left Arrow key until you turn 90-degrees to the left
|
|
||||||
|
|
||||||
when you see a long tunnel, press the function key F2
|
|
||||||
|
|
||||||
Use the Up, Down, Left and Right keys to change your path
|
|
||||||
|
|
||||||
Press function higher numbered function keys (F3, F4, ...) to go faster
|
|
||||||
|
|
||||||
Press F1 to stop
|
|
||||||
|
|
||||||
Turn 90-degrees to one side
|
|
||||||
|
|
||||||
Press F4 to and drill into some blocks for a bit
|
|
||||||
|
|
||||||
Press F1 to stop
|
|
||||||
|
|
||||||
Turn 180-degrees to face the way you came
|
|
||||||
|
|
||||||
Press F2 and navigate back down the new hole until you reach the long tunnel again
|
|
||||||
|
|
||||||
Press F1 to stop
|
|
||||||
|
|
||||||
etc.
|
|
||||||
|
|
||||||
Press the ESC key
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>You are in a twisty maze blocks, almost all alike.</p>
|
|
||||||
|
|
||||||
<p>Those blocks are generated by twisty maze of code blocks, almost all different.</p>
|
|
||||||
|
|
||||||
<p>Can you find your way around either and understand where you are?</p>
|
|
||||||
|
|
||||||
<p>How many function keys does your keyboard have? Can you generate very high number function keys such as F30 or F31? :-)</p>
|
|
||||||
|
|
||||||
<p><em>Textures? We don’t need no stinking textures.</em></p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>What is it?</h3>
|
|
||||||
|
|
||||||
<p>Just run prog with no arguments on an X11-compatible system. The scenery, though pseudo-randomly generated should be strangely familiar, specially to those still in their teen age. You can navigate using the keyboard arrow keys and the function keys. Your speed is a linear function of (n-1) where Fn is the last function key you have pressed, and you always move in the direction you are looking at. Be aware that you are probably some kind of a Creeper as is obvious from looking at the program, hence your movement is destructive to the environment. So after pressing F12 for warp speed, and moving around randomly, you might find yourself in a 3D maze of twisty little passages, from which there is only one Esc(ape) key. Note that in theory if you have a specialty keyboard with 32 function keys you may even press F31 to reach infinite improbability drive speed, though the author had never tested this feature. However a hidden comment in keysymdef.h suggests the existence of a mythical Sun Keyboard with 35 function keys :)</p>
|
|
||||||
|
|
||||||
<h3>Full disclosure.</h3>
|
|
||||||
|
|
||||||
<p>This entry, tough pretty thoroughly obfuscated, is not entirely original, nor am I Notch. The inspiration for this entry is a demo code written by the Notch himself, which was released with the following license: “you may use the code in here for any purpose in any way you want, at your own risk”. That version will henceforth be referred to as the original. Though the original in itself was quite nice and rather dense piece of code, it was not written in C, nor entirely and meticulously obfuscated, a state of things I hopefully rectified.</p>
|
|
||||||
|
|
||||||
<h3>Some extra features.</h3>
|
|
||||||
|
|
||||||
<p>Basing it on the original which already had a wonderful simple and concise ray casting through a generated voxel world rendering, I added a few tweaks of my own device:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Two pass optimized rendering. The program first calculates 1/16 of the output image by ray casting, and then, when possible uses texture interpolation on the voxel faces. It speeds up the rendering by at least a factor of 4 on most scenes, but extra care must be taken when passing rays through the leaves voxels …</li>
|
|
||||||
<li>Fixed a small omission in the original. When you looked though a transparent leaves voxel, you did not see the leaves at voxel faces that were far from you. In this version the rendering of those (far face leaves) is correct.</li>
|
|
||||||
<li>Window rendering size specified in Makefile.</li>
|
|
||||||
<li>Added the keyboard controls for navigation (and destruction).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Portability issues.</h3>
|
|
||||||
|
|
||||||
<p>This entry is rather portable I think on modern platforms. It assumes of course basic X-windows availability. There are several other salient assumptions though:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The entry assumes sizeof(int)=4. This seems to cover pretty much everything that supports X-windows so would be broken only on quite ancient machines, embedded processors, or some big iron 64 bit system where sizeof(int)=8.</li>
|
|
||||||
<li>The entry assumes the default visual has 24 bit depth (RGB). This seems to be the case on most X Servers this days.</li>
|
|
||||||
<li><p>The entry, does a thing which is an absolute No-No for X-windows program, i.e. assuming it knows some numeric values for keysyms defined in keysymdef.h . I have searched far and wide the lord Google’s domain, yet was unable to find a version of the file where those assumptions were broken. This enables the important support of up to 32 function keys keyboards without spilling over the size limit, and allows us to use such fun expression for arrow view control as the following:</p>
|
|
||||||
|
|
||||||
<pre><code> *(a&1?&C:&B)-=(.05 -a/2%2*.1)*!(a-1&4092^3920)
|
|
||||||
</code></pre></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Precision issues.</h3>
|
|
||||||
|
|
||||||
<p>The entry, on purpose, (see the section about SIMD below) does not use enough bits of precision, so some times the ray will miss the intersection of two voxel faces and push on through. That’s why you may notice some noise along close up voxel edges. Fixing this issue would have taken the entry over the size limit regrettably.</p>
|
|
||||||
|
|
||||||
<h3>Obfuscations.</h3>
|
|
||||||
|
|
||||||
<p>Well, of course you have all the usual suspects, used for extreme compression, and such a nice layout: not very informative identifiers, which are being reused all over the place, some rather gruesome looking expressions, a whole load of magic constants with apparently no rhyme nor reason (including a Lagrange polynomial), and a message from our friendly Cetaceans. However it also includes some clever and not so obvious though instructive techniques, to subtly make the code more magical and efficient, at the same time.</p>
|
|
||||||
|
|
||||||
<p>Those techniques are about the use of 64 bit integers in order to do SIMD work, in a portable way without ever using any SSE/AVX or other non-portable compiler inline functions! The irony though, is that when compiling the program on modern X86 architectures indeed SSE/AVX is used for the long longs.
|
|
||||||
Following is some “Spoiler” information, So if you want to play tough, stop reading at this point.</p>
|
|
||||||
|
|
||||||
<h3>Portable SIMD programming.</h3>
|
|
||||||
|
|
||||||
<p>So how is this done? Quite simply by using the whole long long arithmetic’s capability. I think the C99 standard assures us that long long has at least 64 bits. Most of those bits are unused in normal programs, however here we use them more wisely. For example, in the inner loop of the program you have the innocent looking expression i+=d. What it does in fact, is a SIMD addition of two vectors, each with three signed fixed point coordinates, advancing our ray in 3D space!
|
|
||||||
To spell it out, the macro producing such vectors is P, and the assignment q=0x820008202625a0 sets our creeper original position to about (32.5, 32.5019, 2441.406) .</p>
|
|
||||||
|
|
||||||
<p>Evidently when doing such arithmetics, care must me taken to avoid overflow from one component to the other, but since our voxel world is a torus of size 64 in each dimension this hardly matters. A subtle issue, is how to deal with signed quantities. In the i+=d expression above i has 3 positive components, but d has arbitrary signed components, as our ray may face in any direction. It seems things should not work, specially as we defined both i and d as unsigned! However notice that the T (and P )macro converts float to signed long longs. Once sign is extended from a least component into higher bits, it seems at first to be recipe for disaster, however everything works beautifully, and you get precise component results when the final accumulation components in i are positive. This only gets broken a bit when the final accumulation has a least significant negative component. To see this bug in action change the assignment above to q=0x82000820000000, and look towards the negative direction of the main tunnel.</p>
|
|
||||||
|
|
||||||
<p>Similar technique is used on the RGB components so their brightness can be adjusted simultaneously by the expression: o=o*b>>8 . Of course some spare bits are needed between the components, so they are spread in the long long and reordered as RBG.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,215 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best Handwriting</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best Handwriting</h1>
|
|
||||||
|
|
||||||
<p>Etienne Duble <a href="mailto:etienne.duble@imag.fr">etienne.duble@imag.fr</a><br>
|
|
||||||
<a href="http://lig-membres.imag.fr/duble">http://lig-membres.imag.fr/duble</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
echo Some text | ./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo Hello, world | ./prog
|
|
||||||
|
|
||||||
DRAFT=1 ./prog < prog.c
|
|
||||||
|
|
||||||
./prog
|
|
||||||
> [type]
|
|
||||||
(...observe...)
|
|
||||||
|
|
||||||
./prog < prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Beautiful penmanship! However, your fonts may vary.</p>
|
|
||||||
|
|
||||||
<p>How does this entry compress the font it uses? What’s the purpose of lrand48()?
|
|
||||||
Why does the program dump core, when it does :) ?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Introduction</h3>
|
|
||||||
|
|
||||||
<p>This program <strong>prints text in your terminal with an interesting
|
|
||||||
hand-writing effect</strong>.</p>
|
|
||||||
|
|
||||||
<p>It uses the <em>braille patterns</em> range of the unicode standard: this
|
|
||||||
allows to consider each terminal character as a tiny 2x4 bitmap.</p>
|
|
||||||
|
|
||||||
<p>Turning the Braille code into something visual might be considered
|
|
||||||
blasphemous. When I was fighting to make this program work, I started
|
|
||||||
wondering if it was not the reason for its very erratic behaviour.</p>
|
|
||||||
|
|
||||||
<h3>prog.c vs prog.orig.c</h3>
|
|
||||||
|
|
||||||
<p>The file <code>prog.orig.c</code> is the one I submitted.</p>
|
|
||||||
|
|
||||||
<p>Gil Dogon noted a few unsafe statements (statements whose behaviour is
|
|
||||||
undefined in the C standard and, as such, could cause issues with other
|
|
||||||
compilers or optimization levels). These have been fixed in <code>prog.c</code>.
|
|
||||||
After this fix, in order to remain rule-2-compliant, a variable name has
|
|
||||||
also been shortened in this file.</p>
|
|
||||||
|
|
||||||
<h3>How to build</h3>
|
|
||||||
|
|
||||||
<p>If you have <code>clang</code>:</p>
|
|
||||||
|
|
||||||
<pre><code>$ CC=clang make -e
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Otherwise (gcc):</p>
|
|
||||||
|
|
||||||
<pre><code>$ make
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>(You will get a few warnings in this case.)</p>
|
|
||||||
|
|
||||||
<h3>How to use it</h3>
|
|
||||||
|
|
||||||
<p>You need a terminal configured to handle an <em>UTF-8</em> encoding and a
|
|
||||||
font including <em>braille patterns</em>.
|
|
||||||
This is the default on most modern GNU/Linux operating systems.
|
|
||||||
The default terminal application (gnome-terminal) or even a simple
|
|
||||||
xterm should render things properly.
|
|
||||||
I tested this on several Debian and Ubuntu systems, 32 and 64bits (no configuration was needed).
|
|
||||||
I also tested it on FreeBSD 9.3 32bits (font and encoding configuration
|
|
||||||
was needed in this case).</p>
|
|
||||||
|
|
||||||
<p>Basic mode:</p>
|
|
||||||
|
|
||||||
<pre><code>$ echo 'I am testing this thing.' | ./prog
|
|
||||||
[... rendering ...]
|
|
||||||
|
|
||||||
$ ./prog < lorem-ipsum.txt
|
|
||||||
[... rendering ...]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Interactive mode:</p>
|
|
||||||
|
|
||||||
<pre><code>$ ./prog
|
|
||||||
> hello world!!!
|
|
||||||
[... rendering ...]
|
|
||||||
>
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Obfuscation</h3>
|
|
||||||
|
|
||||||
<p>This entry is obfuscated in various ways:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The structure is hidden by avoiding loops, ‘if’ statements, ternary
|
|
||||||
conditionals, and jump-related instructions. Instead, recursivity is
|
|
||||||
heavily used.</li>
|
|
||||||
<li>Merging all functions into one added even more recursivity. ;)</li>
|
|
||||||
<li>The provided code does not contain the same number of opening and closing
|
|
||||||
parenthesis.</li>
|
|
||||||
<li>Preprocessing the code inflates it and adds lots of indents. Removing some
|
|
||||||
of the tricks involved without breaking the program will be challenging.</li>
|
|
||||||
<li>The program ‘plays’ with standard input & output streams, which causes
|
|
||||||
unusual side effects.</li>
|
|
||||||
<li>Some variables are re-used for unrelated processings.</li>
|
|
||||||
<li>Crucial data may be hidden in unexpected places (e.g. as the size of
|
|
||||||
a temporary buffer).</li>
|
|
||||||
<li>Some parts of the code may have no effect (but may have an effect in a
|
|
||||||
specific context, who knows?), and classical libc functions may not act
|
|
||||||
as usual.</li>
|
|
||||||
<li>And of course variable names are hard to read (or distracting).</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>On the other hand, the following may help:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The code layout should help to identify which part of the code is
|
|
||||||
obfuscated. ;)</li>
|
|
||||||
<li>File ‘codes.txt’ shows how each character is drawn. This data is
|
|
||||||
encoded in macro O_o at the top of the source file.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Limitations</h3>
|
|
||||||
|
|
||||||
<h4>Charset</h4>
|
|
||||||
|
|
||||||
<p>In order to comply with the size rule, I encoded only a part of the visible ASCII
|
|
||||||
chars:</p>
|
|
||||||
|
|
||||||
<pre><code>a-z, A-Z, '.' ':' ',' ';' '!' and '?'.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Uppercase and lowercase chars are rendered the same.
|
|
||||||
The program also understand the space and the linefeed (\n).
|
|
||||||
Other chars are simply ignored (most of the time ;)</p>
|
|
||||||
|
|
||||||
<h4>Stack size</h4>
|
|
||||||
|
|
||||||
<p>This limitation is due to the heavy use of recursivity. After having processed
|
|
||||||
a large number of characters, the process may exceed the stack size and crash.
|
|
||||||
(However I did not experience this myself. The top-level recursion might be
|
|
||||||
removed by the compiler as part of its optimizations.)</p>
|
|
||||||
|
|
||||||
<h4>Line rendering</h4>
|
|
||||||
|
|
||||||
<p>The program does its best to avoid cutting words at the end of lines, but
|
|
||||||
it could still happen in case of long words.</p>
|
|
||||||
|
|
||||||
<h3>Subtleties and extra features</h3>
|
|
||||||
|
|
||||||
<h4>Handling more than text docs?</h4>
|
|
||||||
|
|
||||||
<p>Given the limited set of characters handled, the program is mostly limited
|
|
||||||
to simple text documents.
|
|
||||||
Thus, if you try for example:</p>
|
|
||||||
|
|
||||||
<pre><code>$ ./prog < prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>You will not get something that looks like C code. (but you can still try,
|
|
||||||
if you are curious. :)</p>
|
|
||||||
|
|
||||||
<h4>A ‘draft’ mode</h4>
|
|
||||||
|
|
||||||
<p>Defining an environment variable called DRAFT will enable the ‘draft-mode’.
|
|
||||||
Try for example:</p>
|
|
||||||
|
|
||||||
<pre><code>$ echo 'testing the draft mode' | DRAFT=1 ./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The program will run much faster but the rendering will be less precise.</p>
|
|
||||||
|
|
||||||
<h4>The subtle interactive mode</h4>
|
|
||||||
|
|
||||||
<p>I saved the best for last: usually, programs that handle an “interactive
|
|
||||||
mode” have to check whether their standard input is a terminal or not (by
|
|
||||||
using isatty()). Did you notice that this program does not perform any such
|
|
||||||
detection, but still behaves (or seems to behave) appropriately?</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Diffused Reaction</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Diffused Reaction</h1>
|
|
||||||
|
|
||||||
<p>Someone Anonymous<br>
|
|
||||||
Twitter: @hirekoke</p>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a><br>
|
|
||||||
Twitter: @mametter</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
<tbd-tool-rubl-perl-python?>
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>Connect to port http://localhost:10333 with your browser
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>How did the leopard get its spots? Why are a zebra’s stripes unique?</p>
|
|
||||||
|
|
||||||
<p>In case you didn’t recognise the portrait of Alan Turing, there are some
|
|
||||||
pointers to his features like eyes with “stdeye-o” and “<–mouth”. Can you
|
|
||||||
find any other tributes?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>What does “Alan Turing” remind you of? Cryptanalysis of the Enigma? Turing machine? Turing test? This program is also based on his work.</p>
|
|
||||||
|
|
||||||
<h3>Whirlwind tour</h3>
|
|
||||||
|
|
||||||
<p>Compile the program as follows:</p>
|
|
||||||
|
|
||||||
<pre><code>$ clang -O3 -std=c99 \
|
|
||||||
-Wall -Wextra -pedantic -o prog prog.c \
|
|
||||||
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
|
||||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)" \
|
|
||||||
-DF=0.040 -DK=0.060 -DDu=0.200 -DDv=0.100 \
|
|
||||||
-DUV_BACKGROUND=1,0 -DUV_DROP=-0.5,0.5 \
|
|
||||||
-DTIMESTEP=1.0 -DSPEED=2 -DRGB=255:128:192
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Then, run it under <code>tcpserver</code> command in <a href="http://cr.yp.to/ucspi-tcp.html">ucspi-tcp</a> package, which was created by Daniel J. Bernstein, IOCCC 1989 “Best of Show” winner.</p>
|
|
||||||
|
|
||||||
<pre><code>$ tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Finally, open <code>http://127.0.0.1:10333/</code> by a modern browser supporting HTML5. You can use the mouse cursor to place drops into the Petri dish interactively.</p>
|
|
||||||
|
|
||||||
<h3>Description</h3>
|
|
||||||
|
|
||||||
<p>This is a simulator of <em>reaction-diffusion systems</em>.</p>
|
|
||||||
|
|
||||||
<p>Reaction-diffusion systems, proposed by Alan Turing in [1], are mathematical models in which two chemical substances are transformed into each other (<em>local chemical reactions</em>) and spread out (<em>diffusion</em>). Their interactions sometimes form non-trivial patterns, such as spots, spiral, dappling, and labyrinths.</p>
|
|
||||||
|
|
||||||
<p>The systems are generally formulated as follows:</p>
|
|
||||||
|
|
||||||
<pre><code>du/dt = F(u, v) + Du * laplacian(u)
|
|
||||||
dv/dt = G(u, v) + Dv * laplacian(v)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The functions <code>F(u, v)</code> and <code>G(u, v)</code> represent reactions of each substance, and the parameters <code>Du</code> and <code>Dv</code> are diffusion coefficients. By changing the functions and parameters, you can see a wide range of behaviors.</p>
|
|
||||||
|
|
||||||
<p>See <a href="https://en.wikipedia.org/wiki/Reaction%E2%80%93diffusion_system">the Wikipedia article of “Reaction-diffusion system”</a> in detail.</p>
|
|
||||||
|
|
||||||
<p>This program simulates the systems. The field consists of 128 x 128 cells. Each cell includes infomration of an amount of the two substances, and interacts with neighbor cells (in terms of von Neumann neighborhood) in each frame.</p>
|
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
|
||||||
|
|
||||||
<p>You can change the model, initial pattern, simulation speed, and color via macro definition.</p>
|
|
||||||
|
|
||||||
<h4>Model: <code>-Delta_u=<expression> -Delta_v=<expression></code></h4>
|
|
||||||
|
|
||||||
<p>The definitions represent the equations of reaction-diffusion system. For example, the following is <a href="http://groups.csail.mit.edu/mac/projects/amorphous/GrayScott/">the Gray-Scott model</a> in TeX notation.</p>
|
|
||||||
|
|
||||||
<pre><code>\frac{\partial u}{\partial t} = D_u \Delta u - u v^2 + F (1 - u)
|
|
||||||
\frac{\partial v}{\partial t} = D_v \Delta v + u v^2 - v (F + K)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>You can specify this model as follows:</p>
|
|
||||||
|
|
||||||
<pre><code>-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
|
||||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)"
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p><code>Du</code>, <code>Dv</code>, <code>F</code>, and <code>K</code> are parameters of that model.</p>
|
|
||||||
|
|
||||||
<h4>Initial pattern: <code>-DUV_BACKGROUND=<u0>,<v0> -DUV_DROP=<u1>,<v1></code></h4>
|
|
||||||
|
|
||||||
<p>The definitions specifies the initial amount of the two substances u and v. All cells have <code>(u0, v0)</code> by default.</p>
|
|
||||||
|
|
||||||
<p>You can specify a pattern file when the executable is invoked (not compile-time). The file should include a sequence of points, see <code>ioccc.txt</code>, <code>center.txt</code>, or <code>line.txt</code> as examples. Each amount in cells near to the point included in the file, will be added by <code>(u1, v1)</code>.</p>
|
|
||||||
|
|
||||||
<h4>Simulation speed: <code>-DTIMESTEP=ts -DSPEED=spd</code></h4>
|
|
||||||
|
|
||||||
<p>The definitions are for changing the simulation speed.</p>
|
|
||||||
|
|
||||||
<p><code>TIMESTEP</code> is a simulation time step. The bigger, the faster but more unstable.</p>
|
|
||||||
|
|
||||||
<p><code>SPEED</code> is a frameskip parameter. The bigger, the faster but more sluggish.</p>
|
|
||||||
|
|
||||||
<h4>Rendering color: <code>-DRGB=r:g:b</code></h4>
|
|
||||||
|
|
||||||
<p>This specifies a color used for rendering.</p>
|
|
||||||
|
|
||||||
<h3>Examples</h3>
|
|
||||||
|
|
||||||
<p>Some interesting parameters are included in <code>Makefile</code>. Do one of the following command and open <code>http://127.0.0.1:10333</code>.</p>
|
|
||||||
|
|
||||||
<pre><code>$ make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 ioccc.txt
|
|
||||||
$ make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 center.txt
|
|
||||||
$ make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 line.txt
|
|
||||||
$ make gray-scott-2 && tcpserver -v 127.0.0.1 10333 ./gray-scott-2 ioccc.txt
|
|
||||||
$ make gray-scott-3 && tcpserver -v 127.0.0.1 10333 ./gray-scott-3 ioccc.txt
|
|
||||||
$ make gray-scott-4 && tcpserver -v 127.0.0.1 10333 ./gray-scott-4 ioccc.txt
|
|
||||||
$ make fitzhugh-nagumo-1 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-1 ioccc.txt
|
|
||||||
$ make fitzhugh-nagumo-2 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-2 ioccc.txt
|
|
||||||
$ make oregonator && tcpserver -v 127.0.0.1 10333 ./oregonator ioccc.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>These examples are created by drawing (and modifying) the pattern files of <a href="https://github.com/GollyGang/ready">Ready</a>, a cross-platform implementation of various reaction-diffusion systems [2].</p>
|
|
||||||
|
|
||||||
<h3>Compatibility</h3>
|
|
||||||
|
|
||||||
<h4>C part</h4>
|
|
||||||
|
|
||||||
<p>This program compiles clean with no warnings under <code>-std=c99 -Wall -Wextra -pedantic</code>. Since it uses <code>long long</code> for 64bit integers, C99 is required.</p>
|
|
||||||
|
|
||||||
<h4>Browser part</h4>
|
|
||||||
|
|
||||||
<p>You must use a modern browser that supports the latest specification of WebSocket [3]. All the following browsers worked for me:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Google Chrome 45</li>
|
|
||||||
<li>Mozilla Firefox 39</li>
|
|
||||||
<li>Microsoft Internet Explorer 11 (works but sluggish)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>I think Safari 6 will work but I haven’t tested. (I have no recent os x.)</p>
|
|
||||||
|
|
||||||
<h4>tcpserver alternatives</h4>
|
|
||||||
|
|
||||||
<p>I think you may use <code>inetd</code> and <code>xinetd</code> instead of <code>tcpserver</code>. Here is an example of inetd configuration.</p>
|
|
||||||
|
|
||||||
<pre><code>10333 stream tcp nowait nobody /path/to/prog /path/to/prog /path/to/initial-pattern.txt
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>But note that I didn’t test well.</p>
|
|
||||||
|
|
||||||
<h3>Internal</h3>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li>The C program accepts HTTP connection from the browser, and sends a HTML document.</li>
|
|
||||||
<li>The browser tries to upgrade the connection to WebSocket.</li>
|
|
||||||
<li>The C program accepts WebSocket upgrade. This negotiation process requires SHA1 hash [4] and Base64 encoding [5]. The C program calculates them without the aid of any external libraries.</li>
|
|
||||||
<li>The C program simulates the reaction-diffusion system, and then send the field data to the browser on each frame.</li>
|
|
||||||
<li>The browser receives and renders the field data onto the HTML5 canvas.</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>References</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>[1] Turing, A. M., “The Chemical Basis of Morphogenesis”, Philosophical Transactions of the Royal Society, 1952.</li>
|
|
||||||
<li>[2] The Ready Bunch, “Ready”, A cross-platform implementation of various reaction-diffusion systems, since 2011, <a href="https://github.com/GollyGang/ready">https://github.com/GollyGang/ready</a>.</li>
|
|
||||||
<li>[3] Fette, I. and A. Melnikov, “The WebSocket Protocol”, RFC 6455, DOI 10.17487/RFC6455, December 2011, <a href="http://www.rfc-editor.org/info/rfc6455">http://www.rfc-editor.org/info/rfc6455</a>.</li>
|
|
||||||
<li>[4] Eastlake 3rd, D. and P. Jones, “US Secure Hash Algorithm 1 (SHA1)”, RFC 3174, DOI 10.17487/RFC3174, September 2001, <a href="http://www.rfc-editor.org/info/rfc3174">http://www.rfc-editor.org/info/rfc3174</a>.</li>
|
|
||||||
<li>[5] Josefsson, S., “The Base16, Base32, and Base64 Data Encodings”, RFC 4648, DOI 10.17487/RFC4648, October 2006, <a href="http://www.rfc-editor.org/info/rfc4648">http://www.rfc-editor.org/info/rfc4648</a>.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Overlooked Obfuscation</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Overlooked Obfuscation</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a><br>
|
|
||||||
Twitter: @mametter</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>cat prog.c
|
|
||||||
|
|
||||||
./prog | diff - prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>At this point you might be wondering, <a href="http://acronyms.thefreedictionary.com/WTF">WTF</a>?*</p>
|
|
||||||
|
|
||||||
<pre><code>* What The Freak (polite form)
|
|
||||||
|
|
||||||
* What's This For? (you may be wondering)
|
|
||||||
|
|
||||||
* What the Fish (python form)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>How is this code obfuscated? Well look again:</p>
|
|
||||||
|
|
||||||
<pre><code>less prog.c
|
|
||||||
|
|
||||||
more prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Where did those underscores come from? Well <a href="http://acronyms.thefreedictionary.com/RTFS">RTFS</a>!**</p>
|
|
||||||
|
|
||||||
<pre><code>** Read the Freaking Source (polite form)
|
|
||||||
** Read The Freakin' Screen (polite form)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>If you are still puzzled, look at prog.c with your favorite text editor.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p><strong>Follow this instruction literally!</strong></p>
|
|
||||||
|
|
||||||
<pre><code>cat prog.c
|
|
||||||
gcc -w -o prog prog.c
|
|
||||||
./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>You will do a double take.</p>
|
|
||||||
|
|
||||||
<p>Hint 1: Do <code>less prog.c</code>. You will see an <strong>emphasized</strong> string if your terminal supports bold.</p>
|
|
||||||
|
|
||||||
<p>Hint 2: Do <code>wc -c prog.c</code>. This is very long one-liner.</p>
|
|
||||||
|
|
||||||
<p>Spoiler: Open the source with an editor like <code>vim</code> or <code>emacs</code>.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,234 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Back to the Future Award</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Back to the Future Award</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a><br>
|
|
||||||
Twitter: @mametter</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>make -B BACK_TO=ioccc.c
|
|
||||||
|
|
||||||
./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Like Marty and Doc, something nostalgic from 1984 appears live in October of 2015!
|
|
||||||
The author of this gem is a true Delorean!</p>
|
|
||||||
|
|
||||||
<p>A question for inquisitive readers: is the implemented subset of PDP-11 instructions Turing-complete?
|
|
||||||
(For a clue, see the end of the author’s remarks.)
|
|
||||||
If in doubt, use <a href="http://www.tuhs.org/Archive/PDP-11/Emulators/Apout/">APOUT</a>.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Hint / Compatibility</h3>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>A little-endian system is required due to an external factor.</li>
|
|
||||||
<li>Strictly speaking, this program does not comply with any C specification for the same reason. But I believe it is reasonably portable.</li>
|
|
||||||
<li>It uses a GCC extension but works on clang.</li>
|
|
||||||
<li>This is a kind of emulator. You may find its architecture name if you look at the source code from all angles.</li>
|
|
||||||
<li>Find main() function.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Spoiler</h3>
|
|
||||||
|
|
||||||
<p>This program is a joke PDP-11 emulator. (“ll-dpd” is embedded in the code. Read it upside down.)</p>
|
|
||||||
|
|
||||||
<p>You got it? This program is supposed to be used in this way:</p>
|
|
||||||
|
|
||||||
<pre><code>$ wget http://ioccc.org/1984/mullender.c
|
|
||||||
$ clang -o prog prog.c mullender.c
|
|
||||||
$ ./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>You can enjoy the legendary winner of the first IOCCC, again.</p>
|
|
||||||
|
|
||||||
<h3>Internal</h3>
|
|
||||||
|
|
||||||
<p>This program uses <code>__attribute__((constructor))</code>, which is a GCC extension, to hijack the main function call. And then it interprets main as an instruction sequence.</p>
|
|
||||||
|
|
||||||
<p>It supports the minimal subset of instructions and addressing modes which are needed for mullender.c to work:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>Instructions</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>BR: branch</li>
|
|
||||||
<li>MOV: move</li>
|
|
||||||
<li>SOB: subtract one and branch</li>
|
|
||||||
<li>SUB: subtract</li>
|
|
||||||
<li>TRAP 4: write syscall</li>
|
|
||||||
<li>TST: test (no flag is supported, though)</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li><p>Addressing modes</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>0: Register</li>
|
|
||||||
<li>1: Register deferred</li>
|
|
||||||
<li>2: Autoincrement</li>
|
|
||||||
<li>4: Autodecrement deferred</li>
|
|
||||||
<li>6: Index (incomplete)</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Limitation</h3>
|
|
||||||
|
|
||||||
<p>Non-trivial combination of instruction and addressing mode may cause undefined behavior (unsequenced modification), such as attempting to autoincrement a destination register. Index addressing mode works well only for R7 (PC register).</p>
|
|
||||||
|
|
||||||
<h3>One more thing</h3>
|
|
||||||
|
|
||||||
<p>Note: the program writes a binary to stdout.</p>
|
|
||||||
|
|
||||||
<pre><code>short main[]={5568,1,-30460,12,2782,0,-29921,2056,-4864,6873,770,30054,11886,
|
|
||||||
24948,114,21716,-28851,14043,-8944,32691,-16187,-12247,22692,-9781,-20403,
|
|
||||||
-11771,16546,18710,17873,9233,31304,-32215,-24382,-28247,-25916,10466,24988,
|
|
||||||
-3404,-4177,-28528,-531,-3016,17300,-28552,-7708,-26180,-4297,-367,-2312,
|
|
||||||
-25611,28535,-8533,24004,25421,-1224,-5354,-20807,-21589,-6761,-5203,-1055,
|
|
||||||
-6715,-26673,-1433,-17732,-24198,14681,-3714,-6660,-14891,-25575,20349,-7701,
|
|
||||||
-8336,31433,16695,-14773,26819,3096,-12584,-28808,17825,-21200,-32399,15877,
|
|
||||||
-28890,-3728,-27126,21375,-32630,-7615,32004,-29230,-6611,-5508,-28921,12418,
|
|
||||||
27204,-5725,9643,3520,26836,-29347,2101,-29311,9320,29287,-29990,-6593,29825,
|
|
||||||
-29114,16232,25641,20672,-23501,-32127,-6546,-956,10474,-29647,1070,5516,13760,
|
|
||||||
-27814,-32488,-28006,-17968,-3146,10963,19234,22132,23988,7142,5523,9639,-6888,
|
|
||||||
-11428,7964,23099,-16822,16518,31109,-12958,10351,2434,3091,3625,2244,27512,
|
|
||||||
-28559,-10724,-19377,23625,30056,11478,-21176,27660,26517,-29037,-9390,12297,
|
|
||||||
-11903,5980,-21927,-7483,6671,11249,29638,-23827,-26358,-6856,-1063,-5303,
|
|
||||||
26636,25797,31818,26798,-4243,-18772,-13266,27472,-12005,-10642,-22524,24373,
|
|
||||||
-13111,-9062,6274,-20002,24150,22189,-14965,-31249,-13934,-6341,-18384,-32054,
|
|
||||||
-29246,10622,-9260,19428,-15485,2724,23810,16447,11627,18604,2739,27812,30295,
|
|
||||||
-21538,-31786,11355,-11308,-9006,-4987,25363,-18927,-21130,-31213,-27411,17231,
|
|
||||||
-19608,20232,27754,16476,11213,-19803,-24048,30918,-25329,21233,-10160,13519,
|
|
||||||
11828,26653,-6703,10893,6871,-12417,24471,20310,-12137,-19677,4457,-19530,
|
|
||||||
10147,17724,533,-10055,27076,10264,11274,-10511,4809,25208,16065,-5105,-19953,
|
|
||||||
3772,-12124,13475,-27559,-9955,26446,15133,15207,-23640,6425,-11010,28688,
|
|
||||||
-20064,26353,-889,-25008,10380,-14449,-6894,18920,-23900,16902,-31018,16093,
|
|
||||||
20875,-19576,4585,13126,18589,24789,19424,31274,-5059,-14538,-3125,-16527,
|
|
||||||
-25070,-9013,26628,15756,-7652,30841,-1283,17707,25717,-18315,-6342,6880,
|
|
||||||
-19176,6995,5672,2853,-9044,-3409,-14421,-7522,13108,20582,-25317,1376,-5648,
|
|
||||||
13821,17300,1220,-29437,-25832,-8332,-15575,-9744,28297,31995,-1217,23852,
|
|
||||||
14382,31059,9160,-3296,20287,-28357,24449,-10323,-21992,-4655,-32548,13237,
|
|
||||||
-15083,-25226,-21121,2015,-8996,-20247,-27551,-14771,-16089,-6920,-9645,21578,
|
|
||||||
7142,-5613,14029,24730,-29253,13931,-3862,-16634,-7388,16951,15771,31302,
|
|
||||||
-22186,-6716,18416,1698,-26200,-16231,9821,-10886,-4994,-30527,-9448,-16923,
|
|
||||||
29549,-11207,-14909,-3643,-27548,17865,28859,29753,17616,16874,-17733,9424,
|
|
||||||
21435,-31715,24544,8666,30844,25075,-18267,12027,-5346,2717,19615,-4548,-21763,
|
|
||||||
28514,11691,22268,-2338,1406,-27379,-23568,-24525,13633,11295,-14715,7877,
|
|
||||||
-27669,3475,20345,7779,-17849,2184,7132,4079,-24937,11585,22740,5810,-10855,
|
|
||||||
16203,-6371,23235,-7,-24828,-11205,-11006,-10,-17812,-14274,11504,-27517,463,
|
|
||||||
4498,-32180,-9775,-3190,-22435,-18662,-30146,-31834,-26449,-19374,-12616,
|
|
||||||
-10596,14341,-10089,-18449,-16535,21439,21191,-1651,7695,-30009,-23339,-8675,
|
|
||||||
-20774,21588,-2793,8218,-14337,-10866,14060,-15343,31712,25247,-8539,18074,
|
|
||||||
-28683,-7363,-7663,-3563,-30718,17771,28687,-30495,30584,14022,-28053,5292,
|
|
||||||
-31576,-32486,-15470,-1330,23551,-2185,-10829,-13216,-4825,-2964,-14668,24559,
|
|
||||||
-4930,23731,-1152,-11493,-2321,15987,-27073,-20305,-24065,-25048,32750,-27440,
|
|
||||||
-1169,-25633,-4356,-24993,30439,-17165,-4580,8662,22655,-4588,-6162,-3122,
|
|
||||||
31986,-2569,20371,-12320,-25613,-16133,-25644,23677,12254,5855,26325,-13425,
|
|
||||||
-15903,-1930,-28488,31222,31153,17607,-2758,7594,-8868,30434,-2518,27956,
|
|
||||||
-19424,7370,6199,-17602,17347,-14358,25588,11611,-25209,-23701,-27444,-29788,
|
|
||||||
2680,-27406,9318,22483,-28356,28482,4577,-14891,17323,-30152,2507,2977,5004,
|
|
||||||
-11696,-31623,-15149,13357,28938,-14048,19490,-19860,-26050,10842,-24922,
|
|
||||||
-20986,8847,-31184,28519,-29168,32195,10516,25713,-3493,670,31283,-12769,
|
|
||||||
-17461,11357,13180,26133,15944,18051,-32167,-27990,16813,17676,21787,-17578,
|
|
||||||
11173,19093,2836,656,-15239,4632,23937,4106,-21655,-7494,-21575,-17647,-18465,
|
|
||||||
-14654,-29990,-10707,-12440,21465,5822,26164,-1404,-14303,-26635,-6900,-23611,
|
|
||||||
11998,-18551,971,27579,13325,4579,23059,29281,22291,29880,-17546,25664,-14990,
|
|
||||||
-526,-35,28218,-3214,11965,11263,6633,30719,32400,-29,-3733,24383,32678,-27542,
|
|
||||||
-4444,6196,5975,-19722,11902,16840,-11680,11146,-26391,-8980,21573,-9043,2349,
|
|
||||||
-12887,5916,-2996,10410,-23374,26338,11867,-14518,18281,14450,-5815,13842,359,
|
|
||||||
25450,27043,3355,13423,-20880,-26311,-30720,-2503,-6046,-18156,-18558,-14774,
|
|
||||||
-15664,-29001,3365,-12689,10233,23608,24692,12039,15445,18411,-27469,3764,
|
|
||||||
-10841,22672,23844,2282,-12443,2851,-27163,13651,13738,17201,-29819,27414,
|
|
||||||
-29764,-5308,-16171,-32427,-26312,-7460,-27376,-6004,25717,29254,-15015,8754,
|
|
||||||
15493,22232,-28513,-23355,23676,7736,10571,-8120,-16677,7696,32549,-2646,25538,
|
|
||||||
3498,30960,-28459,24716,12655,-10496,402,26209,482,-16661,-20350,-3403,14015,
|
|
||||||
32299,11262,-25886,4092,-7843,-100,-1975,-58,-3729,-19269,-23583,-6929,20000,
|
|
||||||
-6089,17780,-3250,29830,19954,-29277,27896,10330,9277,-25358,31279,-14454,
|
|
||||||
24203,-30170,12872,-21973,-25773,-10502,-6647,-26143,6394,-13479,-24559,23007,
|
|
||||||
-21844,1505,24702,-23187,-24364,-20470,20765,-7107,15674,9404,17408,17964,
|
|
||||||
19820,18952,2154,-26052,30056,-3227,17770,-8557,-31018,-27700,-25974,9003,
|
|
||||||
18218,22730,-19981,6737,3532,1562,-23626,14990,28472,-5270,17358,-32204,-29197,
|
|
||||||
-3647,4296,8588,25302,-23906,30328,-29119,-24392,8992,-16557,31530,-31216,
|
|
||||||
14107,13041,-6976,7529,-8296,17865,-1462,8181,-21588,-131,-10177,-25931,-14627,
|
|
||||||
8301,3708,-32097,20808,13892,-21179,1192,20853,3249,-8774,20843,3520,24954,
|
|
||||||
-14215,-25170,-16170,2390,25964,-23923,-17464,-7177,-27568,-9880,-4647,-7323,
|
|
||||||
15388,2113,-12338,-7737,26255,26818,-22156,-19610,-911,-17057,-556,29935,27647,
|
|
||||||
31806,23676,-18132,-19234,-10869,-3715,24983,-10900,-29564,19856,-16392,-31860,
|
|
||||||
-25826,24077,12080,15383,-29852,-2266,-27217,31931,-3183,17385,-14211,19050,
|
|
||||||
-2449,-468,-2871,-11466,973,2866,649,1367,-8688,-24069,20992,25139,-25850,1184,
|
|
||||||
15851,785,16951,12160,22337,-21851,1849,-18801,14247,-429,-12682,30881,-11273,
|
|
||||||
-24819,-9794,8389,-27287,7525,16633,1328,-26650,32607,-8217,31912,7774,-16188,
|
|
||||||
-3546,-6550,-16279,-32696,1940,2577,-23723,-6484,2009,-424,27833,-21763,-13902,
|
|
||||||
7044,27360,-18450,27889,23987,3137,-7669,-5784,-7490,24946,32302,26464,-15513,
|
|
||||||
28898,2493,-17645,-4615,-13434,-20884,-4058,-29951,-22281,24784,21083,-8536,
|
|
||||||
22147,-11261,-15069,20659,2993,19029,21909,6748,-3263,1401,30960,11000,-16871,
|
|
||||||
-30566,-14959,-26356,-2885,21526,-26531,31063,12857,4992,-5067,3130,-17602,
|
|
||||||
-1732,-6593,30200,24679,3267,310,20733,24863,-15669,7875,-4577,-13821,-22325,
|
|
||||||
15548,29744,3733,-14547,21459,22122,3854,-2572,30197,-24770,-21263,8793,-8316,
|
|
||||||
1571,28191,-16143,-6446,31524,-26496,-17349,-29097,2806,11281,-7041,-683,14149,
|
|
||||||
19689,-22094,-1657,-30904,183,-15226,-6358,25461,461,1495,28345,-10554,-4004,
|
|
||||||
27119,13484,-21600,-12272,-7272,-14064,-299,10697,11280,19066,-9841,-7265,
|
|
||||||
-18002,19906,-17247,21482,-10939,-5897,-22300,-13978,27575,-8684,-6222,-19041,
|
|
||||||
5788,-30863,-10134,15142,2895,14705,-17713,12940,-21535,-11619,29416,18417,
|
|
||||||
-24973,24867,-26462,-24910,-32556,-26705,-7187,-7750,-758,-14809,20289,9260,
|
|
||||||
13778,-1422,30301,-1922,30646,27662,-15465,-912,29340,13846,-1263,28887,-20019,
|
|
||||||
32421,-29411,-27632,-7495,-8368,29230,-6386,-19536,-5235,2054,1854,23563,12348,
|
|
||||||
-15165,-2936,-28063,-15760,20126,-25531,4963,-5739,23182,16895,-17258,-10470,
|
|
||||||
-3969,-7742,-140,4475,-24014,-31961,19231,27153,-18551,20157,26443,11530,
|
|
||||||
-22214,2284,-24238,-31051,-26422,9088,29868,18458,8488,-9515,6799,-12507,54,
|
|
||||||
-19441,-32665,12561,23560,4725,-28617,-14800,-10224,-13503,-17636,-16823,
|
|
||||||
-24072,18735,-29798,-23658,-670,-21769,7489,-6468,-8961,-14785,22255,11582,
|
|
||||||
-29831,16303,-19652,2922,-4362,22966,16173,-18446,-6148,27381,-8493,-32289,
|
|
||||||
24005,-3027,-18665,-16472,-17793,-27027,-7443,17854,31365,-17726,-2510,-17546,
|
|
||||||
14893,21773,-23634,21117,32533,6637,-1106,-8152,-3672,-113,-2149,-34,-22700,
|
|
||||||
-4102,-28533,-14104,-10086,4378,13695,-15320,-28258,2246,7595,30021,13281,
|
|
||||||
-11968,-29983,14274,27152,26713,19434,17058,1142,-3043,-16496,18630,-11976,
|
|
||||||
29168,-3634,32746,27287,-268,16711,-8712,-471,12895,17406,-22548,-3969,-10733,
|
|
||||||
13128,10530,-31667,7929,-32277,30926,-1983,8401,-7705,6790,4532,1442,26728,
|
|
||||||
29600,-15358,21622,9744,11406,15989,-30741,-15044,29913,24534,6774,-3755,17623,
|
|
||||||
19647,18762,10042,9653,-5889,2408,-32579,-6285,-28559,-30655,6294,-21175,4390,
|
|
||||||
1668,25437,2821,21066,-13680,5274,-27253,-5248,-26307,29744,-26428,25358,17196,
|
|
||||||
15199,-29784,-4604,25653,-8048,-23131,-28995,31340,-9558,26186,11268,27916,
|
|
||||||
9646,-7389,-11384,-29116,-4100,160,18394,7856,738,-25920,12148,24713,-31664,
|
|
||||||
8203,-25556,13494,30352,29161,30898,1432,-5991,25411,1344,-4019,22299,15685,
|
|
||||||
-16401,-23136,-28110,11874,-18945,1879,2,0,-32256,-20996,-18169,29220,12,0,0,0,
|
|
||||||
335,-27277,-30776,20480,0};
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best One-liner</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best One-liner</h1>
|
|
||||||
|
|
||||||
<p>Yusuke Endoh<br>
|
|
||||||
<a href="https://github.com/mame/">https://github.com/mame/</a><br>
|
|
||||||
Twitter: @mametter</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog <a number of arguments>
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog @ @ @ @ @ @
|
|
||||||
|
|
||||||
./prog @ @ @ @ @ @ @ @ @ @ @ @
|
|
||||||
|
|
||||||
./prog $(perl -e 'print "@ " x (2*3*5*7);')
|
|
||||||
|
|
||||||
./prog $(< Makefile)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>For this one liner it is best to avoid prime numbers. The output groups
|
|
||||||
factors in the x-y dimensions. How many factors can be represented before you
|
|
||||||
run out of command line argument space? How could you modify the program to
|
|
||||||
experiment with numbers that have more or larger factors?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>Visual factorization 1-liner. Try:</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -o prog prog.c
|
|
||||||
./prog @
|
|
||||||
./prog @ @
|
|
||||||
./prog @ @ @
|
|
||||||
./prog @ @ @ @
|
|
||||||
./prog @ @ @ @ @ @
|
|
||||||
./prog @ @ @ @ @ @ @ @
|
|
||||||
./prog @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Inspired by <a href="http://www.datapointed.net/visualizations/math/factorization/animated-diagrams/">Animated Factorization Diagrams</a>.</p>
|
|
||||||
|
|
||||||
<p>EDIT: <code>prog.orig.c</code> is the original version that I submitted. Gil Dogon kindly improved it during the review. Thank you!</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Well-rounded Hash</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Well-rounded Hash</h1>
|
|
||||||
|
|
||||||
<p>Qiming Hou <a href="mailto:hqm03ster@gmail.com">hqm03ster@gmail.com</a><br>
|
|
||||||
<a href="http://www.houqiming.net/">http://www.houqiming.net/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
echo IOCCC | ./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo "" | ./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>A good start for understanding this entry might be
|
|
||||||
https://www.ietf.org/rfc/rfc1321.txt. How does it compute this using only a
|
|
||||||
single looping construct? The original reference source code for this
|
|
||||||
algorithm is about 355 lines of code, yet this entry is only 199 lines with
|
|
||||||
one statement per line and it isn’t using lots of macro expansion tricks like
|
|
||||||
the reference code!</p>
|
|
||||||
|
|
||||||
<p>Some things that make you go, “huh?”</p>
|
|
||||||
|
|
||||||
<pre><code>./prog < prog.c | cut -c-5
|
|
||||||
./prog < Makefile | cut -c-4
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>How are those values magically returned?</p>
|
|
||||||
|
|
||||||
<p>What happens with a large file? Something over 256K</p>
|
|
||||||
|
|
||||||
<pre><code>./prog < large_file
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Where does that message come from?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This looks like a normal C program.</p>
|
|
||||||
|
|
||||||
<p>Almost everything is a double.</p>
|
|
||||||
|
|
||||||
<p>There are tell-tale signs like <code>pow(2,(?/12))</code> and <code>exp(-?*?)</code> (names redacted). You can also find a bunch of cosines and polynomial evaluations.</p>
|
|
||||||
|
|
||||||
<p>It looks like a ????? ???????????, right?</p>
|
|
||||||
|
|
||||||
<p>Run and find out.</p>
|
|
||||||
|
|
||||||
<h3>Why obfuscated</h3>
|
|
||||||
|
|
||||||
<p>Some poor scripting folks only have access to doubles (Jav?script, L?a, BA?IC, etc.).</p>
|
|
||||||
|
|
||||||
<p>As a C programmer, I feel obliged to show a gesture of sympathy, to experience their pain and provide an answer.</p>
|
|
||||||
|
|
||||||
<p>Except when absolutely necessary (<code>printf</code>, <code>int main()</code>, array indexing), there isn’t a single integer. Even <code>getchar()</code> and <code>EOF</code> are immediately converted.</p>
|
|
||||||
|
|
||||||
<p>Since <code>bool</code> counts as an integer type too, there is no boolean either. No comparison, no <code>if</code>, no <code>?:</code>, no <code>||</code> <code>&&</code>. Everything is done in a single loop that terminates on printf. Straight up arithmetic.</p>
|
|
||||||
|
|
||||||
<p><code>floor</code> and <code>ceil</code> are technically double-to-double functions, but they feel like cheating. Yes <code>cos</code>, no <code>floor</code>.</p>
|
|
||||||
|
|
||||||
<h3>Limitations</h3>
|
|
||||||
|
|
||||||
<p>Hard requirements:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>The platform must implement the <code>double</code> type as IEEE754-compliant 64-bit floating point numbers. The 80-bit intermediate format used by x87 is considered as an violation of this. The code should print an error message on such platforms.</p></li>
|
|
||||||
<li><p>The program must start with the CPU / FPU in round-to-nearest mode.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Soft requirements:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>The compiler must respect <code>volatile</code>. The code is formatted to warn about that, though.</p></li>
|
|
||||||
<li><p>The printed result is only correct on little-endian machines. The program takes care to warn about this issue after printing an incorrect big-endian result. Error messages become garbled, though.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Tested platforms:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Linux 3.18.7, Rasperberry Pi 2, clang 3.0-6.2, (works)</li>
|
|
||||||
<li>Linux 3.18.7, Rasperberry Pi 2, gcc 4.6.3, (works)</li>
|
|
||||||
<li>Mac OS X 10, x64, Apple LLVM version 6.1.0 (clang-602.0.53), (works)</li>
|
|
||||||
<li>Windows 8.1, x86, MSVC 2012 (works)</li>
|
|
||||||
<li>Windows 8.1, x64, MSVC 2012 (works)</li>
|
|
||||||
<li>Windows 8.1, x86, MinGW gcc 4.6.2 (fails, prints error message)</li>
|
|
||||||
<li>Windows 8.1, x86, MinGW gcc 4.6.2 with -msse2 -mfpmath=sse (works)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Different</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Different</h1>
|
|
||||||
|
|
||||||
<p>Anthony Howe <a href="mailto:achowe@snert.com">achowe@snert.com</a><br>
|
|
||||||
Montreal, Quebec, Canada<br>
|
|
||||||
<a href="http://www.snert.com/">http://www.snert.com/</a><br>
|
|
||||||
Twitter: @SirWumpus</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog file1 file2
|
|
||||||
|
|
||||||
./prog -d file1 file2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog prog.orig.c prog.c
|
|
||||||
|
|
||||||
make test
|
|
||||||
./prog -d ABXYEFCD.tmp ACDBECFD.tmp
|
|
||||||
./prog ABXYEFCD.tmp ACDBECFD.tmp
|
|
||||||
|
|
||||||
rm -f curds.tmp whey.tmp
|
|
||||||
cp /usr/share/man/man1/cc.1 curds.tmp
|
|
||||||
cp /usr/share/man/man1/cc.1 whey.tmp
|
|
||||||
chmod 666 whey.tmp
|
|
||||||
make makeholes
|
|
||||||
./makeholes -n 1000 whey.tmp
|
|
||||||
./prog curds.tmp whey.tmp
|
|
||||||
./avgtime.sh 100 ./prog curds.tmp whey.tmp
|
|
||||||
|
|
||||||
# Assuming curl(1) installed, grab a really HUGE text file.
|
|
||||||
curl -L -o war-and-peace.txt http://www.gutenberg.org/ebooks/2600.txt.utf-8
|
|
||||||
cp war-and-peace.txt nuked.tmp
|
|
||||||
./makeholes -c'~' -n 1000 nuked.tmp
|
|
||||||
./prog war-and-peace.txt nuked.tmp
|
|
||||||
./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This is the best use of the FNV that we have seen in the IOCCC so far!
|
|
||||||
The output, when used without -d, is compatible with POSIX diff and
|
|
||||||
is suitable for use with patch.</p>
|
|
||||||
|
|
||||||
<p>We welcome back Canada to the list of nations from where winning
|
|
||||||
entries have been submitted.</p>
|
|
||||||
|
|
||||||
<p>Is this code a bug or a feature? :-) Or is this an attempt to corrupt the
|
|
||||||
programming of our youth? Should we heed Kyle’s mom words that she uttered
|
|
||||||
during a South Park P.T.A. Meeting?</p>
|
|
||||||
|
|
||||||
<p> “We must stop dirty © language from getting to our children’s ears!”</p>
|
|
||||||
|
|
||||||
<p> <a href="https://www.youtube.com/watch?v=bOR38552MJA">Blame Canada</a>:</p>
|
|
||||||
|
|
||||||
<p>Or should we teach our youth to understand the intricacies of this code?
|
|
||||||
Ying Tong Iddle I Po! We suggest you read the source for yourself, which
|
|
||||||
might be easier than the academic papers it was inspired by.</p>
|
|
||||||
|
|
||||||
<p>NOTE: Unlike the original entry source, prog.orig.c, prog.c uses a
|
|
||||||
64 bit FNV hash and fixes a function call warning.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>Features</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p>“An O(NP) Sequence Comparison Algorithm” by Wu, Manber, Myers, Miller.</p></li>
|
|
||||||
<li><p>Output compatible with patch(1).</p></li>
|
|
||||||
<li><p>Strokes one of the judge’s ego (I couldn’t email chocolate or curry).</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Description</h2>
|
|
||||||
|
|
||||||
<p>This is a functioning micro diff tool using an <a href="http://myerslab.mpi-cbg.de/wp-content/uploads/2014/06/np_diff.pdf">O(NP) algorithm</a>, compared to the older <a href="http://www.xmailserver.org/diff2.pdf">O(ND) difference algorithm</a> used by some versions of diff. Its output is based on the default diff(1) output described by POSIX and <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html">The Open Group Base Specifications</a>. The output is suitable for use with patch(1).</p>
|
|
||||||
|
|
||||||
<p>The -d option simply writes the edit distance between file1 and file2.</p>
|
|
||||||
|
|
||||||
<h2>Observations</h2>
|
|
||||||
|
|
||||||
<p>The FNV1a hash is a little slow compared to the trival hash GNU Diff uses. I downloaded a plain text copy of “War And Peace” from Project Gutenberg, used <code>makeholes.c</code> to make 1000 random changes, then profiled and timed the program verses GNU Diff. The bottle neck appears to be in the file I/O and line hashing with an average +0.05s slower. Using a huge file like “War And Peace” for testing offsets the diff(1) optimised file I/O.</p>
|
|
||||||
|
|
||||||
<p>There is no hash collision checking, partly because FNV1a appears to generate very <a href="http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed">few collisions</a> and an assumption that localised collisions within a region of edits are highly unlikely.</p>
|
|
||||||
|
|
||||||
<h2>Support Files</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><p><code>prog-test.sh</code><br>
|
|
||||||
Basic test program verifies known test edit distances and patch support.</p></li>
|
|
||||||
<li><p><code>avgtime.sh</code></p></li>
|
|
||||||
<li><p><code>makeholes.c</code><br>
|
|
||||||
Random edits (holes) made to a file in-place.</p></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>References</h2>
|
|
||||||
|
|
||||||
<p>Wu, Manber, Myers, and Miller; August 1989;<br>
|
|
||||||
“An O(NP) Sequence Comparison Algorithm”;<br>
|
|
||||||
<a href="http://myerslab.mpi-cbg.de/wp-content/uploads/2014/06/np_diff.pdf">http://myerslab.mpi-cbg.de/wp-content/uploads/2014/06/np_diff.pdf</a></p>
|
|
||||||
|
|
||||||
<p>Fowler, Noll, Vo; 1994<br>
|
|
||||||
<a href="http://www.isthe.com/chongo/tech/comp/fnv/index.html">http://www.isthe.com/chongo/tech/comp/fnv/index.html</a></p>
|
|
||||||
|
|
||||||
<p>Fowler, Noll, Vo on Wikipedia<br>
|
|
||||||
<a href="https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function">https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function</a></p>
|
|
||||||
|
|
||||||
<p>“diff”, The Open Group Base Specifications Issue 7<br>
|
|
||||||
IEEE Std 1003.1, 2013 Edition<br>
|
|
||||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html">http://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html</a></p>
|
|
||||||
|
|
||||||
<p>Eugene W. Myers; “An O(ND) Difference Algorithm and Its Variations”;<br>
|
|
||||||
Algorithmica, 1986, pages. 251-266<br>
|
|
||||||
<a href="http://www.xmailserver.org/diff2.pdf">http://www.xmailserver.org/diff2.pdf</a></p>
|
|
||||||
|
|
||||||
<p>Webb Miller and Eugene W. Myers; “A File Comparison Program”;<br>
|
|
||||||
Software-Practice And Experience, Vol. 15(11). 1025-1040 (November 1985)<br>
|
|
||||||
<a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.189.70&rep=rep1&type=pdf">http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.189.70&rep=rep1&type=pdf</a></p>
|
|
||||||
|
|
||||||
<p>D.S. Hirschberg, “A linear space algorithm for computing maximal common subsequence problem”;<br>
|
|
||||||
Comm. of ACM, Vol. 18, June 1975, pages 341-343<br>
|
|
||||||
<a href="http://www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/DynProg/Docs/Hirschberg-LCS-1975.pdf">http://www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/DynProg/Docs/Hirschberg-LCS-1975.pdf</a></p>
|
|
||||||
|
|
||||||
<p>Which hashing algorithm is best for uniqueness and speed?<br>
|
|
||||||
<a href="http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed">http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed</a></p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>"For the Birds!" Award</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>“For the Birds!” Award</h1>
|
|
||||||
|
|
||||||
<p>Chris Mills<br>
|
|
||||||
Twitter: @MisterXopher</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>Pressing the up arrow and the down arrow at the right time.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Did you find that mobile application game a bit frustrating?
|
|
||||||
Well you can adjust the makefile parameters to make life a
|
|
||||||
bit easier for you:</p>
|
|
||||||
|
|
||||||
<pre><code>make clobber all DW=199999 DW=22 DH=16 DA=50 DI=-150
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>From the makefile:</p>
|
|
||||||
|
|
||||||
<pre><code># Game parameters
|
|
||||||
#
|
|
||||||
DU=99999 # Time between steps in microseconds.
|
|
||||||
# Make it larger if the game is too fast for you.
|
|
||||||
|
|
||||||
DW=28 # Pipe-to-pipe spacing, in columns.
|
|
||||||
# Farther apart is easier.
|
|
||||||
|
|
||||||
DD=20 # Space between pipes.
|
|
||||||
# The difference between DD and DW is the width of a pipe.
|
|
||||||
# Narrow pipes are easier to fly though.
|
|
||||||
|
|
||||||
DH=8 # Height of gap in pipe.
|
|
||||||
# Make this larger to make the game easier.
|
|
||||||
|
|
||||||
DA=100 # Acceleration due to gravity (scaled by 256).
|
|
||||||
# Smaller values make you glide slower.
|
|
||||||
|
|
||||||
DI=-200 # Impulse velocity of a flap (scaled by 256).
|
|
||||||
# Make larger if you want an less intense tapping experience!
|
|
||||||
|
|
||||||
DB='"<o^="' # Sprite for player when gliding.
|
|
||||||
# HINT: Try using various emoji.
|
|
||||||
# NOTE: The string MUST be enclosed inside double quotes.
|
|
||||||
|
|
||||||
DF='"<ov="' # Sprite for player when flapping.
|
|
||||||
# HINT: Try using various emoji.
|
|
||||||
# NOTE: The string MUST be enclosed inside double quotes.
|
|
||||||
|
|
||||||
DG='"Tap to Flap!"' # Instruction text.
|
|
||||||
# Change to your native tongue.
|
|
||||||
# NOTE: The string MUST be enclosed inside double quotes.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Enjoy!</p>
|
|
||||||
|
|
||||||
<pre><code>TAP!! TAP!! TAP!!
|
|
||||||
FLAP! FLAP! FLAP!
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>The Program</h1>
|
|
||||||
|
|
||||||
<p>Better late than never to jump on the bandwagon of 2014’s most successful
|
|
||||||
mobile game. The game is called Tappy Bird, and has all the sophisticated
|
|
||||||
gameplay of the original, except with an exciting twist! (you get to fly to
|
|
||||||
the right instead of to the left).</p>
|
|
||||||
|
|
||||||
<p>In addition, the game features exciting new customization options! Too hard?
|
|
||||||
Ran into that damn wall too many times? Now you can change physics! Change
|
|
||||||
any of a number of parameters (speed, gravity, etc.) of the game to suit your
|
|
||||||
gameplay!</p>
|
|
||||||
|
|
||||||
<p>You can even make the game more challenging – resize the terminal window to
|
|
||||||
make the world taller or shorter. You’ll never be able to get through the
|
|
||||||
pipes when they are four times as tall!</p>
|
|
||||||
|
|
||||||
<h2>Instructions</h2>
|
|
||||||
|
|
||||||
<p>The instructions are printed at the start of the game: Tap to Flap!</p>
|
|
||||||
|
|
||||||
<p>Hit any key to make your bird fly. Navigate her between the gaps in the pipes.
|
|
||||||
Your score is shown in the upper left, along with your current high-score.</p>
|
|
||||||
|
|
||||||
<h2>Customization options</h2>
|
|
||||||
|
|
||||||
<p>To customize the gameplay, change any of the following options on the compile
|
|
||||||
command line:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>-DU</code>: Time between steps in microseconds. Make it larger if the game
|
|
||||||
is too fast for you.</li>
|
|
||||||
<li><code>-DW</code>: Pipe-to-pipe spacing, in columns. Farther apart is easier.</li>
|
|
||||||
<li><code>-DD</code>: Space between pipes. The difference between <code>D</code> and <code>W</code> is the
|
|
||||||
width of the pipe. Narrow pipes are easier to fly though.</li>
|
|
||||||
<li><code>-DH</code>: Height of gap in pipe. Make this larger to reduce the challenge.</li>
|
|
||||||
<li><code>-DA</code>: Acceleration due to gravity (scaled by 256). Smaller values
|
|
||||||
make you glide slower.</li>
|
|
||||||
<li><code>-DI</code>: Impulse velocity of a flap (scaled by 256). Make this smaller
|
|
||||||
if you want an intense tapping experience!</li>
|
|
||||||
<li><code>-DB</code>: Sprite for player when gliding.</li>
|
|
||||||
<li><code>-DF</code>: Sprite for player when flapping.</li>
|
|
||||||
<li><code>-DG</code>: Instruction text. Change to your native tongue.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Feel free to try out physics or playfield options to make the game more
|
|
||||||
interesting. Try setting the player sprites to change the game completely –
|
|
||||||
maybe you can be a fish, or a pig – the options are limitless! Try using
|
|
||||||
emoji – you can be a flying beer mug!</p>
|
|
||||||
|
|
||||||
<p>Note that since the <code>curses</code> library on POSIX doesn’t natively support wide
|
|
||||||
characters (needed for UTF-8 support, which is needed for emoji), you may need
|
|
||||||
to make some changes to the <code>Makefile</code> to get emoji to work on your system.
|
|
||||||
To help you get started, I’ve included some example substitutions for emoji
|
|
||||||
sprites and instruction text; for example, type</p>
|
|
||||||
|
|
||||||
<pre><code>make EMOJI=beer LANGUAGE=spanish
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>or</p>
|
|
||||||
|
|
||||||
<pre><code>make EMOJI=globe
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>for some examples (the full list of options is in the <code>Makefile</code>). Don’t
|
|
||||||
forget to <code>make clean</code> first. If the output doesn’t look right, you may need
|
|
||||||
to link with the “wide” version of <code>ncurses</code>. On MacOSX 10.11, it should work
|
|
||||||
with the current <code>-lcurses</code>; on Linux, you probably need <code>-lncursesw</code>.
|
|
||||||
See the <code>Makefile</code> to make this change if you need to. Or buy a Mac.</p>
|
|
||||||
|
|
||||||
<p>You will also need a UTF-8 compatible terminal and an emoji font installed,
|
|
||||||
and you will need to have your <code>LANG</code> environment variable set to use UTF-8.
|
|
||||||
Again, if this is too complicated, maybe just go and get that Mac.</p>
|
|
||||||
|
|
||||||
<h2>Future additions</h2>
|
|
||||||
|
|
||||||
<p>Future versions of the game will include monitization via the freemium model
|
|
||||||
with micropayments for customization options, play-to-win and of course
|
|
||||||
live-streamed targeted video advertising.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Compact</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Compact</h1>
|
|
||||||
|
|
||||||
<p>Chris Mills<br>
|
|
||||||
Twitter: @MisterXopher</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog compressed_file.Z
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>printf '000I\236\f\31H\260\240\301\203' > ioccc.Z
|
|
||||||
./prog ioccc.Z
|
|
||||||
|
|
||||||
dd bs=1k count=4096 < /dev/urandom > test1
|
|
||||||
compress < test1 > test1.Z
|
|
||||||
time ./prog test1.Z | cmp - test1
|
|
||||||
|
|
||||||
dd bs=1k count=4096 < /dev/zero > test2
|
|
||||||
compress < test2 > test2.Z
|
|
||||||
time ./prog test2.Z | cmp - test2
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Without ASCII art, the source code of this entry would have been exactly 256 bytes.
|
|
||||||
Compared to <a href="http://ioccc.org/years.html#1990_jaw">1990/jaw</a>, it is very impressive,
|
|
||||||
even taking into account the missing atob functionality. Now we wish for a compress(1)-like compressor
|
|
||||||
using a similar idea.</p>
|
|
||||||
|
|
||||||
<p>Why is the sad smiley on line 12 in that particular place?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>The Program</h1>
|
|
||||||
|
|
||||||
<p>This program is in implementation of the unix <code>zcat(1)</code> command for printing
|
|
||||||
compressed files that have been created by the <code>compress(1)</code> command.</p>
|
|
||||||
|
|
||||||
<p>The adaptive <a href="https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch">LZW</a> compression
|
|
||||||
employed by <code>compress</code> usually requires a fairly large amount of memory to
|
|
||||||
build the decompression tables (in fact, <code>compress</code> has a command-line option
|
|
||||||
to control the size of the decompression tables, since some of the early
|
|
||||||
systems to which it was ported (<em>cough</em>MS-DOS<em>cough</em>) did not have enough
|
|
||||||
memory to use the full 16-bit codes). This version has no large static or
|
|
||||||
dynamic tables. It is able to decompress 16-bit files using a single function
|
|
||||||
and a few ints.</p>
|
|
||||||
|
|
||||||
<p>To run the program, take an existing compressed file and pass it to the program
|
|
||||||
on the command line. On the odd chance you don’t have <code>compress</code> hanging about
|
|
||||||
on your system, I’ve provided compressed copies of this year’s IOCCC rules
|
|
||||||
and guidelines files. To print them, just do</p>
|
|
||||||
|
|
||||||
<pre><code>./prog ioccc_guidelines.txt.Z
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>The Details</h2>
|
|
||||||
|
|
||||||
<p>The basic cleverness here comes from realizing that the compressed data is
|
|
||||||
itself an encoded version of the code dictionary. When the encoder sees
|
|
||||||
an input string that is not in its dictionary, it emits the code corresponding
|
|
||||||
to the longest prefix that is in the dictionary and adds a new entry consisting
|
|
||||||
of that code followed by the next input character. This means that when the
|
|
||||||
decoder wants to know how to decode a code, it just needs to find the spot in
|
|
||||||
the code-stream where the encoder added that entry to the dictionary. The
|
|
||||||
code at that spot is the prefix, and the first character of the following code
|
|
||||||
is the suffix. Decoding then just becomes recursion, to follow the chain of
|
|
||||||
prefixes and suffix characters.</p>
|
|
||||||
|
|
||||||
<p>Of course, it’s not nearly that simple. Finding the code in the stream is
|
|
||||||
complicated by several issues:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Codes are at bit offsets within the stream, and must be extracted.</li>
|
|
||||||
<li>As codes are added to the dictionary, the code word size grows, so finding
|
|
||||||
the offset to a particular code word is involved.</li>
|
|
||||||
<li>The <code>compress</code> encoder reserves a code word that clears the coding tables.
|
|
||||||
When this is encountered, the computation of offsets and bit sizes reset.</li>
|
|
||||||
<li>The <code>compress</code> decoder is designed to always read a block of eight code
|
|
||||||
words at the same time, so that it need only read N bytes to get eight N-bit
|
|
||||||
code words. When the “clear” code is encountered, the entire eight-word
|
|
||||||
block is flushed (since the decoder didn’t know the word size would change).
|
|
||||||
The program needs to account for this extra flushing.</li>
|
|
||||||
<li>The end of the stream is not explicitly marked; the encoder just pads out
|
|
||||||
the output to the next byte. The decoder must notice this to know when
|
|
||||||
to stop.</li>
|
|
||||||
<li>The output stream contains a header that must be skipped.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>Managing all the details involved added a lovely additional layer of
|
|
||||||
obfuscation to the otherwise elegant recursive decoder. Still, the code
|
|
||||||
manages it in a remarkably small amount of code.</p>
|
|
||||||
|
|
||||||
<h2>Limitations</h2>
|
|
||||||
|
|
||||||
<p>The decoder doesn’t look at the header. If you supply something that is not
|
|
||||||
compressed data, it’s likely to crash in an interesting manner.</p>
|
|
||||||
|
|
||||||
<p>In particular, it doesn’t look at the third byte of the header, which encodes
|
|
||||||
the maximum code word size and whether “block mode” was used when the encoder
|
|
||||||
was run. If you use <code>compress</code> in its default mode, the maximum word size
|
|
||||||
will be 16 bits and “block mode” will be enabled. You are unlikely to find
|
|
||||||
any files that don’t use “block mode”, since all versions of <code>compress</code> after
|
|
||||||
2.0 (circa 1984) use it by default and have no documented way to disable it.
|
|
||||||
Reducing the bit depth is still possibly by using the <code>-b</code> flag. Modern
|
|
||||||
systems have no problem with the 200 KB or so needed for 16-bit decoder
|
|
||||||
tables, so the need for reducing the table size has passed, hence this program
|
|
||||||
always assumes 16-bits… However, should you find a file that needs a
|
|
||||||
smaller table, feel free to change the hard-coded 16 in the source into the
|
|
||||||
appropriate number and recompile.</p>
|
|
||||||
|
|
||||||
<p>In the event that you don’t supply an argument, or that argument doesn’t name
|
|
||||||
a readable file, the program will just silently exit. This is a feature.</p>
|
|
||||||
|
|
||||||
<p>The program depends on having a little-endian system. On a big-endian system
|
|
||||||
you will get a wierd big-endian version of <code>compress</code>, which might have come to
|
|
||||||
pass in an alternate universe where the vax on which <code>compress</code> was authored
|
|
||||||
had been big-endian. Luckily for us, it wasn’t, and neither are most of the
|
|
||||||
systems you might want to compile this for.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Complete Use of CPP</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Complete Use of CPP</h1>
|
|
||||||
|
|
||||||
<p>Dominik Muth <a href="mailto:muth.ioccc@freenet.de">muth.ioccc@freenet.de</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make -B [MACHINE=your_machine.h] [TAPE=your_tape.h] [X=[0|1|2|3|4|5|6|7|8|9]] [V=[0|1|2]] run
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>make -B V=2 run
|
|
||||||
|
|
||||||
strings prog | grep '(,)'
|
|
||||||
|
|
||||||
make -B MACHINE=machine_times2.h TAPE=tape_five.h V=1 run
|
|
||||||
|
|
||||||
make -B MACHINE=machine_chaos_5_2.h X=5 run
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This is something we were fearing all along: that the C preprocessor is Turing-complete
|
|
||||||
even without conditionals and recursive file inclusion as some kind of a
|
|
||||||
<a href="https://en.wikipedia.org/wiki/Rewriting">rewriting system</a>. Now we have the proof!</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h3>Preprocessor Turing Engine</h3>
|
|
||||||
|
|
||||||
<h4>Features</h4>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Turing machine runs in preprocessor</li>
|
|
||||||
<li>universal (unlimited configurable states, symbols, and tape)</li>
|
|
||||||
<li>no <code>#if</code>s or other conditional directives, only <code>#define</code>s</li>
|
|
||||||
<li>no recursive <code>#include</code></li>
|
|
||||||
<li>single compiler run (no repeated preprocessing)</li>
|
|
||||||
<li>no variadic macros</li>
|
|
||||||
<li>verbosity levels:
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>V=0</code> (default) only prints the final tape</li>
|
|
||||||
<li><code>V=1</code> additionally prints one tilde character per machine step (slow)</li>
|
|
||||||
<li><code>V=2</code> additionally prints details on each machine step (slow; generates large files)</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li>make target <code>run</code> runs <code>./prog</code> and filters a little statistics out of the verbose output</li>
|
|
||||||
<li><code>X</code> (defaults to 3) sets the maximum number of steps: <em>M</em>(<code>X</code>) ~ 8<sup><code>X</code></sup></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Limitations</h4>
|
|
||||||
|
|
||||||
<p>If the machine does not halt after <em>M</em>(<code>X</code>) steps, you will see unexpanded macros in the output.</p>
|
|
||||||
|
|
||||||
<h4>Compiler warnings</h4>
|
|
||||||
|
|
||||||
<p>If <code>V=1</code> or <code>V=2</code> is used, you may see “<code>warning: string length is greater than the length '4095' ISO C99 compilers are required to support</code>”.</p>
|
|
||||||
|
|
||||||
<h4>Programming</h4>
|
|
||||||
|
|
||||||
<p>Implementing your own Turing machine is easy. Take a look at the supplied header files for examples.</p>
|
|
||||||
|
|
||||||
<h5>Tape Symbols</h5>
|
|
||||||
|
|
||||||
<p>Every symbol used (except “<code>_</code>”) must be explicitly declared using</p>
|
|
||||||
|
|
||||||
<pre><code>#define sym_SYMBOL(sym, _SYMBOL) sym
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Example:</p>
|
|
||||||
|
|
||||||
<pre><code>#define sym_1(sym, _1) sym
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h5>Tape</h5>
|
|
||||||
|
|
||||||
<p>The initial content of the tape must be defined in the tape header using a triple like:</p>
|
|
||||||
|
|
||||||
<pre><code>#define tape ((((,),...l2), l1), c, (r1, (r2..., (,))))
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>l1</code>, <code>l2</code>, … are the symbols to the left</li>
|
|
||||||
<li><code>c</code> is the symbol at the current position</li>
|
|
||||||
<li><code>r1</code>, <code>r2</code>, … are the symbols to the right</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The empty pairs “<code>(,)</code>” represent the continuations of the tape, filled with underscore symbols (“<code>_</code>”). They are expanded on demand.</p>
|
|
||||||
|
|
||||||
<h5>State Machine</h5>
|
|
||||||
|
|
||||||
<p>All transitions are defined in the machine header using the syntax</p>
|
|
||||||
|
|
||||||
<pre><code>#define CURRENT_SCANNED (WRITE, MOVEMENT, NEXT)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>where</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><code>CURRENT</code> is the current state</li>
|
|
||||||
<li><code>SCANNED</code> is the symbol at the current position</li>
|
|
||||||
<li>the whitespace before the parentheses is significant</li>
|
|
||||||
<li><code>WRITE</code> is the symbol to be written to the tape</li>
|
|
||||||
<li><code>MOVEMENT</code> is “<code>L</code>” for left, “<code>R</code>” for right, or nothing</li>
|
|
||||||
<li><code>NEXT</code> is the next state</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>There must be a state “<code>A</code>” defined, which becomes the initial state of the machine.</p>
|
|
||||||
|
|
||||||
<p>To halt the machine, use the keyword “<code>break</code>” as in</p>
|
|
||||||
|
|
||||||
<pre><code>#define A_1 (2, break)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,805 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Best Documented</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Best Documented</h1>
|
|
||||||
|
|
||||||
<p>Jens Schweikhardt<br>
|
|
||||||
<a href="http://www.schweikhardt.net">http://www.schweikhardt.net</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
./prog n
|
|
||||||
|
|
||||||
where n is a base 16 number of any size
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog 19
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>This code is clean. When you compile with all warnings enabled,
|
|
||||||
such as with clang:</p>
|
|
||||||
|
|
||||||
<p> cc -Weverything -pedantic -std=c11 -Dtyp=uint64_t -O3 prog.c -o prog</p>
|
|
||||||
|
|
||||||
<p>The code compiles without warnings on the systems that we tested!</p>
|
|
||||||
|
|
||||||
<p>Even more, the code was 100% clean when we ran it against various
|
|
||||||
static source checkers.</p>
|
|
||||||
|
|
||||||
<p>This tool references a problem that David I. Bell once described
|
|
||||||
as having one of the largest “yummo quotients” in number theory:</p>
|
|
||||||
|
|
||||||
<pre><code> complexity of the solution
|
|
||||||
yummo quotient = -----------------------------------
|
|
||||||
complexity of the problem statement
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Erdős privately told one of the IOCCC judges:</p>
|
|
||||||
|
|
||||||
<p>“Solving the <a href="https://en.wikipedia.org/wiki/Generalized_Riemann_hypothesis#Extended_Riemann_hypothesis_.28ERH.29">Generalized Riemann hypothesis</a>
|
|
||||||
would be a good warmup exercise for someone to get ready
|
|
||||||
to begin to work on the <a href="https://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a>.”</p>
|
|
||||||
|
|
||||||
<p>You may explore this famous conjecture using this entry:</p>
|
|
||||||
|
|
||||||
<pre><code>./prog 2410
|
|
||||||
./prog abfff
|
|
||||||
./prog 27f8cebf
|
|
||||||
./prog 246f8fddf
|
|
||||||
./prog 2e95ab51ffea9de
|
|
||||||
./prog e6a5c22fd7bde9f
|
|
||||||
./prog 1b7dd73a937485bf
|
|
||||||
./prog 7d3237680d190a77e53751b
|
|
||||||
./prog 302ab3d052fb87c06228d249581be0e4
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>When you first look at the source, the code looks fairly straightforward.
|
|
||||||
But look again. Like the Collatz conjecture, simplicity is deceptive!
|
|
||||||
Oh, and the variable names? They are not simple single letter variables,
|
|
||||||
they are names of various <a href="https://en.wikipedia.org/wiki/Proteinogenic_amino_acid">Proteinogenic amino
|
|
||||||
acid</a>:
|
|
||||||
which is yet another simple building block that can be used to
|
|
||||||
build some very complex structures. :-)</p>
|
|
||||||
|
|
||||||
<p>p.s. We appreciated that apart from a few powers of 2, the source
|
|
||||||
code is magic number free.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>The TL;DR version</h2>
|
|
||||||
|
|
||||||
<p>This is the cleanest program ever submitted. If for some input it enters
|
|
||||||
a non-terminating loop or runs out of memory you will be insta-famous.
|
|
||||||
It’s a bit like a lottery without the need to buy a ticket and you can
|
|
||||||
play as often as you like. One notable historic person has even offered
|
|
||||||
some prize money.</p>
|
|
||||||
|
|
||||||
<p>The program illustrates the bloat caused by adherence to too many rules,
|
|
||||||
each of which may sound sane in isolation, but in their entirety lead to
|
|
||||||
an obfuscated, hard to read and understand monster.</p>
|
|
||||||
|
|
||||||
<h2>What this program does.</h2>
|
|
||||||
|
|
||||||
<p>The program tests whether a given natural number satisfies the
|
|
||||||
<a href="https://en.wikipedia.org/wiki/Collatz_conjecture">Collatz Conjecture</a>:</p>
|
|
||||||
|
|
||||||
<p>Take any natural number <em>n</em>. If <em>n</em> is even, divide it by 2 to get <em>n</em>/2.
|
|
||||||
If <em>n</em> is odd, multiply it by 3 and add 1 to obtain 3<em>n</em> + 1.
|
|
||||||
Repeat the process indefinitely.
|
|
||||||
The conjecture is that no matter what number you start with,
|
|
||||||
you eventually reach 1.</p>
|
|
||||||
|
|
||||||
<p>Paul Erdős said about the Collatz conjecture:
|
|
||||||
“Mathematics may not be ready for such problems.”
|
|
||||||
He also offered $500 for its solution.</p>
|
|
||||||
|
|
||||||
<p>For example, the sequence of numbers for <em>n</em> = 6 is</p>
|
|
||||||
|
|
||||||
<blockquote><p> 6, 3, 10, 5, 16, 8, 4, 2, 1.</p></blockquote>
|
|
||||||
|
|
||||||
<p>Continuing past one leads to the <em>cycle</em> 1, 4, 2, 1, 4, 2, 1, …
|
|
||||||
Interesting factoid: if you allow <em>negative</em> start values, there are
|
|
||||||
a few more cycles, each of different length:</p>
|
|
||||||
|
|
||||||
<blockquote><p> −1, −2, −1</p>
|
|
||||||
|
|
||||||
<p> −5, −14, −7, −20, −10, −5</p>
|
|
||||||
|
|
||||||
<p> −17, −50, −25, −74, −37, −110, −55, −164, −82, −41, −122, −61, −182, −91, −272, −136, −68, −34, −17</p></blockquote>
|
|
||||||
|
|
||||||
<p>The program computes the sequence for a given positive natural number
|
|
||||||
and stops at 1. The number <em>n</em> is specified in hexadecimal (without 0x
|
|
||||||
prefix) as the first argument. The program prints the given number in
|
|
||||||
zero-padded hex and each iteration along with a line count in decimal.
|
|
||||||
The example above looks like this (compiled with 64 bit word size):</p>
|
|
||||||
|
|
||||||
<pre><code>$ ./prog 6
|
|
||||||
0000000000000006
|
|
||||||
0000000000000003 1
|
|
||||||
000000000000000A 2
|
|
||||||
0000000000000005 3
|
|
||||||
0000000000000010 4
|
|
||||||
0000000000000008 5
|
|
||||||
0000000000000004 6
|
|
||||||
0000000000000002 7
|
|
||||||
0000000000000001 8
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The size of <em>n</em> is only limited by the argument size limit of your
|
|
||||||
shell/OS (the program implements arbitrary size bignums).
|
|
||||||
To query this on your POSIX system, run</p>
|
|
||||||
|
|
||||||
<pre><code>$ getconf ARG_MAX
|
|
||||||
262144
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>which reports the limit in bytes, here 256KB. This allows to test
|
|
||||||
whether a <a href="https://en.wikipedia.org/wiki/Googol">Googol</a>, which is
|
|
||||||
10<sup>100</sup>, satisfies the conjecture. But what is a googol in hex?
|
|
||||||
Fear not,
|
|
||||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html">bc(1)</a>
|
|
||||||
to the rescue:</p>
|
|
||||||
|
|
||||||
<pre><code>$ printf 'obase=16;10^100\n' | bc
|
|
||||||
1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F1000000000\
|
|
||||||
0000000000000000
|
|
||||||
$ ./prog 1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F10000000000000000000000000 \
|
|
||||||
| less
|
|
||||||
[...]
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Observe how the first 100 iterations melt the zeros to the right. Can you explain
|
|
||||||
why?</p>
|
|
||||||
|
|
||||||
<p>For a given <em>n</em> the program behavior is one of the following 3:</p>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li>The sequence stops at 1. No fame. No money. Thanks for playing. Computational
|
|
||||||
mathematicians have tested all <em>n</em> < 4FFDD776055A0000 (~10<sup>18</sup>)
|
|
||||||
so don’t try anything less than that.</li>
|
|
||||||
<li>The chosen <em>n</em> leads to a sequence with ever bigger numbers,
|
|
||||||
so that eventually the bignum cannot be stored in memory. If this happens,
|
|
||||||
the program outputs <code>laugh</code> (more likely) or <code>throw up</code> (less likely) and
|
|
||||||
stops. You <em>might</em> have found
|
|
||||||
a number for which the sequence <em>diverges</em>. If confirmed, this disproves the
|
|
||||||
conjecture.</li>
|
|
||||||
<li>The chosen <em>n</em> leads to a cycle not including 1 (i.e. runs forever,
|
|
||||||
repeating the same sequence over and over). You have disproved the
|
|
||||||
conjecture and should certainly submit a paper to the nearest
|
|
||||||
mathematical journal.</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Design objectives</h2>
|
|
||||||
|
|
||||||
<p>I gave myself the following objectives. Like in real world programming,
|
|
||||||
not all of them can be met 100%. Think of them as a multidimensional
|
|
||||||
continuum, where trade-offs have to be made.</p>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li>No arbitrary limits on the input number. 64 bits might be enough
|
|
||||||
for everybody, but is not enough for exploring new Collatz-territory.
|
|
||||||
Thus bignums are required.</li>
|
|
||||||
<li>Ultra-portable. Must run on C89 systems and self-adapt to C99 and C11
|
|
||||||
features like exact width types.</li>
|
|
||||||
<li>Super-efficient. Must be able to run with the widest type as the
|
|
||||||
base of the bignums. Make the user select the widest type supported
|
|
||||||
by the implementation and then crunch away. If a non-standard
|
|
||||||
128bit type is available, it should be usable.</li>
|
|
||||||
<li>Pentagon level lint cleanliness and MISRA compliance.</li>
|
|
||||||
<li>Easy to understand, self-documenting clear code. A joy for maintenance
|
|
||||||
programmers. The epitome of best practice demonstration for all
|
|
||||||
future textbooks on C.</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Program Obfuscation</h1>
|
|
||||||
|
|
||||||
<p>In the following I address all the <em>tests</em> as specified by your honors in the
|
|
||||||
<em>guidelines</em>.</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>look at the original source</li>
|
|
||||||
<li>convert ANSI tri-graphs to ASCII</li>
|
|
||||||
<li>C pre-process the source ignoring <code>#include</code> lines</li>
|
|
||||||
<li>C pre-process the source ignoring <code>#define</code> and <code>#include</code> lines</li>
|
|
||||||
<li>run it through a C beautifier</li>
|
|
||||||
<li>examine the algorithm</li>
|
|
||||||
<li>compile it (with flags to enable all warnings)</li>
|
|
||||||
<li>execute it</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Look at the original source</h2>
|
|
||||||
|
|
||||||
<p>Using one letter identifiers is quite old. I decided to use TLI (three
|
|
||||||
letter identifiers). Not the random kind, rather with a connection to
|
|
||||||
the meaning of life, the universe and the rest. Enter amino acids! Among
|
|
||||||
the myriad of possible amino acids there are 23 from which proteins are
|
|
||||||
built. In biochemistry, each is assigned a TLI (see <a href="https://en.wikipedia.org/wiki/Proteinogenic_amino_acid">Proteinogenic amino
|
|
||||||
acid</a>):</p>
|
|
||||||
|
|
||||||
<pre><code>ala Alanine
|
|
||||||
cys Cysteine
|
|
||||||
asp Aspartic acid
|
|
||||||
glu Glutamic acid
|
|
||||||
phe Phenylalanine
|
|
||||||
gly Glycine
|
|
||||||
his Histidine
|
|
||||||
ile Isoleucine
|
|
||||||
lys Lysine
|
|
||||||
leu Leucine
|
|
||||||
met Methionine
|
|
||||||
asn Asparagine
|
|
||||||
pyl Pyrrolysine
|
|
||||||
pro Proline
|
|
||||||
gln Glutamine
|
|
||||||
arg Arginine
|
|
||||||
ser Serine
|
|
||||||
thr Threonine
|
|
||||||
sec Selenocysteine
|
|
||||||
val Valine
|
|
||||||
trp Tryptophan
|
|
||||||
tyr Tyrosine
|
|
||||||
asx Asparagine or Aspartic acid
|
|
||||||
glx Glutamic acid or Glutamine
|
|
||||||
xle Leucine or Isoleucine
|
|
||||||
unk Unknown
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>My own research results complete this list (not yet in Wikipedia due to
|
|
||||||
the rule “<a href="https://en.wikipedia.org/wiki/Wikipedia:No_original_research">No original
|
|
||||||
research</a>”):</p>
|
|
||||||
|
|
||||||
<pre><code>and Androgynine
|
|
||||||
xor Xenoricine
|
|
||||||
not Notanamine
|
|
||||||
tla Triletramine
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Interestingly, the TLI are the perfect mnemonics for C language source.
|
|
||||||
For example, <code>met</code> is “Main’s Exit Type” (<code>int</code>), <code>ala</code> is “A Large
|
|
||||||
Algebraic” (bignum), <code>ile</code> an “Incremented Local Entity” (index
|
|
||||||
counter), <code>gly</code> means “Grow Larger memorY”, <code>gln</code> is “Grown Larger Now”
|
|
||||||
(after realloc), <code>not</code> is a “Not Overflowing Type” (recursive!), <code>unk</code>
|
|
||||||
is the “UNit (Known as 1)”, <code>trp</code> is the “Tabula Rasa Product” (zero),
|
|
||||||
<code>phe</code> is “Print HEx” and so on.</p>
|
|
||||||
|
|
||||||
<h2>Convert ANSI tri-graphs to ASCII</h2>
|
|
||||||
|
|
||||||
<p>Huh??!</p>
|
|
||||||
|
|
||||||
<h2>C pre-process the source ignoring ‘#include’ lines</h2>
|
|
||||||
|
|
||||||
<p>Wow, an identity operation (except for the <code><stdint.h></code> and <code>EOF + __STDC__</code>
|
|
||||||
trivialities). Did you gain any insight through this?</p>
|
|
||||||
|
|
||||||
<h2>C pre-process the source ignoring ‘#define’ and ‘#include’ lines</h2>
|
|
||||||
|
|
||||||
<p><code>#define</code>? Which <code>#define</code> directives? How many 4K source files do you
|
|
||||||
see that neither use a single <code>#define</code> directive <em>nor</em> abuse the build
|
|
||||||
file? Even though the “no <code>#define</code>” rule I submitted myself to made it
|
|
||||||
hard, I could use <code>__LINE__</code> and stdio macros <code>EOF</code>, <code>L_tmpnam</code>,
|
|
||||||
<code>BUFSIZ</code>, <code>FILENAME_MAX</code>, <code>TMP_MAX</code> to obfuscate at least something.</p>
|
|
||||||
|
|
||||||
<h2>Run it through a C beautifier</h2>
|
|
||||||
|
|
||||||
<p>Another identity operation. I’ve done it for you already. Use this
|
|
||||||
<code>.indent.pro</code> with FreeBSD indent:</p>
|
|
||||||
|
|
||||||
<pre><code>$ cat .indent.pro
|
|
||||||
-bad /* blank line after decls */
|
|
||||||
-bap /* blank line after functions */
|
|
||||||
-br /* braces on if line */
|
|
||||||
-i8 /* indent */
|
|
||||||
-l999 /* line length */
|
|
||||||
-npcs /* no space after function call names */
|
|
||||||
-npsl /* don't break procedure type */
|
|
||||||
-ut /* use tabs */
|
|
||||||
-ce /* cuddle else */
|
|
||||||
-nip /* no parameter indentation */
|
|
||||||
-di1 /* declaration indent */
|
|
||||||
-Tand
|
|
||||||
-Tmet
|
|
||||||
-Tthr
|
|
||||||
-Tpro
|
|
||||||
-Tser
|
|
||||||
-Tala
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>It looks like a perfect program should:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> two and a half <code>#includes</code> of unsuspicious standard headers</li>
|
|
||||||
<li> followed by self protection against goofy implementations</li>
|
|
||||||
<li> followed by a handful of <code>typedef</code>s</li>
|
|
||||||
<li> and a pair of file scope objects by necessity</li>
|
|
||||||
<li> prototypes! With parameter names! <code>static</code> for internal linkage even! This <strong>must</strong> be a first in IOCCC history.</li>
|
|
||||||
<li> function definitions, <code>main</code> last</li>
|
|
||||||
<li> everything is fully const-poisoned: automatics, statics, arguments, even <code>main</code></li>
|
|
||||||
<li> everything is fully curly braced, even single statements</li>
|
|
||||||
<li> plenty of meaningful TLC (Three Letter Comments)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The program contains not a single <em>magic number</em> (only 0 and powers of
|
|
||||||
2, each power from 1 to 512) which are obvious to competent software
|
|
||||||
engineers). How many programs have <em>that</em> property? The check for
|
|
||||||
<code>__STDC_VERSION__</code> was a bit tough to arrive at, since 199901L has too
|
|
||||||
many bits set. But I realized that I only needed a number larger than
|
|
||||||
199409 and less than 199901. 199680 has only 4 bits set and writing it
|
|
||||||
as (256 + 128 + 4 + 2) * 512 minimizes the character count. That’s what
|
|
||||||
judges get when they don’t like programs that are longer than they need
|
|
||||||
to be.</p>
|
|
||||||
|
|
||||||
<h2>Examine the algorithm</h2>
|
|
||||||
|
|
||||||
<p>Spoilers ahead. Duh!</p>
|
|
||||||
|
|
||||||
<p>Pseudocode, with comments matching those in the C source:</p>
|
|
||||||
|
|
||||||
<pre><code>/* run */
|
|
||||||
if (non-NULL and nonempty argv[1]) {
|
|
||||||
n = convert(argv[1])
|
|
||||||
print n /* 2hx */
|
|
||||||
while (n != 1) { /* one */
|
|
||||||
if (n is odd) { /* odd */
|
|
||||||
m = deep copy of n /* cpy */
|
|
||||||
n <<= 1 /* shl */
|
|
||||||
n += m /* add */
|
|
||||||
increment n /* inc */
|
|
||||||
} else { /* eve */
|
|
||||||
n >>= 1 /* shr */
|
|
||||||
}
|
|
||||||
print n /* 2hx */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Bignums are represented as the two member structs</p>
|
|
||||||
|
|
||||||
<pre><code>typedef struct {
|
|
||||||
size_t places; /* number of places in base 2<sup>8*sizeof(type)</sup> */
|
|
||||||
type *number; /* dynamically allocated memory for number */
|
|
||||||
} bignum
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Compile it (with flags to enable all warnings)</h2>
|
|
||||||
|
|
||||||
<p>Here’s where the program shines brighter than a <a href="https://en.wikipedia.org/wiki/Gamma-ray_burst">gamma-ray
|
|
||||||
burst</a>!</p>
|
|
||||||
|
|
||||||
<p>I challenge you to throw all kinds of compilers, lints, checkers and
|
|
||||||
analyzers at my program and make it find the slightest of issues.</p>
|
|
||||||
|
|
||||||
<p>Is <code>clang -Wall -Wextra -Weverything -Dtyp=uint32_t prog.c</code> all you can
|
|
||||||
do? Clang has implemented a new warning? Bring it on!</p>
|
|
||||||
|
|
||||||
<h2>Execute it</h2>
|
|
||||||
|
|
||||||
<p>May you win the jackpot!</p>
|
|
||||||
|
|
||||||
<p>For least surprising results, the execution character set should be
|
|
||||||
ASCII. The program computes four bits from every character in <code>argv[1]</code> and
|
|
||||||
interprets them as a hex digit. On ASCII the characters a-f, A-F and 0-9
|
|
||||||
are converted as expected.</p>
|
|
||||||
|
|
||||||
<p>This means however, that the program accepts <strong>any string</strong>, turns it
|
|
||||||
into a starting number (which is output as the first line), and starts
|
|
||||||
crunching. Nothing stops you from executing</p>
|
|
||||||
|
|
||||||
<pre><code>$ ./prog "$(cat prog.c)" # Kind of quine?
|
|
||||||
$ ./prog "$(cat rules guidelines)" # A jackpot? Maybe next year...
|
|
||||||
$ ./prog "$(cat /bin/ls)" # Number cut short at first NUL byte.
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>In a certain way, the program is character set and encoding agnostic.</p>
|
|
||||||
|
|
||||||
<h2>Assumptions made</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The <code>EOF</code> macro from <code><stdio.h></code> must expand to negative one since it is used
|
|
||||||
to decrement a pointer and do some other math.
|
|
||||||
None of the tools catches this one. The program self-protects against unusual
|
|
||||||
systems with <code>#if EOF + __STDC__</code> followed by <code>#error goofy!</code>. In the rare event
|
|
||||||
your system is goofy, replace all <code>EOF</code> tokens with <code>(-1)</code> and remove the
|
|
||||||
<code>#error</code> directive.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>While the program works best when bytes/characters are octets and the
|
|
||||||
number of bits in a type is <code>sizeof(typ) << 3</code>, it will work correctly
|
|
||||||
on 24bit or 36bit systems with 9 bits/byte, or systems where
|
|
||||||
<code>sizeof(typ)</code> is 1 even for <code>int</code> and so on. On such systems, it will only
|
|
||||||
use 8 * <code>sizeof(typ)</code> bits per place. It does not work when <code>CHAR_BIT <= 7</code>.</p>
|
|
||||||
|
|
||||||
<h2>Results of various checkers</h2>
|
|
||||||
|
|
||||||
<h3>cppcheck</h3>
|
|
||||||
|
|
||||||
<p>The open source static checker <a href="http://cppcheck.sourceforge.net/">cppcheck</a>
|
|
||||||
checks various problems with respect to style, performance, portability
|
|
||||||
and general fishiness. To enable all checks, run</p>
|
|
||||||
|
|
||||||
<pre><code>$ cppcheck --enable=all --force -I/usr/include -Dtyp=uint32_t prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>No issues found.</p>
|
|
||||||
|
|
||||||
<h3>flawfinder</h3>
|
|
||||||
|
|
||||||
<p>The open source static checker <a href="http://www.dwheeler.com/flawfinder/">flawfinder</a>
|
|
||||||
checks various problems with respect to security like buffer overflows,
|
|
||||||
function arguments to known troublemaker functions and more. It doesn’t need to
|
|
||||||
pre-process code, so can be run without the <code>typ</code> macro being defined:</p>
|
|
||||||
|
|
||||||
<pre><code>$ flawfinder prog.c
|
|
||||||
Flawfinder version 1.31, (C) 2001-2014 David A. Wheeler.
|
|
||||||
Number of rules (primarily dangerous function names) in C/C++ ruleset: 169
|
|
||||||
Examining prog.c
|
|
||||||
FINAL RESULTS:
|
|
||||||
ANALYSIS SUMMARY:
|
|
||||||
No hits found.
|
|
||||||
$
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>valgrind</h3>
|
|
||||||
|
|
||||||
<p>The open source dynamic checker <a href="http://valgrind.org/">valgrind</a>
|
|
||||||
runs an executable and verifies all memory accesses and (de)allocations for
|
|
||||||
proper bounds and memory leaks.
|
|
||||||
Since the program frees all memory in all possible execution paths, even when
|
|
||||||
it must bail out,
|
|
||||||
valgrind should be happy. An early version of my program however reported this:</p>
|
|
||||||
|
|
||||||
<pre><code>$ valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
|
||||||
[...]
|
|
||||||
==14615== HEAP SUMMARY:
|
|
||||||
==14615== in use at exit: 4,096 bytes in 1 blocks
|
|
||||||
==14615== total heap usage: 4 allocs, 3 frees, 4,108 bytes allocated
|
|
||||||
==14615==
|
|
||||||
==14615== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1
|
|
||||||
==14615== at 0x4C236C0: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
|
|
||||||
==14615== by 0x4F62175: ??? (in /lib/libc.so.7)
|
|
||||||
==14615== by 0x4F62073: ??? (in /lib/libc.so.7)
|
|
||||||
==14615== by 0x4F514EE: ??? (in /lib/libc.so.7)
|
|
||||||
==14615== by 0x4F51265: vfprintf_l (in /lib/libc.so.7)
|
|
||||||
==14615== by 0x4F3E001: printf (in /lib/libc.so.7)
|
|
||||||
==14615== by 0x40101E: phe (in ./prog)
|
|
||||||
==14615== by 0x400A9F: main (in ./prog)
|
|
||||||
==14615==
|
|
||||||
==14615== LEAK SUMMARY:
|
|
||||||
==14615== definitely lost: 0 bytes in 0 blocks
|
|
||||||
==14615== indirectly lost: 0 bytes in 0 blocks
|
|
||||||
==14615== possibly lost: 0 bytes in 0 blocks
|
|
||||||
==14615== still reachable: 4,096 bytes in 1 blocks
|
|
||||||
==14615== suppressed: 0 bytes in 0 blocks
|
|
||||||
==14615==
|
|
||||||
==14615== For counts of detected and suppressed errors, rerun with: -v
|
|
||||||
==14615== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>From which I concluded that <code>printf</code> allocated a single 4K block for
|
|
||||||
which no matching free existed. But how to free memory allocated deep
|
|
||||||
down in the guts of the Standard I/O library? After some serious head
|
|
||||||
scratching it hit me. The only chance I have is telling the system I no
|
|
||||||
longer want to do I/O, maybe then it would free that buffer. A reading
|
|
||||||
of C99 7.19.5.1, “The fclose function”, was encouraging:</p>
|
|
||||||
|
|
||||||
<blockquote><p> Whether or not the call succeeds, the stream is disassociated from the file
|
|
||||||
and any buffer set by the <code>setbuf</code> or <code>setvbuf</code> function is disassociated from the stream
|
|
||||||
(and deallocated if it was automatically allocated).</p></blockquote>
|
|
||||||
|
|
||||||
<p>So I <code>fclose(stdout)</code> before returning and now:</p>
|
|
||||||
|
|
||||||
<pre><code>$ valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
|
||||||
==14571== Memcheck, a memory error detector
|
|
||||||
==14571== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
|
|
||||||
==14571== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
|
|
||||||
==14571== Command: ./prog 6
|
|
||||||
==14571==
|
|
||||||
0000000000000006
|
|
||||||
0000000000000003 1
|
|
||||||
000000000000000A 2
|
|
||||||
0000000000000005 3
|
|
||||||
0000000000000010 4
|
|
||||||
0000000000000008 5
|
|
||||||
0000000000000004 6
|
|
||||||
0000000000000002 7
|
|
||||||
0000000000000001 8
|
|
||||||
==14571==
|
|
||||||
==14571== HEAP SUMMARY:
|
|
||||||
==14571== in use at exit: 0 bytes in 0 blocks
|
|
||||||
==14571== total heap usage: 4 allocs, 4 frees, 4,120 bytes allocated
|
|
||||||
==14571==
|
|
||||||
==14571== All heap blocks were freed -- no leaks are possible
|
|
||||||
==14571==
|
|
||||||
==14571== For counts of detected and suppressed errors, rerun with: -v
|
|
||||||
==14571== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>A squeaky clean valgrind result!</p>
|
|
||||||
|
|
||||||
<h3>FlexeLint</h3>
|
|
||||||
|
|
||||||
<p>FlexeLint is a commercial lint tool by <a href="http://www.gimpel.com/html/index.htm">Gimpel
|
|
||||||
Software</a>. It supports nearly a
|
|
||||||
thousand checks, broadly categorized into 4 levels,</p>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<li> Syntax errors only (messages 1 to 399)</li>
|
|
||||||
<li> Warnings (messages 400 to 699)</li>
|
|
||||||
<li> Informational messages (700 to 899)</li>
|
|
||||||
<li> Elective notes (900 to 1000 and > 9000)</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<p>There is an <a href="http://www.gimpel-online.com/OnlineTesting.html">on-line
|
|
||||||
demonstrator</a> you can
|
|
||||||
use for checking your C programs and I highly recommend trying it. For a start,
|
|
||||||
paste the well know first program in the form and press “Analyze Code”. Note
|
|
||||||
the FlexeLint configuration options in comments (no space between <code>/*</code> and <code>lint</code>).</p>
|
|
||||||
|
|
||||||
<pre><code>/*lint -w4 turn on everything */
|
|
||||||
/*lint +esym(534,*) no demonstrator defaults */
|
|
||||||
/*lint -e966 indirectly included header file not used */
|
|
||||||
/*lint -esym(9058,_*) tag not used outside typedef */
|
|
||||||
/*lint -misra(2) */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
printf("hello, world\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Possible checks include those for MISRA 2004 compliance verification.
|
|
||||||
The <a href="https://en.wikipedia.org/wiki/Motor_Industry_Software_Reliability_Association">Motor Industry Software Reliability
|
|
||||||
Association</a>
|
|
||||||
has produced a <a href="http://doc.hcc-embedded.com/display/CODING/MISRA+Rules">list of 121 required and 20 advisory
|
|
||||||
rules</a> for C
|
|
||||||
programming. I am proud to report that my program fulfills <em>almost all</em>
|
|
||||||
rules. To assess the few exceptions, one has to understand that MISRA
|
|
||||||
rules are geared towards embedded systems used in the automotive
|
|
||||||
industry. That’s why features like <code>malloc</code> and <code>printf</code> are right out.
|
|
||||||
But that’s too restrictive for an IOCCC hosted application, so I ignored
|
|
||||||
these:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>17.1 Pointer arithmetic shall only be applied to pointers that address an array or array element.</li>
|
|
||||||
<li>17.4 Array indexing shall be the only allowed form of pointer arithmetic.</li>
|
|
||||||
<li>20.4 Dynamic heap memory allocation shall not be used.</li>
|
|
||||||
<li>20.9 The input/output library stdio.h shall not be used in production code.</li>
|
|
||||||
<li>20.11 The functions abort, exit, getenv, and system from the library stdlib.h shall not be used.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>I started out with enabling <em>all</em> messages using FlexeLint’s <code>-w4</code>
|
|
||||||
option and disabling all noise from system headers. Then I dealt with
|
|
||||||
the remaining messages by addressing them or suppressing them in such a way
|
|
||||||
that the set of suppressions was minimal. At the end of the day, this is
|
|
||||||
what remained:</p>
|
|
||||||
|
|
||||||
<pre><code>// === Tested with FlexeLint 9.00L on FreeBSD 11 ===
|
|
||||||
// Compiler:
|
|
||||||
// "4.2.1 Compatible FreeBSD Clang 3.6.1 (tags/RELEASE_361/final 237755)"
|
|
||||||
|
|
||||||
-w4 // Enable maximum pickiness
|
|
||||||
-passes(6) // Recommended in FlexeLint manual for torture testing
|
|
||||||
+fsc // Make string literals have type const char*
|
|
||||||
+fnr // ptr-returning functions may return NULL
|
|
||||||
-strong(AJX,and,pro,ser,ala) // strong types
|
|
||||||
-strong(AcJcm,thr) // thr is strong, but most arithmetic is okay
|
|
||||||
-strong(AarJemorX,met) // met is strong, but some use is okay
|
|
||||||
+libclass(angle) // All <headers> are system headers
|
|
||||||
-wlib(1) // Only errors for system headers
|
|
||||||
-i/usr/include // System headers
|
|
||||||
-i/usr/local/lib/supp/ansi // Comes with FlexeLint
|
|
||||||
-d__GNUC__=4 // Pretend...
|
|
||||||
-d__GNUC_MINOR__=2 // I'm...
|
|
||||||
-d__GNUC_PATCHLEVEL__=1 // someone else.
|
|
||||||
-d__builtin_va_list=char* // Fake this compiler extension
|
|
||||||
-d__inline= // Delete this compiler extension
|
|
||||||
-d__attribute__(x)= // Delete this compiler extension
|
|
||||||
+e900 // Announce number of messages produced
|
|
||||||
|
|
||||||
// MISRA 2004 checking
|
|
||||||
|
|
||||||
/usr/local/lib/supp/lnt/au-misra2.lnt // Enable all MISRA checking
|
|
||||||
-elib(960) // Don't check FreeBSD system headers for required rules
|
|
||||||
-elib(961) // Don't check FreeBSD system headers for advisory rules
|
|
||||||
-e829 // stdio.h used
|
|
||||||
-e522 // MISRA 14.2 Highest operation, lacks side-effects
|
|
||||||
-esym(960,17.4) // pointer arithmetic other than array indexing used
|
|
||||||
-e971 // char without signed/unsigned
|
|
||||||
-e974 // stack usage report
|
|
||||||
// Use verboten functions, Req. Rules 20.4 malloc() et al., 20.11, exit()
|
|
||||||
-esym(586,malloc,realloc,calloc,free,exit)
|
|
||||||
|
|
||||||
-e911 // implicit promotion of smaller than int to int
|
|
||||||
-e921 // cast from integral to integral
|
|
||||||
-e925 // cast from pointer to pointer
|
|
||||||
-e958 // padding required in struct
|
|
||||||
|
|
||||||
+e9??? // Enable all 9xxx informational messages, except:
|
|
||||||
-e9079 // conversion from pointer to void to pointer to other type
|
|
||||||
-e9087 // cast performed between a pointer to object type and a
|
|
||||||
// pointer to a different object type
|
|
||||||
-e9141 // global declaration of symbol
|
|
||||||
|
|
||||||
// Messages due to code in FreeBSD headers.
|
|
||||||
//
|
|
||||||
-dlint // The "lint" macro is tested in x86/_types.h
|
|
||||||
-elib(537) // Repeated include file
|
|
||||||
-e793 // external identifiers > 6 chars
|
|
||||||
-e935 // (unsigned) int within struct (actually the size_t)
|
|
||||||
-estring(960,_*) // Could be defined at block scope
|
|
||||||
-e964 // Header file not directly used
|
|
||||||
-e966 // Indirectly included header file not used
|
|
||||||
-elib(970) // int outside typedef
|
|
||||||
-esym(9003,_*) // could be defined at block scope
|
|
||||||
-elib(9047) // FILE pointer dereferenced
|
|
||||||
-esym(9058,__*) // tag not used outside typedef
|
|
||||||
-e9092 // NULL does not expand to a pointer (but plain 0)
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Compulsory obfuscations</h2>
|
|
||||||
|
|
||||||
<p>Which of the rules cause which obfuscation?</p>
|
|
||||||
|
|
||||||
<p>MISRA 6.1, “The plain char type shall be used only for the storage and
|
|
||||||
use of character values.” This forbids using character constants in
|
|
||||||
expressions other than assignments to <code>char</code> objects. A consequence is
|
|
||||||
that printing digits with <code>'0' + digit</code> is not allowed (even though
|
|
||||||
<code>'0'</code> is technically an <code>int</code>!) so I am forced to output hex digits with</p>
|
|
||||||
|
|
||||||
<pre><code>printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>because of the “no magic numbers other than powers of two” rule. How is this
|
|
||||||
an improvement over <code>printf("%c", '0' + tyr + 7 * (tyr / 10)</code>, MISRA?</p>
|
|
||||||
|
|
||||||
<p>MISRA 6.3 “typedefs that indicate size and signedness should be used in
|
|
||||||
place of the basic types.” Well, if you can’t infer the size and
|
|
||||||
signedness from <code>typedef int met</code>, you’re not a real C programmer.</p>
|
|
||||||
|
|
||||||
<p>MISRA 10.5, “If the bitwise operators <code>~</code> and <code><<</code> are applied to an
|
|
||||||
operand of underlying type <code>unsigned char</code> or <code>unsigned short</code>, the
|
|
||||||
result shall be immediately cast to the underlying type of the operand.”
|
|
||||||
Because the program must work for any unsigned type chosen for the <code>typ</code>
|
|
||||||
macro, including the narrow types enumerated in the rule, a lot of
|
|
||||||
redundant casting ensues. It gets worse with the next rule…</p>
|
|
||||||
|
|
||||||
<p>MISRA 12.1, “Limited dependence should be placed on the C operator
|
|
||||||
precedence rules in expressions.” This requires parentheses for almost
|
|
||||||
all expressions involving more than one operator, especially those for which
|
|
||||||
a cast is required, leading to hard to understand expressions such as</p>
|
|
||||||
|
|
||||||
<pre><code>const ser glx = (ser)((asx > (ser)64u) ? (ser)((ser)asx + (ser)8u + (ser)1u) : (ser)asx);
|
|
||||||
not.not[leu] = (and)((and)not.not[leu] | (and)(((and)glx % (and)16u) << (and)lys));
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>MISRA 14.7, “A function shall have a single point of exit at the end of
|
|
||||||
the function.” Sigh. Since I must use eloquent prototypes (8.1, 16.3,
|
|
||||||
16.4) and static functions (8.10, 8.11), I can only use a few functions.
|
|
||||||
Everything usually written with an early <code>return</code> now cause <em>another
|
|
||||||
useless indent level</em>. The first three <code>if</code> statements in <code>main</code> cause a
|
|
||||||
silly 24 character indent. The maximum indent is forced to 8, which is way
|
|
||||||
too high for a sane function.</p>
|
|
||||||
|
|
||||||
<p>MISRA 16.10, “If a function returns error information, then that error
|
|
||||||
information shall be tested.” A cast to void would draw a lint warning, so
|
|
||||||
I use the <code>printf</code> result in expressions,</p>
|
|
||||||
|
|
||||||
<pre><code>lys -= 4 * printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
|
|
||||||
val += printf("\n") / ((__LINE__ * L_tmpnam) + TMP_MAX);
|
|
||||||
val -= (printf(" %d\n", val) > BUFSIZ) ? FILENAME_MAX : EOF;
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>which are, in the absence of errors, equivalent to</p>
|
|
||||||
|
|
||||||
<pre><code>lys -= 4;
|
|
||||||
/*nop*/
|
|
||||||
++val;
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>MISRA 13.1, “Assignment operators shall not be used in expressions that
|
|
||||||
yield a Boolean value.” Forbids the idiomatic <code>if ((p = malloc(n)) ==
|
|
||||||
NULL)</code> and requires separate statements, in other words, bloat.</p>
|
|
||||||
|
|
||||||
<p>MISRA 16.7, “A pointer parameter in a function prototype should be
|
|
||||||
declared as pointer to const if the pointer is not used to modify the
|
|
||||||
addressed object.” in conjunction with lint’s “Note 952: Parameter could
|
|
||||||
be declared const” causes const-poisoning for all functions,</p>
|
|
||||||
|
|
||||||
<pre><code>static void phe(const ala not);
|
|
||||||
static void gly(ala *const not, const and his);
|
|
||||||
met main(met val, const pro *const his[]);
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>and quite a number of automatic variables.</p>
|
|
||||||
|
|
||||||
<h3>Why the “laugh” and “throw up” messages?</h3>
|
|
||||||
|
|
||||||
<p>The guidelines state “We like programs that: make us laugh and/or throw
|
|
||||||
up :-) (humor really helps!)”</p>
|
|
||||||
|
|
||||||
<h3>If you have a 128 bit type</h3>
|
|
||||||
|
|
||||||
<p>If your compiler supports a 128 bit wide type (e.g. clang, gcc) then
|
|
||||||
you can use it via the <code>typ</code> macro:</p>
|
|
||||||
|
|
||||||
<pre><code>clang -Dtyp=__uint128_t -o prog prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Indeed, the program can use (and lints clean for) all of</p>
|
|
||||||
|
|
||||||
<pre><code>clang -Dtyp=uint8_t -o prog8 prog.c
|
|
||||||
clang -Dtyp=uint16_t -o prog16 prog.c
|
|
||||||
clang -Dtyp=uint32_t -o prog32 prog.c
|
|
||||||
clang -Dtyp=uint64_t -o prog64 prog.c
|
|
||||||
clang -std=c89 -Dtyp="unsigned long" -o prog89 prog.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>This works because the program has no need for corresponding <code>SCN</code> or
|
|
||||||
<code>PRI</code> macros to do the scanning and printing of variables of these
|
|
||||||
types. With a 128 bit type the program can represent numbers up to
|
|
||||||
340282366920938463463374607431768211457 (3.4 * 10<sup>39</sup>) as a
|
|
||||||
single “place”, enough to explore yet untested numbers for the rest of
|
|
||||||
your life.</p>
|
|
||||||
|
|
||||||
<h3>How big a number can I test with 4 GB of RAM?</h3>
|
|
||||||
|
|
||||||
<p>The number of hex digits in the start number is limited by <code>ARG_MAX</code>,
|
|
||||||
probably minus some overhead for the environment variables (use
|
|
||||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html"><code>env</code>(1)</a>
|
|
||||||
to trim your environment). In bits this leaves you with 2<sup>4 *
|
|
||||||
ARG_MAX</sup>.</p>
|
|
||||||
|
|
||||||
<p>The algorithm requires two bignums in memory for addition.
|
|
||||||
If you hit a divergent number, this will cause out-of-memory (“laugh”)
|
|
||||||
somewhere near 2<sup>16,000,000,000</sup> (4GB/2 * 8bits/byte).
|
|
||||||
Sadly, I don’t have a test case :-)</p>
|
|
||||||
|
|
||||||
<p>How long would it take to overflow the <em>Not Overflowing Type</em>? Lets
|
|
||||||
assume we’re processing 2GB numbers. The program copies, shifts by one,
|
|
||||||
adds and increments 2GB long bit strings, each time completely thrashing
|
|
||||||
the data cache – at <em>all</em> levels. We have a fast machine that can do an
|
|
||||||
iteration in one second, on average. To make things easy, we round up
|
|
||||||
3<em>n</em> + 1 to 4<em>n</em>, and assume we never need to divide by two (which is
|
|
||||||
quite optimistic). Then each iteration shifts left by 2. This would take
|
|
||||||
8 billion seconds, or about 250 years. If you want to get famous, you
|
|
||||||
better <em>remove</em> some of the RAM, use an ancient box, or reduce available
|
|
||||||
memory resources with the ulimit(1) built-in of your shell.</p>
|
|
||||||
|
|
||||||
<p>For all intents and purposes, the <em>Not Overflowing Type</em> keeps the promise!</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most Pointed Reaction</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most Pointed Reaction</h1>
|
|
||||||
|
|
||||||
<p>Don Yang<br>
|
|
||||||
<a href="http://uguu.org/">http://uguu.org/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
echo Some text | ./prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>echo IOCCC 2015 | ./prog | tee output.c
|
|
||||||
make output
|
|
||||||
./output
|
|
||||||
|
|
||||||
echo IOCCC 2015 | ./prog_c11 | tee output.c
|
|
||||||
make output
|
|
||||||
./output
|
|
||||||
|
|
||||||
echo IOCCC 2015 | ./prog_c++98 | tee output.c
|
|
||||||
make output
|
|
||||||
./output
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Before analysing the code in detail we were able to guess two out of four tests
|
|
||||||
this entry uses to tell the 5 languages/flavors apart. Can you find all four?</p>
|
|
||||||
|
|
||||||
<p>The way the text is encoded in the output doesn’t cease to amaze. Can you tell
|
|
||||||
why an array of 512 elements is needed?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>Fuuko is a sea star generator. Feed her some input through stdin to
|
|
||||||
get lots of sea star patterns in stdout.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -O3 -std=c90 fuuko.c -lm -o fuuko_c90
|
|
||||||
echo IOCCC | ./fuuko_c90 > output_c90.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>If you compile with a C99 compiler instead of C90, the sea stars will
|
|
||||||
have eyes.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -O3 -std=c99 fuuko.c -lm -o fuuko_c99
|
|
||||||
echo IOCCC | ./fuuko_c99 > output_c99.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Don’t like sea stars? Use a C++98 compiler to get dango instead.</p>
|
|
||||||
|
|
||||||
<pre><code>g++ -O3 -std=c++98 fuuko.c -lm -o fuuko_cpp98
|
|
||||||
echo IOCCC | ./fuuko_cpp98 > output_cpp98.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Don’t like dango either? Use a C++11 compiler to get just circles (or
|
|
||||||
swiss cheese, if you prefer that).</p>
|
|
||||||
|
|
||||||
<pre><code>g++ -O3 -std=c++11 fuuko.c -lm -o fuuko_cpp11
|
|
||||||
echo IOCCC | ./fuuko_cpp11 > output_cpp11.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Don’t like any of these patterns? Use a C11 compiler and there will be
|
|
||||||
no extra patterns.</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -O3 -std=c11 fuuko.c -lm -o fuuko_c11
|
|
||||||
echo IOCCC | ./fuuko_c11 > output_c11.c
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Regardless of which of these C/C++ dialects you choose, the output
|
|
||||||
will all be valid C90 code that reproduces original input on stdout,
|
|
||||||
filled with pointer dereferences (C stars).</p>
|
|
||||||
|
|
||||||
<p>Next time people ask you for a few pointers on C, you can run their
|
|
||||||
question through Fuuko and give them pointers all day long.</p>
|
|
||||||
|
|
||||||
<h3>Compatibility</h3>
|
|
||||||
|
|
||||||
<p>Fuuko has been tested under these environments:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>gcc 4.9.3 on Cygwin</li>
|
|
||||||
<li>gcc 4.9.2 on Linux</li>
|
|
||||||
<li>gcc 4.8.4 on Linux</li>
|
|
||||||
<li>gcc 4.6.3 on Linux (doesn’t support C11 nor C++11)</li>
|
|
||||||
<li>gcc 4.3.5 on JS/Linux</li>
|
|
||||||
<li>clang 3.5.2 on Cygwin (doesn’t work with optimization enabled,
|
|
||||||
probably cygwin bug)</li>
|
|
||||||
<li>clang 3.5.0 on Linux</li>
|
|
||||||
<li>clang 3.4.1 on Linux</li>
|
|
||||||
<li>tcc 0.9.25 on JS/Linux (C99 only)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Features</h3>
|
|
||||||
|
|
||||||
<p>The most obscure parts are in detecting the subtle differences in
|
|
||||||
different dialects. The standard committees put a lot of effort into
|
|
||||||
avoiding “quiet changes”, but Fuuko is still able exploit a few of
|
|
||||||
those. It should be an interesting exercise for the reader to figure
|
|
||||||
how she did it.</p>
|
|
||||||
|
|
||||||
<p>Output patterns are usually random (except for C11). The built-in
|
|
||||||
random number generator is seeded using ASLR. On systems where ASLR
|
|
||||||
is not so random (such as cygwin), you can introduce randomness by
|
|
||||||
changing number of command line arguments to Fuuko.</p>
|
|
||||||
|
|
||||||
<p>Output is somewhat robust: corruption on most of the lines will
|
|
||||||
usually result in a compiler warning. This is because the output is
|
|
||||||
vastly redundant: For ~1K of input, expect output to be on the order
|
|
||||||
of ~1MB, and take ~500MB of RAM to compile.</p>
|
|
||||||
|
|
||||||
<p>CRC32 of source code is embedded in the source code itself.</p>
|
|
||||||
|
|
||||||
<p>Process of writing this program is included in spoiler.html</p>
|
|
||||||
|
|
||||||
<p>Code layout is inspired by Ibuki Fuuko, for her love of sea stars.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2016,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,154 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most cacophonic</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most cacophonic</h1>
|
|
||||||
|
|
||||||
<p>Anton Älgmyr<br>
|
|
||||||
Twitter: @aalgmyr</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
|
|
||||||
cat prog.c | ./prog # Printing garbage might break your font
|
|
||||||
./prog <file1> <file2> > out.raw
|
|
||||||
./prog -d 2 0 out.raw # Decode the first (0th) channel out of two
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>To try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog -h | ./prog -d 1 0
|
|
||||||
|
|
||||||
# Who needs cat?
|
|
||||||
./prog prog.c | ./prog -d 1 0
|
|
||||||
|
|
||||||
# Assuming ALSA
|
|
||||||
echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' |
|
|
||||||
./prog | aplay -c1 -fFLOAT_LE -r44100
|
|
||||||
|
|
||||||
# Assuming sox
|
|
||||||
echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog |
|
|
||||||
sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - -n spectrogram -d 10 -X 300
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Be warned, this is not your garden variety text-to-speech program! Earplugs are advised,
|
|
||||||
or at least a handy and well-tested volume knob.</p>
|
|
||||||
|
|
||||||
<p>Pixels are numbered, amplitudes are weighed, frequencies are divided,
|
|
||||||
and the message can be displayed in fiery letters, but don’t be alarmed.</p>
|
|
||||||
|
|
||||||
<p>How does decoding of the waveform work? Can you encode an arbitrary text in a sound sample?</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h1>What is this?</h1>
|
|
||||||
|
|
||||||
<p>To put it brief, this entry is akin to a sound based cat. It takes characters as input and outputs them into frequency space as audio. The entry also supports decoding the produced waveforms using the <code>-d</code> flag. Usage instructions is output if run with the <code>-h</code> flag, albeit not in an immediately legible format.</p>
|
|
||||||
|
|
||||||
<h2>Details</h2>
|
|
||||||
|
|
||||||
<p>In normal operation, the entry reads characters from one or more sources. If the <code>-h</code> flag is given, usage instructions is used as a source. Else if file paths are present as arguments those will be used. Else stdin is used.</p>
|
|
||||||
|
|
||||||
<p>If a character is part of the supported subset of ASCII <code>{10, 32-126}</code> then that character is output into frequency space of an audio signal (44.1 kHz single precision float, endianness should depend on system endianness) through stdout. Any other character will be interpreted and outputted as a space.</p>
|
|
||||||
|
|
||||||
<p>Characters are printed using a (slightly modified) pixel font based on <a href="https://github.com/hchargois/gohufont">gohufont</a>. Pixels are drawn using crosses in frequency space, achieved by simultaneous up and down chirps.</p>
|
|
||||||
|
|
||||||
<p>Each input source is designated its own channel in the output (one float per channel per time step in the output) so if you have a surround sound system you could listen to a cacophony of chirpy characters.</p>
|
|
||||||
|
|
||||||
<p>Interestingly, with training you might actually be able to tell characters just from hearing. But even without training you can easily read along with the printed characters and have the sound make sense with the look of the characters.</p>
|
|
||||||
|
|
||||||
<p>See image spoiler.png for an example spectrogram.</p>
|
|
||||||
|
|
||||||
<h2>Limitations</h2>
|
|
||||||
|
|
||||||
<p>There is no error checking done when opening files, so expect segfaults if you provide the wrong path to a file.</p>
|
|
||||||
|
|
||||||
<p>This program is bound to misbehave if int is less than 32 bits.</p>
|
|
||||||
|
|
||||||
<p>Flags will only be interpreted correctly if they are the first argument. Reading a file named <code>-d</code> or <code>-h</code> is fully possible if it is not the first file provided, even though I am not sure why you would want to do that.</p>
|
|
||||||
|
|
||||||
<p>Providing invalid/unexpected arguments to the decode flag will result in odd behavior. Some erroneous arguments cause segfaults (negative number of channels, channel id outside valid range). One argument in particular causes an infinite loop printing whitespace.</p>
|
|
||||||
|
|
||||||
<h1>Techniques</h1>
|
|
||||||
|
|
||||||
<h2>Obfuscation</h2>
|
|
||||||
|
|
||||||
<p>A lot of the obfuscations done came naturally from trying to appease the size tool. To name some:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>One character names</li>
|
|
||||||
<li>Merging of related (and not so related) arithmetic operations</li>
|
|
||||||
<li>Short circuiting for flow control to replace some <code>if</code>s</li>
|
|
||||||
<li>Some <code>#defines</code>, sadly</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>On the intersection of size and obfuscation is the data encoding, which was quite fun to design.</p>
|
|
||||||
|
|
||||||
<p>Some additional obfuscation was done to mathematical formulas. Somewhat known expressions was transformed into equivalent but less recognizable counterparts.</p>
|
|
||||||
|
|
||||||
<p>I have tried to avoid intentional red herrings in the code, although fishy statements are plentiful.</p>
|
|
||||||
|
|
||||||
<h2>Data encoding</h2>
|
|
||||||
|
|
||||||
<p>The large string in the beginning of the source file contains font data, encoded in base64 using characters in the range <code>' '</code> to <code>'_'</code>. The space was chosen as the zero because the data contains a lot of zeroes, and quite helpfully the size tool ignores whitespace even in strings. Without this fact the program would have been too large and the decoding feature would have had to go. Fortunately this hole in the size spec was readily available. :)</p>
|
|
||||||
|
|
||||||
<p>Characters in the font (5x8 pixels, 40 bits) is packed into 7 base64 digits (which was a pain to decode in minimal code).</p>
|
|
||||||
|
|
||||||
<h2>Math</h2>
|
|
||||||
|
|
||||||
<p>Note that even though floats are used for the waveforms, the standard math library is not used at all! Most arithmetic is done purely on integers. The only major exception is generating a table of sine values which are interpolated to give high resolution waveforms. Can you see when the generation is triggered, and how it is done?</p>
|
|
||||||
|
|
||||||
<p>A critical issue encountered was that having abrupt starts and ends of signals cause a lot of problems with spectral leakage which makes spectrograms hard to read and audio painful to listen to. To reduce spectral leakage a windowing function was used. Although the one used is quite well known, it is not in a form that should be familiar to anyone. What looks like a polynomial and quacks like a polynomial might not actually be a polynomial, at least not deep inside.</p>
|
|
||||||
|
|
||||||
<h2>Printing a string</h2>
|
|
||||||
|
|
||||||
<p>The program was written to deal exclusively with file descriptors, so how would one go about printing a char array not from a file descriptor without adding additional logic? Answer: <code>ungetc</code> into stdin, one char at a time (to be standards compliant). This is used to print the usage instructions.</p>
|
|
||||||
|
|
||||||
<h1>Compilation warnings</h1>
|
|
||||||
|
|
||||||
<p>Compiling using</p>
|
|
||||||
|
|
||||||
<pre><code>gcc -Wall -Wextra -pedantic
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>gives only <code>-Wmisleading-indentation</code> which is sensible considering the source code. While</p>
|
|
||||||
|
|
||||||
<pre><code>clang -Wall -Wextra -pedantic
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>is a bit more pessimistic and gives <code>-Wempty-body</code> (I like loops without bodies), <code>-Wstring-plus-int</code> (since apparently some people think string+int is a concatenation) and one of the weirder warnings I have seen from me splitting a negative constant with whitespace. Compiling using</p>
|
|
||||||
|
|
||||||
<pre><code>clang -Wall -Wextra -pedantic -Weverything
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>produces a few pagefuls of warnings and makes me feel generally bad about myself. :(</p>
|
|
||||||
|
|
||||||
<h1>Misc</h1>
|
|
||||||
|
|
||||||
<p>The reported size of the source code using the size tool is very intentionally 2018.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2018,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most able to divine code gaps</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most able to divine code gaps</h1>
|
|
||||||
|
|
||||||
<p>Derek Anderson</p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
./prog < textfile
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>./prog < prog.c
|
|
||||||
./prog < prog.orig.c
|
|
||||||
./prog < hint.text
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>With this entry, you won’t need to turn your monitor <a href="http://en.wikipedia.org/wiki/River_%28typography%29">upside down</a>!</p>
|
|
||||||
|
|
||||||
<p>Compare <code>prog.c</code> and <code>prog.orig.c</code> and find out why we had to modify the entry, and what confused the author
|
|
||||||
(see the author’s remarks). No, it was not the shape of the Roman V that we, or the compiler, didn’t like.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<h2>Compiling the program</h2>
|
|
||||||
|
|
||||||
<pre><code>gcc -Wall -Wextra -Wpedantic -O3 -std=c11 prog.c -o prog
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>Also works with a standard of c99, but c90/c89 will not compile due to
|
|
||||||
for loop initial declarations, along with additional warnings about
|
|
||||||
variable length arrays and lack of a return statement.</p>
|
|
||||||
|
|
||||||
<h2>Additional info</h2>
|
|
||||||
|
|
||||||
<p>This small program, when given text on stdin, will produce a pattern of
|
|
||||||
squiggly lines. This pattern is deterministic, and it shouldn’t be too
|
|
||||||
difficult to determine from whence they come. There is even a comment
|
|
||||||
that describes the highlighted phenomena in the source, for those that
|
|
||||||
require a small nudge. With denser text blocks, such as an essay or
|
|
||||||
similar prose, the output can be rather pretty, in an chaotic emergence
|
|
||||||
sort of way. Try using this file, or the source file as inputs.</p>
|
|
||||||
|
|
||||||
<p>In its current form, this program can handle lines of length 255; to
|
|
||||||
adjust this limit, change the variable <code>a</code> at the top of the source.
|
|
||||||
Other adjustments, such as the exact printed characters, are rather
|
|
||||||
easy, once sufficient reverse engineering has occurred. Improvements
|
|
||||||
such as proper handling of tabs are left as an exercise to the reader.</p>
|
|
||||||
|
|
||||||
<p>In developing this program, the author found a potentially interesting
|
|
||||||
bug. If the expression <code>(j=k,j)</code> (near the middle of the source) is
|
|
||||||
changed to <code>(j=k,k)</code>, the program produces different output. The author
|
|
||||||
used compiler gcc 5.4.0, compiled for x86_64-linux-gnu. Enabling or
|
|
||||||
disabling optimization produces the same results. The author is not
|
|
||||||
sure who is the culprit, but instead shrugged and moved on with life.
|
|
||||||
Of course, YMMV with your own environment.</p>
|
|
||||||
|
|
||||||
<p>The structure of this program, as you may have deduced, is two for
|
|
||||||
loops, one nested in the other. There is also a bunch of direct
|
|
||||||
variable assignment, such as <code>j=k</code>. There is some filler fluff, such as
|
|
||||||
<code>0-0+0</code>, but all that sort should be rather easy to spot. It was mostly
|
|
||||||
added for the purpose of making certain things line up right, and only
|
|
||||||
secondarily to obfuscate.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2018,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="../hint.css">
|
|
||||||
<title>Most inflationary</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Most inflationary</h1>
|
|
||||||
|
|
||||||
<p>Fabrice Bellard<br>
|
|
||||||
<a href="https://bellard.org/">https://bellard.org/</a></p>
|
|
||||||
|
|
||||||
<h2>Judges' comments:</h2>
|
|
||||||
|
|
||||||
<h3>To use:</h3>
|
|
||||||
|
|
||||||
<pre><code>make
|
|
||||||
./prog > lena.ppm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h3>Try:</h3>
|
|
||||||
|
|
||||||
<pre><code>eog lena.ppm # On Linux
|
|
||||||
preview lena.ppm # On MacOS
|
|
||||||
|
|
||||||
wget http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png
|
|
||||||
pngtopnm < Lenna.png | pnmscale 0.25 | cjpeg -arithmetic -dct float -quality 14 > small.jpg
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The file <code>small.jpg</code> will be approximately of the same size as the raw image data
|
|
||||||
in the program. Compare the level of the detail and the artifacts of
|
|
||||||
<code>small.jpg</code> and <code>lena.ppm</code>.</p>
|
|
||||||
|
|
||||||
<h3>Selected Judges Remarks:</h3>
|
|
||||||
|
|
||||||
<p>Compressing images is just a matter of simple arithmetic and some magic, isn’t it?</p>
|
|
||||||
|
|
||||||
<p>We could understand some of the arithmetic but none of the magic.</p>
|
|
||||||
|
|
||||||
<p>Deciphering the mechanism used for data encoding to make use
|
|
||||||
of the whitespaces, braces and semicolons should be a slightly easier task.</p>
|
|
||||||
|
|
||||||
<h2>Author’s comments:</h2>
|
|
||||||
|
|
||||||
<p>This program outputs a 128x128 RGB image file to the standard output
|
|
||||||
using the portable pixmap file format (PPM). It contains the famous
|
|
||||||
“Lena” image which is used in many image compression tests.</p>
|
|
||||||
|
|
||||||
<p>The uncompressed image is 12 times larger than the source code of the
|
|
||||||
program which includes the image data and the complete decoder. The
|
|
||||||
actual image data is 1220 byte long, which gives a compression ratio
|
|
||||||
of 40. Using a JPEG-like algorithm would not be enough to reach this
|
|
||||||
level of compression (the Lena image would be barely recognizable). So
|
|
||||||
the algorithm is based on the latest advances in image compression. It
|
|
||||||
includes the following features:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>DCT transform with variable block size (4x4, 8x8, 16x16 and 32x32)</li>
|
|
||||||
<li>DC and directional predictors</li>
|
|
||||||
<li>arithmetic coding</li>
|
|
||||||
<li>YCgCo color space.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The image data is encoded to a C string with some tricks to make the
|
|
||||||
best use of the IOCCC size constraints. The identifiers were shortened
|
|
||||||
to a single letter to save space. No specific obfuscation was needed
|
|
||||||
as the algorithms already have a significant complexity.</p>
|
|
||||||
|
|
||||||
<p>Although the program was optimized to decompress its built-in image,
|
|
||||||
it accepts to decompress image files from its standard
|
|
||||||
input. Examples:</p>
|
|
||||||
|
|
||||||
<pre><code>./prog d < lena512.bin > lena512.ppm
|
|
||||||
./prog d < fruits.bin > fruits.ppm
|
|
||||||
./prog d < vintage_cars.bin > vintage_cars.ppm
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<p>The original images for <a href="https://commons.wikimedia.org/wiki/File%3AFruits_oranges%2C_jardin_japonais_2.JPG">fruits</a> and <a href="https://commons.wikimedia.org/wiki/File%3ARed_Bull_Jungfrau_Stafette%2C_10th_stage_-_vintage_cars_%282%29.jpg">vintage cars</a> come from
|
|
||||||
Wikipedia and were resized to a width of 1024 pixels. Warning: the
|
|
||||||
program is not protected against invalid input.</p>
|
|
||||||
|
|
||||||
<p>The program should be portable on any Unix system. On Windows the line
|
|
||||||
“<em>setmode(0, 32768); </em>setmode(1, 32768);” must be added at the start of
|
|
||||||
the main() function to avoid unwanted carriage return characters in
|
|
||||||
the output.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<TABLE><TR>
|
|
||||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
|
||||||
<TD><P>© Copyright 1984-2018,
|
|
||||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
|
||||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loaded 100 of 143 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user