Stupid Coding Tricks: Sudoku solver in Whitespace!



  • Yes, I know. I have way too much time on my hands. 

    I wanted to practice some of what I learned from my recent compilers class (hey, I enjoy the subject), so I designed a simple LISP-like language that compiles to Whitespace. Of course, I wanted to write a small (but not trivial) application in it to test out the compiler. A sudoku solver - basically just a simple depth first search algorithm - seemed the perfect choice.

    http://rapidshare.com/files/235032340/sudoku.ws

    The Whitespace interpreter is here: http://compsoc.dur.ac.uk/whitespace/




  •  hehe, very clever.  I like how almost nobody writes IN whitespace, buy instead compiles TO it.  I'm wondering why you didn't paste your source?



  • The web tends to screw up white-space formatting (I've played around a bit on the "Preview" tab, but it seems to convert all tabs into spaces). If you want, I could post a long string of 's', 't', and 'n' so you can do a search & replace in a text edtior. Being a 12k file though, that kinda borders on spamming.



  • thread moved to funny stuff
    (IMO a better fit than the sidebar wtf)



  •  @ammoQ said:

    thread moved to funny stuff (IMO a better fit than the sidebar wtf)

     Darnit! I should have waited until tomorrow morning to post this, just before everyone started work. Nobody's gonna see it here.



  • @Huf Lungdung said:

    Being a 12k file though, that kinda borders on spamming.

    You could post it to [url=http://whitespace.pastebin.com/]basepint[/url].



  • Thanks. That's a really cool website.

    http://whitespace.pastebin.com/f761fc4b5

    Note that you can't copy & paste the code because it seems to add indented line numbers. Use the "download" link instead.

     



  • @Huf Lungdung said:

    Note that you can't copy & paste the code because it seems to add indented line numbers. Use the "download" link instead.

    You're using IE, aren't you?

    Interestingly enough, Firefox doesn't add line numbers, but inserts octothorpes between lines. Opera doesn't add anything.



  •  Umm... no. I am using FireFox, but it wasn't adding hash symbols. 

    As long as it doesn't add white-space characters, it should be good. The problem was that the line numbers were indented.



  • Alternatively, one could also copy and paste the text from the text area at the bottom of the page. This should preserve the whitespace characters correctly (it does at least in Firefox).


Log in to reply