Solve a Rubik's cube: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Thundergnat moved page Solve a Rubik's Cube to Solve a Rubik's cube: capitalization policy) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 23:
For the single line example, typical timings are around 240 milliseconds which is much faster than Kotlin due, no doubt, to JVM warm up time.
<
*
* A cube 'state' is an int array with 40 entries, the first 20
Line 310:
fmt.Println("\nAverage number of moves =", float64(aggregateMoves)/float64(lineCount))
fmt.Println("\nAverage time =", elapsedTime/int64(lineCount), "milliseconds")
}</
{{out}}
Line 320:
=={{header|Julia}}==
{{trans|Kotlin}}
<
*
* A cube 'state' is a vector<int> with 40 entries, the first 20
Line 511:
pochmann("rubikdata.txt")
</
Using the 100-line database:
<pre style="height:45ex">
Line 627:
To aid readability I've also inserted spaces between each move in the results and added the total moves needed for each line.
<
/**********************************************************************
Line 859:
println("\nAverage number of moves = ${aggregateMoves.toDouble() / lineCount}")
println("\nAverage time = ${elapsedTime / lineCount} milliseconds")
}</
{{out}}
Line 987:
=={{header|Nim}}==
{{trans|Kotlin}}
<syntaxhighlight lang="nim">#[
**********************************************************************
*
Line 1,190:
let elapsedTime = cpuTime() - startTime
echo &"\nAverage number of moves = {aggregateMoves / lineCount}"
echo &"\nAverage time = {elapsedTime * 1000 / lineCount.toFloat:.2f} milliseconds"</
{{out}}
Line 1,319:
The final stage (pll) would probably benefit the most from being replaced with standard algorithms.<br>
While technically this works under pwa/p2js, you should expect a blank screen for nearly 3 minutes.
<!--<
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\rubik_cfop.exw
Line 1,708:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</
{{Out}}
The "hardest case" from http://www.cube20.org with a high threshold. You can try this manually.
Line 1,774:
Translation/de-golf(hrumph) of Tomas Sirgedas' winning entry from http://tomas.rokicki.com/cubecontest as held in 2004.<br>
Faster and shorter solutions (in most cases) than cfop, however probably nigh on impossible to debug/enhance...
<!--<
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\rubik_tomas.exw
Line 1,990:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s (%d move%s)\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">tomas</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"UL DL RF UB FD BR DB UF DR UR BL FL FDR BLU DLB URB RUF FLD BRD FUL"</span><span style="color: #0000FF;">))</span>
<!--</
{{out}}
<pre>
Line 2,003:
Despite this, the script is taking an average of just over a second to calculate the number of moves for each line which is probably not too bad for an interpreted language.
<
*
* A cube 'state' is an int array with 40 entries, the first 20
Line 2,260:
var elapsedTime = ((endTime - startTime) * 1000).round
System.print("\nAverage number of moves = %(aggregateMoves/lineCount)")
System.print("\nAverage time = %(elapsedTime/lineCount) milliseconds")</
{{out}}
|