The navigation bar for a winning entry now has a "_Original C_" link
(between the ✅ and the Inventory on the right hand side) so that one
may easily view the original C code that was submitted for IOCCC judging.
Ran `make www timestamp` to perform the above.
760 lines
28 KiB
HTML
760 lines
28 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||
<!-- START: two lines up starts content from: inc/top.default.html -->
|
||
|
||
<!-- END: this line ends content from: inc/top.default.html -->
|
||
<!-- START: this line starts content from: inc/head.default.html -->
|
||
|
||
<head>
|
||
<link rel="stylesheet" href="../../ioccc.css">
|
||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||
<title>2006/sykes1 - Best assembler</title>
|
||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||
<meta name="description" content="2006 IOCCC entry sykes1 - Best assembler">
|
||
<meta name="keywords" content="IOCCC, 2006, IOCCC 2006, IOCCC entry, sykes1, Best assembler">
|
||
</head>
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- END: this line ends content from: inc/head.default.html -->
|
||
|
||
<!-- -->
|
||
<!-- This web page was formed via the tool: bin/readme2index.sh -->
|
||
<!-- The content of main section of this web page came from: 2006/sykes1/README.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2006/sykes1/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2006/sykes1/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2006/sykes1/README.md !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content from: inc/body.default.html -->
|
||
|
||
<body>
|
||
|
||
<!-- END: this line ends content from: inc/body.default.html -->
|
||
<!-- START: this line starts content from: inc/topbar.default.html -->
|
||
|
||
<div class="theader">
|
||
<nav class="topbar">
|
||
<div class="container">
|
||
<div class="logo">
|
||
<a href="../../index.html" class="logo-link">
|
||
IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="topbar-items">
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Entries
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../years.html" class="sub-item-link">
|
||
Winning entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../authors.html" class="sub-item-link">
|
||
Winning authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../location.html" class="sub-item-link">
|
||
Location of authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../bugs.html" class="sub-item-link">
|
||
Bugs and (mis)features
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||
Fixing entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_author" class="sub-item-link">
|
||
Updating author info
|
||
</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Status
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../news.html" class="sub-item-link">
|
||
News
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../status.html" class="sub-item-link">
|
||
Contest status
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../next/rules.html" class="sub-item-link">
|
||
IOCCC rules
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../next/guidelines.html" class="sub-item-link">
|
||
IOCCC guidelines
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../markdown.html" class="sub-item-link">
|
||
Markdown guidelines
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../SECURITY.html" class="sub-item-link">
|
||
Security policy
|
||
</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
FAQ
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html" class="sub-item-link">
|
||
Frequently asked questions
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../quick-start.html#enter" class="sub-item-link">
|
||
Enter the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#compiling" class="sub-item-link">
|
||
Compiling entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#running_entries" class="sub-item-link">
|
||
Running entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#help" class="sub-item-link">
|
||
How to help
|
||
</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
About
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../index.html" class="sub-item-link">
|
||
Home page
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../social.html" class="sub-item-link">
|
||
IOCCC social media
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../about.html" class="sub-item-link">
|
||
About the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../judges.html" class="sub-item-link">
|
||
The judges
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../thanks-for-help.html" class="sub-item-link">
|
||
Thanks for the help
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../contact.html" class="sub-item-link">
|
||
Contact us
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<div class="header-mobile-menu">
|
||
<noscript>
|
||
<a href="../../nojs-menu.html" class="topbar-js-label">
|
||
Please Enable JavaScript
|
||
</a>
|
||
</noscript>
|
||
|
||
<button id="header-open-menu-button" class="topbar-mobile-menu">
|
||
<img
|
||
src="../../png/hamburger-icon-open.png"
|
||
alt="hamburger style menu icon - open state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<button id="header-close-menu-button" class="hide-content">
|
||
<img
|
||
src="../../png/hamburger-icon-closed.png"
|
||
alt="hamburger style menu icon - closed state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<div id="mobile-menu-panel" class="hide-content">
|
||
<div class="mobile-menu-container">
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
Entries
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../years.html">
|
||
Winning entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../authors.html">
|
||
Winning authors
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../location.html">
|
||
Location of authors
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../bugs.html">
|
||
Bugs and (mis)features
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||
Fixing entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||
Updating author info
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||
Thanks for the help
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
|
||
<div class="mobile-menu-item">
|
||
Status
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../news.html">
|
||
News
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../status.html">
|
||
Contest status
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/rules.html">
|
||
IOCCC rules
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/guidelines.html">
|
||
IOCCC guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../markdown.html">
|
||
Markdown guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../SECURITY.html">
|
||
Security policy
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
FAQ
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html">
|
||
Frequently asked questions
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../quick-start.html#enter">
|
||
Enter the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#compiling">
|
||
Compiling entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
|
||
Running entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#help">
|
||
How to help
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
About
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../index.html">
|
||
Home page
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../social.html">
|
||
IOCCC social media
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../about.html">
|
||
About the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../judges.html">
|
||
The judges
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../contact.html">
|
||
Contact us
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<script>
|
||
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
|
||
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
|
||
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
|
||
|
||
headerOpenMenuButton.addEventListener("click", () => {
|
||
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.add("hide-content");
|
||
|
||
headerCloseMenuButton.classList.remove("hide-content");
|
||
headerCloseMenuButton.classList.add("topbar-mobile-menu");
|
||
|
||
mobileMenuPanel.classList.remove("hide-content");
|
||
mobileMenuPanel.classList.add("topbar-mobile-panel");
|
||
});
|
||
|
||
headerCloseMenuButton.addEventListener("click", () => {
|
||
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerCloseMenuButton.classList.add("hide-content");
|
||
|
||
mobileMenuPanel.classList.add("hide-content");
|
||
mobileMenuPanel.classList.remove("topbar-mobile-panel");
|
||
|
||
headerOpenMenuButton.classList.add("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.remove("hide-content");
|
||
});
|
||
</script>
|
||
|
||
<!-- END: this line ends content from: inc/topbar.default.html -->
|
||
<!-- START: this line starts content from: inc/header.default.html -->
|
||
|
||
<div class="header">
|
||
<a href="../../2011/zucker/index.html">
|
||
<img src="../../png/ioccc.png"
|
||
alt="IOCCC image by Matt Zucker"
|
||
width=300
|
||
height=110>
|
||
</a>
|
||
<h1>The International Obfuscated C Code Contest</h1>
|
||
<h2>2006/sykes1 - Best assembler</h2>
|
||
<h3>Bedlam cube solver</h3>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/header.default.html -->
|
||
<!-- START: this line starts content from: inc/navbar.mid.html -->
|
||
|
||
<div class="navbar">
|
||
<a class="Left" href="../stewart/index.html">← 2006/stewart</a>
|
||
<a class="Left" href="../index.html">↑ 2006 ↑</a>
|
||
<a class="Left" href="../sykes2/index.html">2006/sykes2 →</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/sykes1.c">C code</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/Makefile">Makefile</a>
|
||
<a class="Right" href="#inventory">Inventory</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/sykes1.orig.c">Original C</a>
|
||
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2006%2Fsykes1%2Findex.html">✓</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/navbar.mid.html -->
|
||
<!-- START: this line starts content from: inc/before-content.default.html -->
|
||
|
||
<div class="content" id="content">
|
||
|
||
<!-- END: this line ends content from: inc/before-content.default.html -->
|
||
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
|
||
|
||
<h2 id="author">Author:</h2>
|
||
<ul>
|
||
<li>Name: <a href="../../authors.html#Stephen_Sykes">Stephen Sykes</a><br>
|
||
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em> (<em>Finland</em>)</li>
|
||
</ul>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
|
||
<!-- BEFORE: 1st line of markdown file: 2006/sykes1/README.md -->
|
||
<h2 id="to-build">To build:</h2>
|
||
<pre><code> make</code></pre>
|
||
<p>There is an alt version based on the author’s remarks. The <a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/try.sh">try.sh</a>
|
||
script will compile and use both but if you wish to see the alternate version
|
||
specifically see the <a href="#alternate-code">Alternate code</a> section below.</p>
|
||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||
<p>The current status of this entry is:</p>
|
||
<blockquote>
|
||
<p><strong>STATUS: INABIAF - please DO NOT fix</strong></p>
|
||
</blockquote>
|
||
<p>For more detailed information see <a href="../../bugs.html#2006_sykes1">2006/sykes1 in bugs.html</a>.</p>
|
||
<h2 id="to-use">To use:</h2>
|
||
<pre><code> ./sykes1</code></pre>
|
||
<p>Next point your browser to the file: <code>sykes1.html</code>.</p>
|
||
<h2 id="try">Try:</h2>
|
||
<pre><code> ./sykes1 10</code></pre>
|
||
<p>Refresh your browser.</p>
|
||
<p>You might also try:</p>
|
||
<pre><code> ./try.sh</code></pre>
|
||
<p>This will run both the original entry and the alternate code to show some differences.</p>
|
||
<h3 id="also-try">Also try:</h3>
|
||
<p>If you have all day :-) and wish to find out how fast your machine can solve the
|
||
maximum:</p>
|
||
<pre><code> time ./sykes1 19186</code></pre>
|
||
<p>This was done on a Rocky Linux 9.2 server with <code>Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz</code> with 16 cores (via HyperThreading):</p>
|
||
<pre><code> real 6m35.524s
|
||
user 6m35.159s
|
||
sys 0m0.002s</code></pre>
|
||
<p>and done with macOS Sonoma with the Max M1 chip:</p>
|
||
<pre><code> real 7m10.786s
|
||
user 7m8.322s
|
||
sys 0m0.110s</code></pre>
|
||
<h2 id="alternate-code">Alternate code:</h2>
|
||
<p>This alternate code is based on the author’s remarks.</p>
|
||
<h3 id="alternate-build">Alternate build:</h3>
|
||
<pre><code> make alt</code></pre>
|
||
<h3 id="alternate-use">Alternate use:</h3>
|
||
<p>Use <code>sykes1.alt</code> as you would <code>sykes1</code> above.</p>
|
||
<h3 id="alternate-try">Alternate try:</h3>
|
||
<p>The <a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/try.sh">try.sh</a> script will use both versions to show some differences. You
|
||
can do so like:</p>
|
||
<pre><code> ./try.sh</code></pre>
|
||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||
<p>Read the <code>sykes1.html</code> (generated by <code>make</code>) page source.
|
||
Now then read the C source. Confused? :-) If it’s not clear try:</p>
|
||
<pre><code> diff -s sykes1.c sykes1.html</code></pre>
|
||
<p>For extra credit, understand what happens when you give this entry
|
||
an negative number argument, and why.</p>
|
||
<p>See the author’s remarks for how to make your own shapes as well.</p>
|
||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||
<p>This cube shaped program solves the fiendishly difficult “Bedlam Cube”.</p>
|
||
<p>If you did not get one for Christmas, there is an <a href="http://en.wikipedia.org/wiki/Bedlam_cube">article about these
|
||
puzzles in wikipedia</a>.</p>
|
||
<p>Some instructions on how to make your own cube are in the included file
|
||
<a href="bedlam-cubes.pdf">bedlam-cubes.pdf</a>.</p>
|
||
<p>Actually the cube is very hard to do by hand by just trying to fit it
|
||
together. I have not known anyone to solve it in this way - you would
|
||
need to be very lucky indeed to stumble across a solution.</p>
|
||
<h3 id="instructions">Instructions</h3>
|
||
<p>Compile the program, then test that it works:</p>
|
||
<pre><code> ./sykes1</code></pre>
|
||
<p>Shortly you should see the first solution pop out on your screen. It
|
||
shows you how to build the cube piece by piece, rendered in glorious
|
||
3D ASCII.</p>
|
||
<p>ASCII art is all very well, but you also have a web browser, right? Well, just
|
||
open the file <code>sykes1.html</code>. This html file is just a copy of
|
||
<a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/sykes1.c">sykes1.c</a>, which helpfully contains an html document that should make
|
||
the browser display for you a nice animated GIF, showing you how to build the
|
||
cube. Rendered in glorious 3D color.</p>
|
||
<p>Want to see another solution? Try:</p>
|
||
<pre><code> ./sykes1 some_number</code></pre>
|
||
<p>The program will discard solutions up to the number, and output numbered
|
||
solution. Refresh your browser window to see the new solution.</p>
|
||
<p>Try some more - there are exactly <code>19186</code> solutions to choose from.</p>
|
||
<p>If you have a fast machine you might try the last solution:</p>
|
||
<pre><code> ./sykes1 19186</code></pre>
|
||
<p>On my machine this takes about half an hour to run.</p>
|
||
<h3 id="implementation">Implementation</h3>
|
||
<p>The implementation is an optimized recursive algorithm that tries to fit
|
||
the pieces into the cube one by one. The cube pieces are defined near
|
||
the start of the program:</p>
|
||
<pre><code> int s[ ] = { 186, 94, 1426, 3098
|
||
,1047 , 122 , 1082 , 3083 , 1039
|
||
, 569 , 527 , 1054 , 531 } ;</code></pre>
|
||
<p>Each piece is a bitmap, and represents a 3x3x3 cube.</p>
|
||
<p>For instance the first piece is <code>186</code> - this is <code>010111010</code> in binary.
|
||
Written out like this you can see that it is the cross shaped piece:</p>
|
||
<pre><code> 010
|
||
111
|
||
010</code></pre>
|
||
<p>The other pieces are defined similarly. Most of the rest require more
|
||
than one layer, such as piece 3 (<code>1426</code>):</p>
|
||
<pre><code> 000
|
||
000
|
||
010
|
||
|
||
110
|
||
010
|
||
010</code></pre>
|
||
<p>Imagine the two layers on top of each other, and you should see this
|
||
shape:</p>
|
||
<pre><code> +---------+
|
||
/ +----+ /|
|
||
+-/ /| / |
|
||
|+----+ |/ +
|
||
|| | + /
|
||
+| | /
|
||
| | /
|
||
| | /
|
||
| |/
|
||
+----+</code></pre>
|
||
<h3 id="making-your-own-shapes">Making your own shapes</h3>
|
||
<p>The program is in fact a general solver - you can change the shape of
|
||
the pieces, and provided that a solution is possible, it will be found.</p>
|
||
<p>For example, if you modify line 13 of the source like this, the program
|
||
will solve for a different piece set:</p>
|
||
<pre><code> int s[ ] = { 187, 94, 402, 3098</code></pre>
|
||
<p>And of course you can make your own.</p>
|
||
<p>After the pieces are defined, the first thing the program does it to
|
||
fit them into a 4x4 cube. It collects every possible placing of each
|
||
of the pieces.</p>
|
||
<p>Once those placings are ready, the program recursively checks each
|
||
combination thereof.</p>
|
||
<p>In order to complete in a reasonable time, care is taken to eliminate
|
||
any branches that cannot result in a solution. This is done by checking
|
||
after each placing if all the remaining pieces can be placed somewhere,
|
||
and that all the free space in the cube can be filled by at least one
|
||
viable placing. Also if a piece is found to only have one possible
|
||
placing, it is placed immediately without invoking a recursive function
|
||
call.</p>
|
||
<p>Once the solution is found, the ASCII and GIF representations are
|
||
generated. Care must be taken to render cubes in the right order such
|
||
that pieces further back are occluded by those in front.</p>
|
||
<p>In the ASCII output care must be taken with drawing the edges of each
|
||
<code>1/64th</code> cube (edges must be removed within each piece). In the GIF
|
||
this is taken care of by color, which is graded from the back to the
|
||
front to ensure edge visibility.</p>
|
||
<h3 id="notes">Notes</h3>
|
||
<p>The whole program has just one function - <code>main()</code> - which is recursively
|
||
called. In fact if you select solution 19186 it will be called exactly
|
||
<code>159,260,759</code> times.</p>
|
||
<p>If you pick a number higher than <code>19186</code>, the program will return a
|
||
solution but it will be a rotation of one of the first <code>19186</code>. This is
|
||
because the cross shaped piece fits 48 ways in the 4x4 cube, but only
|
||
2 of those ways are unique - you can rotate one of those to make any
|
||
of the other 46. The algorithm used always places the cross piece
|
||
first, so the first two placings of that piece result in the <code>19186</code>
|
||
unique solutions.</p>
|
||
<p>If you pick a number higher than <code>460464</code> (<code>24x19186</code>) the program will
|
||
return without outputting a solution. If you can wait that long.</p>
|
||
<p>I recommend compiling with the most aggressive optimization options
|
||
your compiler supports. I find <code>--unroll-loops</code> to be helpful with gcc.</p>
|
||
<p>The program relies on <code>long long int</code> being 64 bits, but has no other special
|
||
requirements.</p>
|
||
<p>The program is known to compile and run under gcc and Intel cc, as well
|
||
as PellesC on Windows.</p>
|
||
<h3 id="bugs">Bugs</h3>
|
||
<p>The program is not at all a valid html document, but fortunately
|
||
browsers have good error recovery and amongst other things will ignore
|
||
the <code>/*</code> at the beginning, and won’t mind the missing html and head tags
|
||
and the lack of end tags.</p>
|
||
<p>The generated GIF is not compressed. This could be argued as an
|
||
advantage - at least I don’t violate any of those old Unisys patents!</p>
|
||
<p>The pieces aren’t really those colors. Unless you make your own.</p>
|
||
<!--
|
||
|
||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
<!-- AFTER: last line of markdown file: 2006/sykes1/README.md -->
|
||
|
||
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<div id="inventory">
|
||
<h1 id="inventory-for-2006sykes1">Inventory for 2006/sykes1</h1>
|
||
</div>
|
||
<h2 id="primary-files">Primary files</h2>
|
||
<ul>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/sykes1.c">sykes1.c</a> - entry source code</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/Makefile">Makefile</a> - entry Makefile</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/sykes1.alt.c">sykes1.alt.c</a> - alternate source code</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/sykes1.orig.c">sykes1.orig.c</a> - original source code</li>
|
||
<li><a href="bedlam-cubes.pdf">bedlam-cubes.pdf</a> - how to make your own Bedlam cube</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/try.sh">try.sh</a> - script to try entry</li>
|
||
</ul>
|
||
<h2 id="secondary-files">Secondary files</h2>
|
||
<ul>
|
||
<li><a href="2006_sykes1.tar.bz2">2006_sykes1.tar.bz2</a> - download entry tarball</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/README.md">README.md</a> - markdown source for this web page</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2006/sykes1/.path">.path</a> - directory path from top level directory</li>
|
||
<li><a href="index.html">index.html</a> - this web page</li>
|
||
</ul>
|
||
<hr style="width:10%;text-align:left;margin-left:0">
|
||
<h4>
|
||
Jump to: <a href="#">top</a>
|
||
</h4>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content from: inc/after-content.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/after-content.default.html -->
|
||
<!-- START: this line starts content from: inc/footer.inventory.html -->
|
||
|
||
<!--
|
||
|
||
Copyright © 1984-2025 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
|
||
<div class="footer">
|
||
|
||
<div id="copyright"><h3>Copyright © 1984-2025 by Landon Curt Noll:
|
||
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
|
||
<p>
|
||
This work is <b>licensed by Landon Curt Noll</b> under
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
|
||
target="_blank"
|
||
rel="license noopener noreferrer"
|
||
style="display:inline-block;">CC BY-SA 4.0</a></b>.
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/cc.png"
|
||
alt="cc inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/by.png"
|
||
alt="person inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/sa.png"
|
||
alt="arrow looping back on itself inside circle symbol"><br>
|
||
You should <b>carefully review</b> the
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
|
||
before using the licensed material.<br>
|
||
You may wish to review the
|
||
<b><a href="../../license.html"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
|
||
of <b>CC BY-SA 4.0</b>.<br>
|
||
</p>
|
||
</div>
|
||
|
||
<div id="coda"><h3>Coda</h3>
|
||
<p>
|
||
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2006%2Fsykes1%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
|
||
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
|
||
</p>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/footer.inventory.html -->
|
||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<!-- END: this line ends content from: inc/bottom.default.html -->
|