754 lines
33 KiB
HTML
754 lines
33 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>2005/aidan - Most ingenious puzzle solution</title>
|
||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||
<meta name="description" content="2005 IOCCC entry aidan - Most ingenious puzzle solution">
|
||
<meta name="keywords" content="IOCCC, 2005, IOCCC 2005, IOCCC entry, aidan, Most ingenious puzzle solution">
|
||
</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: 2005/aidan/README.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2005/aidan/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2005/aidan/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2005/aidan/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 winning authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../bugs.html" class="sub-item-link">
|
||
Bugs and (mis)features
|
||
</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">
|
||
IOCCC 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/index.html" class="sub-item-link">
|
||
Rules and Guidelines
|
||
</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">
|
||
FAQ
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#submit" class="sub-item-link">
|
||
How to enter the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||
Fixing IOCCC entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_web_site" class="sub-item-link">
|
||
Fixing the website
|
||
</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">
|
||
About
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../index.html" class="sub-item-link">
|
||
IOCCC Home
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../judges.html" class="sub-item-link">
|
||
The IOCCC Judges
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../contact.html" class="sub-item-link">
|
||
Contacting the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../SECURITY.html" class="sub-item-link">
|
||
IOCCC Security Policy
|
||
</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="../../markdown.html" class="sub-item-link">
|
||
IOCCC markdown guidelines
|
||
</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">
|
||
Authors of winning IOCCC entries
|
||
</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>
|
||
|
||
</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="../../status.html">
|
||
Contest status
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/index.html">
|
||
Rules and Guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../news.html">
|
||
IOCCC News
|
||
</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="../../faq.html#submit">
|
||
How to enter the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||
Fixing IOCCC entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_web_site">
|
||
Fixing the website
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||
Fixing author info
|
||
</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">
|
||
IOCCC Home
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../judges.html">
|
||
The IOCCC Judges
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../contact.html">
|
||
Contacting the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||
Thanks for the help
|
||
</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>2005/aidan - Most ingenious puzzle solution</h2>
|
||
</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="../../2004/vik2/index.html">← 2004/vik2</a>
|
||
<a class="Left" href="../index.html">↑ 2005 ↑</a>
|
||
<a class="Left" href="../anon/index.html">2005/anon →</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/aidan.c">C code</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/Makefile">Makefile</a>
|
||
<a class="Right" href="#inventory">Inventory</a>
|
||
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2005%2Faidan%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#Aidan_Thornton">Aidan Thornton</a><br>
|
||
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</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: 2005/aidan/README.md -->
|
||
<h2 id="to-build">To build:</h2>
|
||
<pre><code> make</code></pre>
|
||
<p>There is an alternate version based on the author’s remarks. See <a href="#alternate-code">Alternate
|
||
code</a>.</p>
|
||
<h2 id="to-use">To use:</h2>
|
||
<pre><code> ./aidan < puzzle
|
||
|
||
./aidan seed</code></pre>
|
||
<p>where <code>seed</code> is a number.</p>
|
||
<h2 id="try">Try:</h2>
|
||
<pre><code> ./try.sh</code></pre>
|
||
<h2 id="alternate-code">Alternate code:</h2>
|
||
<p>This code is formatted differently and is not the approach used by the author;
|
||
it is slower, inelegant and not as obscure, as the author put it.</p>
|
||
<h3 id="alternate-build">Alternate build:</h3>
|
||
<pre><code> make alt</code></pre>
|
||
<h3 id="alternate-use">Alternate use:</h3>
|
||
<p>Use <code>aidan.alt</code> as you would <code>aidan</code> above.</p>
|
||
<h3 id="alternate-try">Alternate try:</h3>
|
||
<pre><code> ./try.alt.sh</code></pre>
|
||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||
<p>Are you puzzled about puzzles? This entry might puzzle you
|
||
more while it puzzles out some puzzles: all in a puzzling way!</p>
|
||
<p><code>goto</code> the source and notice the lack of functions. Jump
|
||
to the <code>switch</code> statement. And if you think you can puzzle
|
||
it out better, try solving <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane1.sudoku">insane1.sudoku</a> all by yourself!</p>
|
||
<p><strong>NOTE</strong>: the tarball named by the author was removed after the files were
|
||
extracted into the directory instead. These files were added to the list.</p>
|
||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||
<p>This program can solve a type of logic puzzle known as a
|
||
<a href="https://en.wikipedia.org/wiki/Sudoku">Sudoku</a>, and also
|
||
generate new ones.</p>
|
||
<h3 id="contents">Contents</h3>
|
||
<ul>
|
||
<li>program file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/aidan.c">aidan.c</a> - sudoku solver and generator</li>
|
||
<li>test suite: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/test-su.perl">test-su.perl</a> - optional test script (written for Perl5)</li>
|
||
<li>sudoku file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/blank.sudoku">blank.sudoku</a></li>
|
||
<li>sudoku file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane1.sudoku">insane1.sudoku</a></li>
|
||
<li>sudoku file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane2.sudoku">insane2.sudoku</a></li>
|
||
<li>sudoku file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane3.sudoku">insane3.sudoku</a></li>
|
||
<li>sudoku file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane4.sudoku">insane4.sudoku</a></li>
|
||
<li>sudoku file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane5.sudoku">insane5.sudoku</a></li>
|
||
<li>sudoku file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/tough1.sudoku">tough1.sudoku</a></li>
|
||
<li>sudoku file: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/wp.sudoku">wp.sudoku</a></li>
|
||
</ul>
|
||
<p>Yes, the test suite really is 5 times larger than the actual program. You
|
||
<strong>did</strong> say this was a parody of the software development process…</p>
|
||
<h3 id="important">IMPORTANT</h3>
|
||
<p><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/test-su.perl">test.perl</a> expects the <code>sudoku-sf</code> executable to be
|
||
<code>./sudoku-sf</code>. If you rename it, please change the definition of <code>$sf_exe</code> to the
|
||
new name.</p>
|
||
<p><strong>Judges’ note</strong>: this was done.</p>
|
||
<h3 id="legal-blurb">Legal blurb</h3>
|
||
<p>This program comes with NO WARRANTY, not even that it’ll do what I say it
|
||
should. Any misfortunes that occur as a result of using this are not my fault.
|
||
Go find some unpopular multinational to sue instead.</p>
|
||
<p>This program is not copyrighted and is entirely my work. Distribute or modify
|
||
it as you wish, though please give me credit.</p>
|
||
<h3 id="what-is-a-sudoku">What is a sudoku?</h3>
|
||
<p>(If you know, feel free to skip this section. Get more details from <a href="http://en.wikipedia.org/wiki/Sudoku">the
|
||
wikipedia entry</a>.</p>
|
||
<p>A sudoku is a type of logic puzzle. You are given a grid of 9x9 boxes, some
|
||
of which contain digits. This is divided into a 3x3 set up, e.g. (from the
|
||
Wikipedia article - fairly easy):</p>
|
||
<pre><code> . . . | 1 . . | 7 4 .
|
||
. 5 . | . 9 . | . 3 2
|
||
. . 6 | 7 . . | 9 . .
|
||
------+-------+------
|
||
4 . . | 8 . . | . . .
|
||
. 2 . | . . . | . 1 .
|
||
. . . | . . 9 | . . 5
|
||
------+-------+------
|
||
. . 4 | . . 7 | 3 . .
|
||
7 3 . | . 2 . | . 6 .
|
||
. 6 5 | . . 4 | . . .</code></pre>
|
||
<p>You have to fill in the remaining boxes so that each row, column, and smaller
|
||
box contains all of the digits 1-9. That’s all the information I needed to
|
||
figure out how to solve them, but there’s a useful tutorial on
|
||
<a href="http://www.sudoku.org.uk/" class="uri">http://www.sudoku.org.uk/</a>, which is roughly affiliated with the <a href="https://www.telegraph.co.uk/">Daily
|
||
Telegraph</a>, a UK newspaper.</p>
|
||
<p>Now, with modern computers this <strong>can</strong> be solved using brute force, e.g.:</p>
|
||
<pre><code> #include <stdio.h> /* sudoku-bfi.c */
|
||
#define S(t) for(n=0;n<9;v[n++]=0);for(n=0;n<81;n++)if(i[n]){z=1<<i[n];if(v[t]\\
|
||
&z)for(;;){if(p<0)goto d;if(i[p]++<9)goto f;i[p]=0;p=s[p];}v[t]|=z;}
|
||
int i[82],s[81],v[9],n,p,z;int main(void){for(n=0;n<81;){p=getchar()^48;if(p==
|
||
30)p=0;if(p<10)i[n++]=p;}i[81]=0;p=-1;f:S(n%9)S(n/9)S(n%9/3+n/27*3)if(p>80)goto
|
||
d;for(n=p;i[++p];);s[p]=n;i[p]=1;goto f;d:z=p<81;printf("\n%s!\n\n",z?"Fail":
|
||
"Success");for(n=0;n<81;){p=i[n];printf("%c %s",(p?p|48:'.'),(++n%3?"":n%9?"| "
|
||
:n%27?"\n":n%81?"\n------+-------+------\n":"\n\n"));}return z;}</code></pre>
|
||
<p><strong>Judges’ note</strong>: this was added as <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/aidan.alt.c">aidan.alt.c</a>.</p>
|
||
<p>That isn’t the approach I’ve used; it’s slow (particularly in worst-case or
|
||
nearly so scenarios), inelegant, and not a good starting point for sudoku
|
||
generation. It’s also much too easy to understand ;-) Instead, I’ve written a
|
||
program which solves them in much the same way as I do, only a lot faster (and
|
||
hopefully more reliably).</p>
|
||
<p>Oh, and if you think that example sudoku is too easy, try this one (which my
|
||
program generated):</p>
|
||
<pre><code> --- insane1.sudoku --
|
||
. . 4 | . . . | . 5 6
|
||
5 . . | . 7 2 | . . .
|
||
. . 1 | . . . | 8 . .
|
||
------+-------+------
|
||
. . . | . . . | . . .
|
||
. . . | 6 9 3 | . . 5
|
||
. . . | . . . | 7 3 4
|
||
------+-------+------
|
||
. 5 . | 2 . 1 | 4 . 8
|
||
3 . . | . . . | . . .
|
||
. . . | . . . | . 6 1</code></pre>
|
||
<p>Be warned - it’s evil! (I certainly haven’t been able to solve it by hand. The
|
||
brute-force program given above, <code>sudoku-bfi.c</code>, <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/aidan.alt.c">aidan.alt.c</a>,
|
||
also has trouble - it took 66 seconds to solve it - but probably for different
|
||
reasons. That’s the worst performance I’ve had from brute-force so far!)</p>
|
||
<h3 id="usage">Usage</h3>
|
||
<h4 id="building">Building</h4>
|
||
<pre><code> cc -o sudoku-sf sudoku-sf.c</code></pre>
|
||
<p>or, if using gcc, try:</p>
|
||
<pre><code> gcc -O2 -Wall -Wextra -ansi -pedantic-errors -o sudoku-sf sudoku-sf.c</code></pre>
|
||
<h4 id="testing-optional">Testing (optional)</h4>
|
||
<pre><code> perl ./test-su.perl</code></pre>
|
||
<p>Note that this requires Perl 5 (I use 5.8.5, earlier versions untested) and is
|
||
somewhat slow (should take under a minute on a fairly modern PC - try
|
||
appending <code>-n 0</code> if you’re in a hurry). I wrote it mostly for my own benefit,
|
||
really.</p>
|
||
<h4 id="solving">Solving</h4>
|
||
<pre><code> ./aidan < somefile.txt</code></pre>
|
||
<p>Input should be the numbers of each row in turn. Empty spaces can be
|
||
represented as a full stop (<code>.</code>) or zero (<code>0</code>). Other characters are ignored, so you
|
||
can cut-and-paste either example sudoku puzzle from above into a file and feed that
|
||
in. The program has coped with every input I’ve thrown at it so far, including
|
||
an <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/blank.sudoku">empty grid</a>.</p>
|
||
<p>Output consists of the problem, then the solution, then a message of
|
||
success/failure.</p>
|
||
<p><code>./aidan U</code> may also be useful, or perhaps not. It only took
|
||
an extra 15 bytes of (very simple) code to add, so it doesn’t really matter to
|
||
me. (It’s the same as the normal mode for most input you’re likely to feed it,
|
||
though slightly slower. See if you can figure out what it does.)</p>
|
||
<h4 id="generating">Generating</h4>
|
||
<pre><code> ./sudoku <seed></code></pre>
|
||
<p>Output is a blank grid, then the solution, then the problem. There’s no
|
||
control over the difficulty. Sorry. However, all generated sudokus should have
|
||
exactly one solution - if one doesn’t, that’s a bug.</p>
|
||
<h3 id="speed">Speed</h3>
|
||
<p>Fast enough. Solving and generating are practically instant on my 1Ghz Duron.
|
||
Of course, there could be some cases which take longer…</p>
|
||
<p>More precisely - 400 random sudokus are generated and solved in about 45 seconds
|
||
in tests on my PC (1Ghz Duron, gcc 3.4.1, <code>-O2</code> optimisation - takes about 60
|
||
seconds with no optimisation). If that isn’t fast enough, what on Earth are you
|
||
doing with it?</p>
|
||
<h3 id="bugs">Bugs</h3>
|
||
<p>None known - hopefully I’ve worked out all the major ones. Nothing has come up
|
||
in testing since the last bug fix, but what does that mean?</p>
|
||
<p>Tested on:</p>
|
||
<ul>
|
||
<li><code>gcc 3.4.1-3mdk</code>, Linux/x86</li>
|
||
</ul>
|
||
<p><em>RETEST</em> Borland C 4.5, 16-bit DOS .exe (small memory model)</p>
|
||
<p>I don’t count the fact that it first prints a blank grid whenever asked to
|
||
generate a sudoku as a bug - just a minor quirk. The fix is slightly awkward
|
||
and would make the program slightly longer, so I haven’t bothered - it’s not
|
||
important.</p>
|
||
<h3 id="missing-features">Missing Features</h3>
|
||
<ul>
|
||
<li><p>No control over the difficulty of generated sudokus - they vary from easy to
|
||
hair-tugging near-impossibility. Solver beware. Seeing as apparently one program
|
||
<a href="http://news.bbc.co.uk/1/hi/magazine/4469719.stm">took six years</a>, I’m in no
|
||
hurry.</p></li>
|
||
<li><p>Some sort of curses-based UI to let you solve interactively might be cool,
|
||
but I don’t feel like learning curses just for this. Besides, I spent enough
|
||
of the time swearing as it is.</p></li>
|
||
<li><p>If you mistype a sudoku (e.g. from a paper/magazine) - and you will - it
|
||
can’t help you figure out where the mistake is, sadly.</p></li>
|
||
</ul>
|
||
<h3 id="portability">Portability</h3>
|
||
<p>Dependant on ASCII, requires that an <code>int</code> is at least 15 bits and a <code>long</code> at
|
||
least 32. (No, that isn’t a typo - I did say 15, not 16).</p>
|
||
<p>Also requires that <code>cpp</code> can properly handle something like:</p>
|
||
<pre><code> #define foo(x,y) x y
|
||
foo(bar,)</code></pre>
|
||
<p>Apparently, a few can’t (ANSI C specifically doesn’t require that this works,
|
||
though it usually does). Unfortunately, I didn’t discover this issue until too
|
||
late. (It was mentioned in the notes for people modifying GCC in the “beware
|
||
of obscure compiler limitations” section, so I’m figuring it’s quite unusual.)</p>
|
||
<h3 id="compiler-warnings">Compiler warnings</h3>
|
||
<p>Some when compiled with <code>gcc -Wall -Wextra -ansi -pedantic</code>:</p>
|
||
<ul>
|
||
<li>The left-hand operand of a comma has no effect in two places.</li>
|
||
<li>Parentheses are suggested around a <code>+</code> in an operand of <code>&</code> in the <code>i</code> macro
|
||
definition.</li>
|
||
</ul>
|
||
<p>Borland C also spots some code in expressions which has no effect, and some
|
||
uses of <code>=</code> where you’d expect a comparison operator.</p>
|
||
<h3 id="obfuscation">Obfuscation</h3>
|
||
<p>Let’s see now:</p>
|
||
<ul>
|
||
<li>Squint-inducing variable naming.</li>
|
||
<li>Slightly odd <code>#defines</code> (which will be cleaned up by <code>cpp</code> + a code
|
||
beautifier, but see the next item).</li>
|
||
<li>No functions but <code>main()</code> - all code reuse via <code>#define</code>s, or by various other
|
||
methods (usually somewhat icky ones). This wasn’t deliberate - it just ended up
|
||
that way somehow…</li>
|
||
<li><code>goto</code>s from everywhere to everywhere else.</li>
|
||
<li>A slightly… interesting <code>switch</code> statement.</li>
|
||
<li>Generally odd flow of control (see above items).</li>
|
||
<li>Plenty of bit-twiddling.</li>
|
||
<li>To save space, no <code>'A'</code>-style char constants - hard-coded numbers are used.
|
||
(There’s one, but it isn’t used to make things <strong>clearer</strong>).</li>
|
||
<li><code>array[index]</code> notation, because:
|
||
<ul>
|
||
<li>it’s traditional</li>
|
||
<li>take a look at how the <code>s</code> and <code>N(I,l)</code> macros are used</li>
|
||
</ul></li>
|
||
<li>various other little things not worth mentioning.</li>
|
||
</ul>
|
||
<p>So basically, just what you’d normally expect in an IOCCC entry.</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: 2005/aidan/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-2005aidan">Inventory for 2005/aidan</h1>
|
||
</div>
|
||
<h2 id="primary-files">Primary files</h2>
|
||
<ul>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/aidan.c">aidan.c</a> - entry source code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/Makefile">Makefile</a> - entry Makefile</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/aidan.alt.c">aidan.alt.c</a> - alternate source code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/aidan.orig.c">aidan.orig.c</a> - original source code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/blank.sudoku">blank.sudoku</a> - blank Sudoku puzzle</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane1.sudoku">insane1.sudoku</a> - insane sudoku puzzle</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane2.sudoku">insane2.sudoku</a> - insane sudoku puzzle</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane3.sudoku">insane3.sudoku</a> - insane sudoku puzzle</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane4.sudoku">insane4.sudoku</a> - insane sudoku puzzle</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/insane5.sudoku">insane5.sudoku</a> - insane sudoku puzzle</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/tough1.sudoku">tough1.sudoku</a> - tough sudoku puzzle</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/try.alt.sh">try.alt.sh</a> - script to try alternate code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/try.sh">try.sh</a> - script to try entry</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/wp.sudoku">wp.sudoku</a> - Wikipedia sudoku puzzle</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/test-su.perl">test-su.perl</a> - test suite</li>
|
||
</ul>
|
||
<h2 id="secondary-files">Secondary files</h2>
|
||
<ul>
|
||
<li><a href="2005_aidan.tar.bz2">2005_aidan.tar.bz2</a> - download entry tarball</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/README.md">README.md</a> - markdown source for this web page</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/aidan/.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-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/
|
||
|
||
-->
|
||
|
||
<div class="footer">
|
||
|
||
<div id="copyright"><h3>Copyright © 1984-2024 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%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2005%2Faidan%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 -->
|