Portal Maze Shortest Path Your goal is to write a program that creates a random 10x10 map using 0, 1, and 2, and finds the shortest path from top-left to bottom-right, assuming that:

0 represents a grass field: anyone can walk on it;
1 represents a wall: you cannot cross it;
2 represents a portal: when entering a portal, you can move to any other portal in the map.

Specs:


The top-left element and the bottom-right one must be 0;  
When creating the random map, every field should have 60% chance of being a 0, 30% of being a 1 and 10% of being a 2;  
You can move in any adjacent field (even diagonal ones);  
Your program should output the map and the number of steps of the shortest path;
If there isn't a valid path that leads to the bottom-right field, your program should output the map only;
You can use any resource you'd like to;
Shortest code wins.


Calculating steps:
A step is an actual movement; every time you change field, you increment the counter.

Output:

0000100200
0100100010
1000000111
0002001000
1111100020
0001111111
0001001000
0020001111
1100110000
0000020100

9
Mathematica (344)
Bonus: highlighting of the path
n = 10;
m = RandomChoice[{6, 3, 1} -&gt; {0, 1, 2}, {n, n}];
m[[1, 1]] = m[[n, n]] = 0;

p = FindShortestPath[Graph@DeleteDuplicates@Join[Cases[#, Rule[{ij__}, {k_, l_}] /; 
      0 &lt; k &lt;= n &amp;&amp; 0 &lt; l &lt;= n &amp;&amp; m[[ij]] != 1 &amp;&amp; m[[k, l]] != 1] &amp;@
   Flatten@Table[{i, j} -&gt; {i, j} + d, {i, n}, {j, n}, {d, Tuples[{-1, 0, 1}, 2]}], 
  Rule @@@ Tuples[Position[m, 2], 2]], {1, 1}, {n, n}];

Grid@MapAt[Style[#, Red] &amp;, m, p]
If[# &gt; 0, #-1] &amp;@Length[p]


I create the graph of all possible movies to neighbor vertices and add all possible &quot;teleports&quot;.