Archive for the ‘speedcubing’ Category

Rubik’s cube Average formula in Excel

stopwatchAny speedcuber knows how to calculate his or her average: total all, remove fastest and slowest, and divide. Here’s how you do that in Excel

=( SUM(A1:A12) – MIN(A1:A12) – MAX(A1:A12) ) / (COUNT(A1:A12) – 2)

But that is tedious of course, and your constantly changing the range to find the average of e.g. 5, or a running average. So instead I wrote a little VBA function you can put in a module.

  • Press ALT+F11 to go to the editor
  • Choose Insert > Module
  • Choose Insert > Procedure
  • Type CubeAVG
  • Click Function
  • Click OK

Now edit so it’s like the code below

' cubeavg : calculate speedcubing average
Public Function cubeavg(r)
    Dim total As Double, fastest As Double, slowest As Double, n As Integer
    total = WorksheetFunction.Sum(r)
    fastest = WorksheetFunction.Min(r)
    slowest = WorksheetFunction.Max(r)
    n = WorksheetFunction.Count(r) - 2
    cubeavg = (total - slowest - fastest) / n
End Function

Don’t forget to save the file…

Finding Possible Cube PLL Algorithms using an Anagram Finder

I ran the internet anagram server on the list of PLL algorithms’ shortcodes: 

So who can find some interesting words or sentences? Put it in the comments.

Here’s the full list:

288 candidate words found:
1. Gaunter 
2. Fraught 
3. Naughty 
4. Unearth 
5. Haunter 
6. Frenzy 
7. Jaunty 
8. Rehang 
9. Hunger 
10. Hanger 
11. Gather 
12. Naught 
13. Argent 
14. Father 
15. Graven 
16. Anther 
17. Hungry 
18. Gyrate 
19. Garnet 
20. Nature 
21. Hearty 
22. Tavern 
23. Earthy 
24. Gentry 
25. Rehung 
26. Vaguer 
27. Hunter 
28. Gantry 
29. Urgent 
30. Gurney 
31. Turfy 
32. Heart 
33. Jaunt 
34. Hyena 
35. Grave 
36. Fayer 
37. Faery 
38. Vegan 
39. After 
40. Grunt 
41. Grate 
42. Aunty 
43. Furze 
44. Nervy 
45. Auger 
46. Junta 
47. Gauze 
48. Great 
49. Ferny 
50. Argue 
51. Earth 
52. Avert 
53. Agent 
54. Gaunt 
55. Thane 
56. Graze 
57. Angry 
58. Aught 
59. Teary 
60. Graft 
61. Azure 
62. Grant 
63. Hater 
64. Gazer 
65. Yearn 
66. Hefty 
67. Tangy 
68. Tuner 
69. Gayer 
70. Hazer 
71. Huger 
72. Gauzy 
73. Runty 
74. Rangy 
75. Vaunt 
76. Anger 
77. Heavy 
78. Gravy 
79. Raven 
80. Entry 
81. Hertz 
82. Neath 
83. Vague 
84. Haven 
85. Range 
86. Haunt 
87. Tear 
88. Thru 
89. Year 
90. Rave 
91. They 
92. Aver 
93. Rant 
94. Tare 
95. Fate 
96. Rang 
97. Fang 
98. Tune 
99. Rage 
100. Tray 
101. Raze 
102. Tern 
103. Zany 
104. Faun 
105. Aery 
106. Urge 
107. Rent 
108. Gaze 
109. Near 
110. Yeah 
111. Navy 
112. Nave 
113. Turn 
114. Ante 
115. Gave 
116. Nary 
117. Arty 
118. Fret 
119. Jute 
120. Rhea 
121. Gate 
122. True 
123. Fare 
124. Tang 
125. Jean 
126. Yuan 
127. Gent 
128. Envy 
129. Feat 
130. Tyre 
131. Zeta 
132. Fray 
133. Hurt 
134. Rune 
135. Hunt 
136. Fern 
137. Ague 
138. Hung 
139. Turf 
140. Huge 
141. Thug 
142. Vary 
143. Very 
144. Fear 
145. Jury 
146. Runt 
147. Trey 
148. Heft 
149. Yang 
150. Heat 
151. Rung 
152. Ghat 
153. Then 
154. Futz 
155. Hazy 
156. Than 
157. Haze 
158. Gnat 
159. Raft 
160. Have 
161. Urea 
162. Earn 
163. Hear 
164. Hate 
165. Tarn 
166. Hart 
167. Hare 
168. Frat 
169. Hang 
170. Fury 
171. Haft 
172. Tzar 
173. Gyve 
174. Yurt 
175. Tuna 
176. Fart 
177. Gear 
178. Rate 
179. Faze 
180. Grey 
181. Fuze 
182. Feta 
183. Gray 
184. Neat 
185. Vent 
186. Yarn 
187. Vane 
188. Aunt 
189. Hut 
190. Jet 
191. Hay 
192. Gnu 
193. Nag 
194. Hey 
195. Van 
196. Yen 
197. Ran 
198. Rue 
199. Fay 
200. Hue 
201. Rye 
202. Rut 
203. Are 
204. Tag 
205. Nut 
206. Jag 
207. Tau 
208. Rug 
209. Hat 
210. Nay 
211. Rev 
212. Age 
213. Jug 
214. Hag 
215. Fur 
216. Fun 
217. Fry 
218. Nae 
219. Gay 
220. Gut 
221. Her 
222. Zen 
223. Fez 
224. Fey 
225. Vat 
226. Jay 
227. Yet 
228. Fen 
229. Jar 
230. Rag 
231. Rah 
232. Yea 
233. Ant 
234. Nth 
235. Net 
236. Get 
237. Fat 
238. Guy 
239. Tan 
240. Far 
241. Veg 
242. Fan 
243. Fag 
244. Vet 
245. Gun 
246. Eta 
247. Erg 
248. Era 
249. Urn 
250. Jut 
251. Hen 
252. Gar 
253. Eat 
254. Tar 
255. Ugh 
256. The 
257. Ear 
258. Ray 
259. Aye 
260. Ten 
261. Ref 
262. Rat 
263. Thy 
264. Tun 
265. Tug 
266. Try 
267. Ate 
268. Tea 
269. Run 
270. Art 
271. Hug 
272. Aft 
273. Any 
274. Nu 
275. Re 
276. En 
277. Ye 
278. Fa 
279. Ay 
280. An 
281. Ah 
282. At 
283. Ya 
284. He 
285. Eh 
286. Ha 
287. Uh 
288. A 

Check it out here

Can you solve it?

Source code

Rubik’s CubeImageCube is a program written by Lars Vandenbergh to show images of Rubik’s cube where you define what stickers to show.

I wrote a version of ImageCube that can also be used as a model of the Rubik’s Cube. I decided to give away the code, because that’s how cool I am. If you’re only into cubing and not into programming at all, you should just check out what I did with it at the algorithm database or my Rubik’s cube site.

And now for the source. If you have any comments, feel free to leave them here.

<?
/*
Cube object

Copyright (C) 2007 Michiel van der Blonk - <a href="mailto:blonkm@gmail.com">blonkm@gmail.com</a> - All Rights Reserved
Based on C++ code by Joël van Noort

This software is licensed as per the MIT License below:
MIT License: <a href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/*
 * To generate the imagecube sticker codes, this program first simulates the
 * cube, using a  string that represents the cube state. Every elementarty move
 * (UDLRFB) is then executed as five 4-cycles of stickers. Example: the
 * sticker permutations corresponding with the move U are:
 *
 * U: (53, 51, 45, 47) (50, 52, 48, 46) (2, 38, 29, 11)
 *     (1, 37, 28, 10,) (0, 36, 27, 9)
 */

// just for debugging
class Debug
{
 function out($s)
 {
  echo '<div class="debug">';
  print_r($s);
  echo '</div>';
 }
}

// post, get
class Page
{
 function get($s)
 {
  if (isset($_GET[$s]))
   return $_GET[$s];
  if (isset($_POST[$s]))
   return $_POST[$s];
 }
}

// handy functions
class Util
{
 //swaps two elements in an array
 function  swap(&amp;$var, $a, $b){

  $temp = $var[$a];
  $var[$a] = $var[$b];
  $var[$b] = $temp;
 }
}

// model of a Rubik's cube
class Cube
{
 var $stickers;
 var $mode;

 // constructor
 function Cube()
 {
  // initialize stickers
  $this->stickers = "rrrrrrrrrgggggggggwwwwwwwwwooooooooobbbbbbbbbyyyyyyyyy";
 }

 //this function uses swap function 3 times to make a 4-cycles of stickers:
 function execute_permutation($a, $b, $c, $d){
  Util::swap($this->stickers, $a, $b);
  Util::swap($this->stickers, $a, $c);
  Util::swap($this->stickers, $a, $d);
 }

 // perform a move and update stickers member variable
 // for multiple moves in the string $token the moves are done one by one
 function move($token)
 {
  $moveTransforms = array('u'=>'UEEE', 'd'=>'DE', 'f'=>'FS', 'b'=>'BSSS', 'l'=>'LM', 'r'=>'RMMM', 'x'=>'rLLL', 'y'=>'uDDD', 'z'=>'fBBB');

  // recursive calls to walk through the translated lowercase moves
  if (strlen($token) > 1)
   foreach (str_split($token) as $ch)
    $this->move($ch);

  switch($token)
  {
    case 'U':
    //one of the elementary move functions. Uses the execute_permutation function
    //five times to make five 4-cycles of stickers:
    $this->execute_permutation(53, 51, 45, 47); // top layer
    $this->execute_permutation(50, 52, 48, 46);
    $this->execute_permutation(2, 38, 29, 11);
    $this->execute_permutation(1, 37, 28, 10);
    $this->execute_permutation(0, 36, 27, 9);
    break;
    case 'D':
    $this->execute_permutation(20, 26, 24, 18);
    $this->execute_permutation(23, 25, 21, 19);
    $this->execute_permutation(8, 17, 35, 44);
    $this->execute_permutation(7, 16, 34, 43);
    $this->execute_permutation(6, 15, 33, 42);
    break;
    case 'F':
    $this->execute_permutation(2, 8, 6, 0);
    $this->execute_permutation(5, 7, 3, 1);
    $this->execute_permutation(9, 20, 44, 51);
    $this->execute_permutation(12, 19, 41, 52);
    $this->execute_permutation(15, 18, 38, 53);
    break;
    case 'B':
    $this->execute_permutation(29, 35, 33, 27);
    $this->execute_permutation(32, 34, 30, 28);
    $this->execute_permutation(47, 36, 24, 17);
    $this->execute_permutation(46, 39, 25, 14);
    $this->execute_permutation(45, 42, 26, 11);
    break;
    case 'R':
    $this->execute_permutation(11, 17, 15, 9);
    $this->execute_permutation(14, 16, 12, 10);
    $this->execute_permutation(2, 47, 33, 20);
    $this->execute_permutation(5, 50, 30, 23);
    $this->execute_permutation(8, 53, 27, 26);
    break;
    case 'L':
    $this->execute_permutation(38, 44, 42, 36);
    $this->execute_permutation(41, 43, 39, 37);
    $this->execute_permutation(0, 18, 35, 45);
    $this->execute_permutation(3, 21, 32, 48);
    $this->execute_permutation(6, 24, 29, 51);
    break;
   case 'M':
    $this->execute_permutation(4, 22, 31, 49 );
    $this->execute_permutation(1, 19, 34, 46 );
    $this->execute_permutation(7, 25, 28, 52 );
    break;
   case 'E':
    $this->execute_permutation(4, 13, 31, 40);
    $this->execute_permutation(5, 14, 32, 41);
    $this->execute_permutation(3, 12, 30, 39);
    break;
   case 'S':
    $this->execute_permutation(49, 13, 22, 40);
    $this->execute_permutation(50, 16, 21, 37);
    $this->execute_permutation(48, 10, 23, 43);
    break;
   case '':
    break;
   default:
    // u,d,f,b,l,r,x,y,z
    $this->move($moveTransforms[$token]);
  }
 }

 // clean from certain tokens
 // note: only cleans up space, minus, quote
  function clean($input)
  {
  if ($input=='')
   return $input;

  $tokens = " ()-\\'";
  $input_clean = '';
  $prevCh = '';
  // delete magic quotes
  $input = str_replace("\\\\", '', $input);
  foreach (str_split($input) as $ch)
  {
   if (!strpos($tokens, $ch))
       $input_clean .= $ch;

   // only add prime when right after a move token, e.g. R'
   // so skip R2' (becomes R2)
   if ($ch=='\\'' &amp;&amp; $prevCh!='2')
    $input_clean .= $ch;
   $prevCh = $ch;
  }
  return $input_clean;
 }

 // normalize algorithm
 // e.g. R2L'FD' becomes R2L3F1D3
 function normalize($input_clean){
  $temp = str_replace('\\'', '3', $input_clean);
  foreach (str_split($temp) as $ch)
  {
   // when both ch and prev are moves, insert a 1 between them
   // RL becomes R1L
   if (preg_match("/\\D/", $prevCh) &amp;&amp; preg_match("/\\D/", $ch))
    $alg_normal .= '1';
   $alg_normal .= $ch;
   $prevCh = $ch;
  }
  if (preg_match("/\\D/", $ch))
   $alg_normal .= '1';
  return $alg_normal;
 }

 // reverse moves
 // used to show an algorithm that solves a cube
 function  inverse($alg_normal){
  // split into separate moves
  $moves = str_split($alg_normal, 2);
  // reverse those
  $moves_inverse = array_reverse($moves);
  // back to string
  $alg_inverse = implode("", $moves_inverse);
  // inverse quantifiers
  $alg_inverse = str_replace('1', '#', $alg_inverse); // temp ch for 3
  $alg_inverse = str_replace('3', '1', $alg_inverse);
  $alg_inverse = str_replace('#', '3', $alg_inverse);

  return $alg_inverse;
 }

 // several predefined sticker modes
 function setMode($mode='')
 {
  if ($mode!='')
   $this->mode = $mode;

  switch (strtoupper($this->mode))
  {
   case "F2L":
    $this->stickers =  "xxxrrrrrrxxxggggggwwwwwwwwwxxxooooooxxxbbbbbbxxxxyxxxx";
    break;
   case "SHORTCUT":
    $this->stickers = "xxxxrrxrrxxxggxggxxwwwwwxwxxxxxoxxoxxxxxbxxbxxxxxyxxxx";
    break;
   case "OLL":
    $this->stickers = "xxxrrrrrrxxxggggggwwwwwwwwwxxxooooooxxxbbbbbbyyyyyyyyy";
    break;
   case "PLL":
    $this->stickers = "rrrrrrrrrgggggggggwwwwwwwwwooooooooobbbbbbbbbyyyyyyyyy";
    break;
  }
 }

 // execute an algorithm
 function  execute($alg, $mode='')
 {
  // prepare with a certain mode if given
  if ($preset!='')
   $this->setMode($mode);

  // walk through all moves in a normalized alg
  for ($i=0; $i < strlen($alg); $i+=2)
  {
   // define operation (move) and quantifier
   $op = $alg[$i];
   $q = $alg[$i+1];
   // move a face n times
   foreach (range(1, $q) as $value)
    $this->move($op);
  }
  return $this->stickers;
 }

 // applet sticker for RubikPlayer are
 // the same as the stickers member variable
 function toAppletStickers()
 {
  return $this->stickers;
 }

 // return only visible faces for imagecube
 // i.e. U, F, R
 function toImageCubeStickers()
 {
  // split into 9 faces
  $faces = str_split($this->stickers, 9);

  // create string for up, right, front
  $upFace = $faces[5];
  $frontFace = $faces[0];
  $rightFace = $faces[1];
  $imageStickers = $upFace . $frontFace . $rightFace;

  return $imageStickers ;
 }

 // perform an algorithm given
 // done in the steps
 // 1. clean up
 // 2. normalize (add quantifiers)
 // 3. optionally inverse
 // 4. execute
 function performAlg($input, $inverse = false)
 {
    $input_clean = "";
    $alg_normal = "";
    $alg_inverse = "";

  // clean input leaves only the moves
  $alg = $this->clean($input);

  // process to get normalized alg (e.g. R2F1L3)
  $alg = $this->normalize($alg);

  // process inverse of alg
  if ($inverse)
   $alg = $this->inverse($alg);

  // perform inverse on the stickers
  $this->stickers = $this->execute($alg);
 }
}
?>

rubik’s cube tutorial

My very own website. I can’t believe I didn’t even have this in delicious. LOL. Anyway, here it is, full of programs, tutorials, algorithms, you name it. I also have it under the domain name rubikscubetutorial.com, although I notice that vanderblonk.com gets a lot more hits.

Don’t forget to check out my algorithm database if you’re into speedcubing, or any cubing at all actually.

Rubik’s cube in local press

I was very surprised when I opened up my local (Aruban) newspaper and saw the heading “Prince: Solve the Rubik’s cube.” It says the prince of the Netherlands, Willem Alexander (so not TAFKAP) thinks the problem of world wide water shortage is one that resembles a Rubik’s cube, and we need to fix it.

Here’s a rough translation:

Guatemala-cit — Last Sunday, Prince Willem-Alexander of the Netherlands, in the yearly meeting of the inter American Development Bank in Guatemala City, called all 47 countries as a member of this organisation to make progress with the millenium targets of the United Nations.

One third of the 550 million people in these countries do not have access to clean water. and over 125 million people have no sewer system. According to the prince the millenium targets of the UN resemble the Rubik’s cube, an invention of Erno Rubik, which was a famous brain teaser some 30 years ago that was very popular.

One turn in the right direction in one area (e.g. reducing poverty) can have a direct negative influence on another one (like the environment). “That’s why we need cooperation on all areas, so that one side doesn’t take what the other gives. Lets start turning this cube as soon as possible and get all the colors in the right place”, says the prince.

As an example of the problems he mentions the large cultivation of sheer sugar for the production of the bio-fuel ethanol. It’s great for the environmen, but it costs a tremendous amount of water. We need to search for cultivation methods that require less water, says the future king.

Willem Alexander travels all over the world to lobby for his cause. Last week he was in Tokyo for a consultation with the Japanese government. Next Thursday he will speak in Rome on World Water Day.

If he doesn’t know how to solve it he can visit my site, and learn how to solve the Rubik’s cube. Anyway, I thought this was a nice analogy, and one that could very well fit into every day life. Usually the Rubik’s cube is only used as an analogy to a difficult problem, or even an unsolvable problem, which, as we know, is hardly the case.
So maybe we can help solve world poverty by using Rubik’s cube algorithms?

Anyway, here’s the article. Unfortunately no link to an online version, since Amigoe only provides those as a paid service.
Prince says we should solve the cube

Website update

my “logo”

The last couple of weeks I have been working hard updating my website www.vanderblonk.com. It’s been fun, but I’m hardly ready, there is so much more to do.

Let me give you a little breakdown of what has been done and what you can expect in the (near) future:

  • There is a new home page
  • The applet has already been greatly improved, e.g. you can now enter any parameters of the applet in the url.
  • I placed google ads. I know not everyone likes ads, but I think everyone mature enough in our field (speedcubing, programming) knows how to disable them. I get a lot of juice from wikipedia of which I am grateful.

And soon:

  • I will make some help text available for all the new awesome options (which I am not revealing yet)
  • Not very useful to you, but I will integrate the style of the home page in all of my pages, it’s still a collection of pages, and not a real site this way. Let me know if you like it.

I bet this guy could memorize all LL cube positions

Watch it and remind yourself to close your mouth when you’re done.

Some pictures of WC 2005

I managed to save some pictures although my camera has now died a silent death. My friends Jasmine and Peter promised me some more pictures, and for some I will be in them.

Houston, we have a visual:

Pictures of Disney at WC2005

Follow

Get every new post delivered to your Inbox.