• Welcome to the Speedsolving.com, home of the web's largest puzzle community!
    You are currently viewing our forum as a guest which gives you limited access to join discussions and access our other features.

    Registration is fast, simple and absolutely free so please, join our community of 40,000+ people from around the world today!

    If you are already a member, simply login to hide this message and begin participating in the community!

Advice on the appropriate programming language for exploring lower bounds?

wheezyg

Member
Joined
Jun 15, 2010
Messages
2
Does anyone have advice on what programming language would be best to learn in order to be able to figure out lower bounds on (first) the 3x3x3 (as a self-teaching tool), then eventually different puzzle cubes? I would like to get two things out of this project. First, I would like to be able to learn a programming language (obviously) and secondly, I would like to be able to explore minimal solutions to cubes (or cube-like puzzles), and their subgroups, using what I have learned.

I have a small amount of experience with scheme and C++ (but very, VERY rusty). What have others used to explore minimal solutions? Any advice would be greatly appreciated!

thx
ENG
 

Litz

Member
Joined
Dec 14, 2009
Messages
216
Location
Portugal
It doesn't really matter what language you do it on. You can code the algorithms with whatever you want.

Scheme is a great language to start learning but I doubt you'll ever use it in the future. If you want to learn a language and already have some experience with Scheme, go ahead with C++. It might take you a while to understand some things, but it will actually make your life easier in the future. And honestly, once you know it, you'll easily pick up other languages if you want to.
 

Christopher Mowla

Premium Member
Joined
Sep 17, 2009
Messages
1,184
Location
Earth
YouTube
Visit Channel
I would go with C++ too. I have heard it is a very fast language. I would think speed comes in handy for calculating lower bounds.
 
Last edited:

Lars Petrus

Member
Joined
Mar 22, 2009
Messages
67
WCA
1982PETR01
C++ is the fastest, but it's quite a bit harder to be productive with, especially if you're not an expert programmer.

I'd go with Java. C# is very similar. They're no worse than half as fast.
 

LewisJ

Member
Joined
Nov 4, 2009
Messages
273
As long as you write your program to be structured towards what your programming language of choice is good at and to avoid what your programming language of choice is bad at, it almost doesn't matter.

For example - on question 10 on projecteuler, I wrote a lua script tailored to how lua works which comes up with the answer in ~2 seconds on my netbook, while one of my friends wrote a program in java following the same method but taking MUCH longer. Although lua is renowned for its speediness (often regarded as the fastest among scripting language), you'd still expect java to beat it in a simple brawny test. It didn't because the way my program worked to cater to lua's strong points caused a problem with memory allocation in java or something, causing it to take much longer.

Simply saying python is slow vs C is fast is like saying QQ is a faster cuber than faz because QQ is faster at bigcubes. Different languages have different strong sides and applications - as long as you use them appropriately you should be fine.
 
Last edited:

Johannes91

Member
Joined
Mar 28, 2006
Messages
1,341
For example - on question 10 on projecteuler, I wrote a lua script tailored to how lua works which comes up with the answer in ~2 seconds on my netbook, while one of my friends wrote a program in java following the same method but taking MUCH longer.
Sure, it's possible to write slow code in any language. But some are still much better than others for writing fast code.

OP: You want a low level language with bit-level operations and support for big arrays of unboxed ints with zero memory over-head. C++ would be a fine choice, I like it a lot for algorithmic programming. While it is a bit of a mess and C# and Java are definitely cleaner languages, I don't think that's really important for what you're planning to do.
 

souljahsu

Member
Joined
Jun 18, 2010
Messages
216
Location
Delta, British Columbia, Canada
WCA
2010HSUK01
sorry, what I was trying to say was:
It's a lot faster to write a program in Python but it will run relatively slow comparing a program written in C, because C is a compiled language and Python is a interpreted language.

edit: so if its a small program, write it in Python; but if it's a big program, write it in C
 

LewisJ

Member
Joined
Nov 4, 2009
Messages
273
Sure, it's possible to write slow code in any language.

That's not the point I was going for - I was trying to show that different languages perform well in different ways. Lua performed well with the way I wrote my solution, while Java would work well with some other method.

Anyway, if you're serious about this, be sure to look into the work Rokicki has done to cut the requirement to 22 moves. Here is his paper on his 25 move solution, I'm not sure if a similar document exists for his 22move proof but it was an extension of the idea used for 25 moves. He never mentions what he wrote his program in, but I would think either x86 assembly or C++. You might contact him to discuss his program - he's been into upper bound work much more than any of us, he would know more.
 
Joined
Nov 29, 2008
Messages
214
I suggest using C++ or C because it is easy to interface with Windows API-functions (or similar Linux functions) which is quite usefull if you want to write really fast code. But if you are a beginner in programming do not expect too much. You should start with a 2x2x2 cube solver. Try to understand the concepts of move-tables, pruning tables, symmetry reductions etc. A good 3x3x3 solver is much more difficult to program and you should not start this before you have managed to write an optimal 2x2x2 solver which gives you the optimal solution within in a few milliseconds.
 
Last edited:

Johannes91

Member
Joined
Mar 28, 2006
Messages
1,341
That's not the point I was going for - I was trying to show that different languages perform well in different ways. Lua performed well with the way I wrote my solution, while Java would work well with some other method.
I know what you're saying, and it's a good point to make. Especially beginner programmers often put too much weight to the "C is faster than Python" statements, as it really depends on whose using the language and what for.

The point I was trying to get across is that a straight-forward solution in C for that Euler problem runs in a few milliseconds, which is several orders of magnitude faster than your Lua.

I suggest using C++ or C because it is easy to interface with Windows API-functions (or similar Linux functions) which is quite usefull if you want to write really fast code.
Sounds interesting, could you give some pointers as to which OS functions would be the most useful to look at?
 
Last edited:
Top