Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Sudoku as a Service with Julia (iaindunning.com)
62 points by idunning on Sept 17, 2013 | hide | past | favorite | 12 comments


I've been using Julia a little while now for my scientific work, and I have to say, it is a very well-designed language. I remember reading a few days ago on HN another user commented that he thought it was the best-designed language after Clojure. Not to mention it's much easier for people used to conventional programming languages to pick up and get started with.

I was actually thinking this would be a great language to use for web development; it's just that no one's developed a really good framework for it yet.


Theres been some work towards that: https://github.com/hackerschool/Meddle.jl is "middleware", and https://github.com/hackerschool/Morsel.jl is a framework. The main issue right now is that no one is particularly pushing/has a strong need for that kind of thing right now. I speculate that math-heavy services like the one described in this post will probably sit side-by-side with other services written in more traditional languages in the short to mid-term.


I remember some activities we did at junior high math courses regarding Sudokus. I was so disappointed to see the brute-force solving solution to work perfectly fine, no need to implement human solving-strategies. It was fun nevertheless :)


> I was so disappointed to see the brute-force solving solution to work perfectly fine

I had the same slight disappointment when hacking a PostScript solver together back in 2005 (see https://chris-lamb.co.uk/posts/sudoku-solver-in-postscript)

On the positive side, a brute force approach means you can easily test for unique solutions.


That's why I could never get into Sudoku. There is no creativity in the endeavor. It's like doing math homework for fun.


Brute-force strategies rarely work well in real life Sudoku.


Really? They tend to work pretty well for me.

I use Sudoku to exercise my memory.


I read through the Julia documentation and a couple tutorials last weekend, and I'm looking forward to building some things with it.

one note - this code could be better optimized by the compiler if you broke everything down into functions, especially the nested for loops (according to the optimization section of the docs).


It is a lot of fun, quite addictive! Let us know what you cook up at the julia-users google group. Re: optimization, that is indeed usually true, although I imagine the actual sudoku solve time dominates the request time. From a code design perspective I'd probably pull the validation/change-to-matrix stuff entirely and stick it in a module which would achieve the same thing. The way I build the "pretty" table is also pretty inefficient, using an IOBuffer is probably the right way to go. Tried to go for clarity for new-comers to the language.


That's a good tip in general, but it's mostly aimed at addressing type instability. For example, if you have

   x = 1
   f(x)
   x = "foobar"
   f(x)
then each call to f will be optimized for the current type of x. On the other hand, if your code is type stable, as it appears to be here, it will be properly optimized in place by the Julia JIT compiler and there's no need split it into separate functions.


Excuse me, can anyone tell me why I may be seeing this? I have showdead turned on.

http://cl.ly/RRQw


Duplicated comments are made dead. With showdead you can see the (dead) duplicate.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: