Sudoku solver

BartC bc at freeuk.com
Sun Mar 29 07:25:20 EDT 2015


On 29/03/2015 04:06, Steven D'Aprano wrote:
> On Sun, 29 Mar 2015 10:50 am, BartC wrote:

>> But using X *and* my own brute-force algorithm, the same puzzle took 2
>> seconds to solve - faster than C!

> But, when you tell me that your very own personal interpreted language,
> which I assume nobody else has worked on, is 40% faster than optimized C,
> my first reaction is to expect that you've probably made a mistake
> somewhere. I would have the same reaction if somebody casually dropped into
> a conversation that they happened to beat Usain Bolt's 100m personal best
> of 9.58 seconds by almost four seconds. While carrying a 20kg backpack.

As Chris mentioned, when I say 'faster than C', I mean X running my 
algorithm was faster then C running Marko's algoritim (on Ian's data). 
This was just an illustration of algorithm being more important than 
language.

(As it happens, C using gcc was particularly good at this benchmark. 
Looking only at optimised code, Clang took 4.5 seconds, while a trio of 
lesser C compilers took from 14 to 22 seconds.

This is why I also showed the unoptimised figure, which indicates what 
raw native code could do, without taking account of the 
super-optimisations that gcc is capable of applying.

Because after all such optimisations could also be applied to the Python 
code, such as unrolling those nested loops in good().

And theoretically, a clever enough C compiler could have solved it in 0 
seconds since I'd hard-coded the board values within the source!

See: http://pastebin.com/RZE67TLy )

-- 
Bartc



More information about the Python-list mailing list