์ด ๋์ ์ ๋ชฉํ ๋ ์ฃผ์ด์ง ๊ณผ์ ์ ์๋ฃํ๋ ๋ฐ ํ์ํ ์ต์์ ํ์ ์ ๋ฐํ ํ๋ ํ๋ก๊ทธ๋จ์ด๋ ๊ธฐ๋ฅ ์ ์์ฑ ํ๋ ๊ฒ ์ ๋๋ค.
์ ๋ ฅ
- ์ฝ์ค์ ๋ ์ด์์์ ์ํ๋ ๋ฐฉ์๊ณผ ํ์์ผ๋ก ์ ๋ฌํ ์ ์์ต๋๋ค. (์ฝ์์์ ์ฝ๊ธฐ, ์ ๋ ฅ ๋งค๊ฐ ๋ณ์๋ก ์ ๋ฌ, ํ์ผ ๋๋ ๊ธฐํ ์ฌ๋ฌ ์ค ๋ฌธ์์ด, ๋ฌธ์์ด ๋ฐฐ์ด, 2 ์ฐจ์ ๋ฌธ์ / ๋ฐ์ดํธ ๋ฐฐ์ด์์ ์ฝ์)
 - ๊ณต์ ์์ ์์น์ ๊ตฌ๋ฉ๋ ์ ๋ ฅ์ผ๋ก ์ ๋ฌํ ์ ์์ผ๋ฉฐ ์ ๋ ฅ์์ ํ์ฑ ํ ํ์๊ฐ ์์ต๋๋ค. ํ ์คํธ ์ฌ๋ก์์๋ ์ค์  ์์น์ ํผ๋๋์ง ์๋๋ก ์ฝ์ค์ ํฌํจ๋์ด ์์ต๋๋ค.
 - ์ ๋ ฅ ๋ฌธ์๊ฐ ์ฌ์ ํ ๊ณ ์ ๋ฌธ์ (์ : ์ธ์ ๊ฐ๋ฅํ ASCII ๋ฌธ์)๋ก ์ธ์๋๋ ํ ์ ๋ ฅ ๋ฌธ์๋ฅผ ๋ค๋ฅธ ๊ฒ์ผ๋ก ๋ค์ ๋งตํ ํ ์ ์์ต๋๋ค.
 
์ฐ์ถ
- ํ๋ก๊ทธ๋จ์ ํ๋ช ํ ํ์ (๊ฒฐ๊ณผ๋ฅผ ์ค๋ช ํ๋ ๋ฌธ์์ด, ์ ์, ๋ถ๋ ๋๋ ํ์ด์ฟ )์ผ๋ก ์ ๋ ฅ์ผ๋ก ์ ๋ฌ ๋ ์ฝ์ค์ ๋ํด ์ต์  ์ ์ (ํ์ ๋๋ฌํ๋ ๋ฐ ํ์ํ ์ต์ ์คํธ๋ผ์ดํฌ)๋ฅผ ๋ฐํํด์ผํฉ๋๋ค.
 - ๊ฐ์ข๋ฅผ ์ด๊ธธ ์์๋ ๊ฒฝ์ฐ ๊ท๊ตญ 
-1(๋๋ ์ ํ ๊ฐ๋ฅํ ๋ค๋ฅธ ๊ฐ๋ฐ ํ ๊ฐ์น๋ ์ด๊ธธ ์์๋ ๊ฐ์ข์ ๋ํด์๋ ๋ฐํ๋์ง ์์). 
์:
์ด ์์ ์์ ์์น๋ 0 ๊ธฐ๋ฐ, X / Y, ์ผ์ชฝ์์ ์ค๋ฅธ์ชฝ์ผ๋ก, ์์์ ์๋๋ก ํ๊ธฐ๋์ง๋ง ๊ฒฐ๊ณผ๋ ํ์์ ๋ ๋ฆฝ์ ์ด๋ฏ๋ก ์ํ๋ ํ์์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ ๋ ฅ:
###########
#     ....#
#      ...#
#  ~    . #
# ~~~   . #
# ~~~~    #
# ~~~~    #
# ~~~~  o #
# ~~~~    #
#@~~~~    #
###########
Ball (Start-Position): 1/9
Hole (End-Position):   8/7
์ฐ์ถ:
8
๊ท์น๊ณผ ํ๋
์ด ๊ณผ์ ์ ๋ค์๊ณผ ๊ฐ์ ํ๋๋ก ๊ตฌ์ฑ ๋ ์ ์์ต๋๋ค.
'@'๊ณต -์ฝ์ค ์์'o'๊ตฌ๋ฉ -์ฝ์ค์ ๋ชฉํ'#'๋ฒฝ -๋ฒฝ์ ๋ฟ์ผ๋ฉด ๊ณต์ด ๋ฉ ์ถฅ๋ ๋ค'~'๋ฌผ -ํผํด์ผํฉ๋๋ค'.'๋ชจ๋ -๊ณต์ด ๋ชจ๋ ์์์ ์ฆ์ ๋ฉ ์ถฅ๋ ๋ค' '์ผ์ -๊ณต์ด ๋ฌด์ธ๊ฐ์ ๋ฟ์ ๋๊น์ง ๊ณ์ ๋ฏธ๋๋ฌ์ง๋๋ค.
๊ฒ์์ ๊ธฐ๋ณธ ๊ท์น ๋ฐ ์ ํ ์ฌํญ :
- ๊ณต์ ๋๊ฐ์ ์ผ๋ก, ์ผ์ชฝ, ์ค๋ฅธ์ชฝ, ์์๋๋ก ์์ง์ผ ์ ์์ต๋๋ค.
 - ๊ณต์ ๋ฌผ ์์์, ๋ฒฝ ์์์, ๋ชจ๋ ์์์ ๊ทธ๋ฆฌ๊ณ  ๊ตฌ๋ฉ์์ ๋ฉ์ถ์ง ์์ต๋๋ค.
- ๋ฌผ ์์ผ๋ก์ ์ท์ด ์ ํจํ์ง ์๊ฑฐ๋ ๋ถ๊ฐ๋ฅํฉ๋๋ค
 - ๊ณต์ ์ผ์ ์์์๋ ๊ฒ์ฒ๋ผ ๊ฑด๋ ๋ฐ์ง ์๊ณ ๊ตฌ๋ฉ์ ๋จ์์๊ฒ๋ฉ๋๋ค.
 
 - ์ฝ์ค๋ ํญ์ ์ง์ฌ๊ฐํ์ ๋๋ค.
 - ์ด ์ฝ์ค๋ ํญ์ ๋ฌผ์ด๋ ๋ฒฝ์ผ๋ก ๋๋ฌ์ธ์ฌ ์์ต๋๋ค (๊ฒฝ๊ณ ํ์ธ ํ์ ์์).
 - ํญ์ ์ ํํ ํ๋์ ๊ณต๊ณผ ํ๋์ ๊ตฌ๋ฉ์ด ์์ต๋๋ค.
 - ๋ชจ๋ ์ฝ์ค๊ฐ ์ด๊ธธ ์์๋ ๊ฒ์ ์๋๋๋ค.
 - ๋์ผํ (๊ฐ์ฅ ๋ฎ์) ์ ์๋ฅผ ์ป๋ ์ฌ๋ฌ ๊ฒฝ๋ก๊ฐ์์ ์ ์์ต๋๋ค.
 
ํ์ ๊ณผ ์น๋ฆฌ ์กฐ๊ฑด
- ํ์ค ํ์  ์ ๊ธ์ง๋์ด ์์ต๋๋ค
 - ํ๋ก๊ทธ๋จ์ ์ข ๋ฃ๋์ด์ผํฉ๋๋ค
 - ์ถ๊ฐ ๊ท์น์ ๊ตฌ์ฑ ํ ์ ์์ต๋๋ค (๊ณต์ ๋๋ฌด ์ธ๊ฒ ์น๋ฉด ๋ฌผ ์๋ก ๊ฑด๋ ๋ฐ๊ฑฐ๋ ๋ฒฝ์์ ํ์ด ๋์ค๊ฑฐ๋ ๋ชจ๋๋ฐญ ์๋ก ๋ฐ์ด ์ค๋ฆ, ๋ชจ์๋ฆฌ ์ฃผ์์ ๊ณก์ ๋ฑ)
 - ์ด๊ฒ์ code-golf ์ด๋ฏ๋ก ๋ฌธ์ ์๊ฐ ๊ฐ์ฅ ์ ์ ์๋ฃจ์ ์ด ์น๋ฆฌํฉ๋๋ค.
 - ์๋ฃจ์ ์ ์ ๊ณต๋ ๋ชจ๋ ํ ์คํธ ์ฌ๋ก๋ฅผ ์ฒ๋ฆฌ ํ ์ โโ์์ด์ผํฉ๋๋ค. ์ฌ์ฉ ๋ ์ธ์ด์ ์ ํ์ผ๋ก ์ธํด ์ด๊ฒ์ด ๋ถ๊ฐ๋ฅํ ๊ฒฝ์ฐ ๋ต๋ณ์์ด๋ฅผ ์ง์ ํ์ญ์์ค.
 
ํ ์คํธ ์ฌ๋ก
์ฝ์ค # 1 (2 ํ์ )
####
# @#
#o~#
####
์ฝ์ค # 2 (๋ถ๊ฐ๋ฅ)
#####
#@  #
# o #
#   #
#####
์ฝ์ค # 3 (3 ํ)
~~~
~@~
~.~
~ ~
~ ~
~ ~
~ ~
~.~
~o~
~~~
์ฝ์ค # 4 (2 ํ์ )
#########
#~~~~~~~#
#~~~@~~~#
##  .  ##
#~ ~ ~ ~#
#~. o .~#
#~~~ ~~~#
#~~~~~~~#
#########
์ฝ์ค # 5 (๋ถ๊ฐ๋ฅ)
~~~~~~~
~...  ~
~.@.~.~
~...  ~
~ ~ ~.~
~ . .o~
~~~~~~~
๋ ๋ง์ ํ ์คํธ ์ฌ๋ก :
๋ต๋ณ
์๋ฐ ์คํฌ๋ฆฝํธ (ES6), 174 ๋ฐ์ดํธ
curling currying syntax ์์ ์
๋ ฅ์ ๋ฐ์ต๋๋ค ([x, y])(a). ์ฌ๊ธฐ์ x ์ y ๋ ์์ ์์น์ 0- ์ธ๋ฑ์ค ์ขํ์ด๊ณ  a [] ๋ 0= ice, 1= wall, 2= sand, 3= hole ๋ฐ 4= water๋ฅผ ๊ฐ๋ ์ ์์ ํ๋ ฌ์
๋๋ค.
0์๋ฃจ์
์ด์๋ ๊ฒฝ์ฐ ๋ฐํ ํฉ๋๋ค.
p=>a=>(r=F=([x,y],n,R=a[y],c=R[x])=>R[c&(R[x]=4)|n>=r||[-1,0,1,2].map(d=>(g=_=>(k=a[v=Y,Y+=d%2][h=X,X+=~-d%2])||g())(X=x,Y=y)>3?0:k>2?r=-~n:F(k>1?[X,Y]:[h,v],-~n)),x]=c)(p)|r
์จ๋ผ์ธ์ผ๋ก ์ฌ์ฉํด๋ณด์ญ์์ค!
๋๊ธ
p => a => (                       // given the starting position p[] and the matrix a[]
  r =                             // r = best result, initialized to a non-numeric value
  F = (                           // F = recursive function taking:
    [x, y],                       //   (x, y) = current position
    n,                            //   n = number of shots, initially undefined
    R = a[y],                     //   R = current row in the matrix
    c = R[x]                      //   c = value of the current cell
  ) =>                            //
    R[                            // this will update R[x] once the inner code is executed
      c & (R[x] = 4) |            //   set the current cell to 4 (water); abort if it was
      n >= r ||                   //   already set to 4 or n is greater than or equal to r
      [-1, 0, 1, 2].map(d =>      //   otherwise, for each direction d:
        (g = _ => (               //     g = recursive function performing the shot by
          k = a[                  //         saving a backup (h, v) of (X, Y)
            v = Y, Y += d % 2][   //         and updating (X, Y) until we reach a cell
            h = X, X += ~-d % 2]) //         whose value k is not 0 (ice)
          || g()                  //   
        )(X = x, Y = y)           //     initial call to g() with (X, Y) = (x, y)
        > 3 ?                     //     if k = 4 (water -> fail):
          0                       //       abort immediately
        :                         //     else:
          k > 2 ?                 //       if k = 3 (hole -> success):
            r = -~n               //         set r to n + 1
          :                       //       else:
            F(                    //         do a recursive call to F():
              k > 1 ?             //           if k = 2 (sand):
                [X, Y]            //             start the next shots from the last cell
              :                   //           else (wall):
                [h, v],           //             start from the last ice cell
              -~n                 //           increment the number of shots
            )                     //         end of recursive call
      ), x                        //   end of map(); x = actual index used to access R[]
    ] = c                         // restore the value of the current cell to c
)(p) | r                          // initial call to F() at the starting position; return r
๋ต๋ณ
ํ์ด์ฌ 3 , 273 ๋ฐ์ดํธ
def p(g,c,d,k=0):
	while 1>k:c+=d;k=g.get(c,9)
	return-(k==2)or c-d*(k==3)
def f(g):
	c={q for q in g if g.get(q,9)>4};I=0;s=[c]
	while all(g.get(q,9)-4for q in c):
		c={k for k in{p(g,k,1j**q)for k in c for q in range(4)}if-~k}
		if c in s:return-1
		s+=[c];I+=1
	return I
์จ๋ผ์ธ์ผ๋ก ์ฌ์ฉํด๋ณด์ญ์์ค!
ovs ๋๋ถ์ -41 ๋ฐ์ดํธ-Jonathan 
Frech ๋๋ถ์ -1 ๋ฐ์ดํธ
๋ต๋ณ
C #, 461 418 ๋ฐ์ดํธ
์ด๊ฒ์์ด ๋์ ์ (ํฌ๋ง์ ์ผ๋ก) ๋ถํ์ํค๊ธฐ์ํ ๋น ๊ฒฝ์์  ์ฐธ์กฐ ๊ตฌํ์ ๋๋ค.
์ผ๋น ํฌ๋ฃจ์ด ์ผ ๊ณจํ
int P(string[]C){int w=C[0].Length,i=0,l=c.Length;var c=string.Join("",C);var h=new int[l];for(var n=new List<int>();i<l;n.Add(i++))h[i]=c[i]!='@'?int.MaxValue:0;for(i=1;;i++){var t=n;n=new List<int>();foreach(int x in t){foreach(int d in new[]{-1,1,-w,w}){for(int j=x+d;c[j]==' ';j+=d);if(c[j]=='#'&h[j-d]>s){h[j-d]=s;n.Add(j-d);}if(c[j]=='.'&h[j]>s){h[j]=s;n.Add(j);}if(c[j]=='o')return s;}}if(n.Count<1)return -1;}}
์ธ ๊ณจํ
int IceGolf(string[] course)
{
    // Width of the course
    int w = course[0].Length;
    // Course as single string
    var c = string.Join("", course);
    // Array of hits per field
    var hits = new int[c.Length];
    // Fields to continue from
    var nextRound = new List<int>();
    // Initialize hits
    for (int i = 0; i < hits.Length; i++)
    {
        if (c[i] != '@')
            // All fields start with a high value
            hits[i] = Int32.MaxValue;
        else
        {
            // Puck field starts with 0
            hits[i] = 0;
            nextRound.Add(i);
        }
    }
    for (int s = 1; ; s++)
    {
        // clear the fields that will be used in the next iteration
        var thisRound = nextRound;
        nextRound = new List<int>();
        foreach (int i in thisRound)
        {
            // test all 4 directions
            foreach (int d in new[] { -1, 1, -w, w })
            {
                int j = i+d;
                // ICE - slide along
                while (c[j] == ' ')
                    j += d;
                // WALL - stop on previous field
                if (c[j] == '#' && hits[j-d] > s)
                {
                    hits[j-d] = s;
                    nextRound.Add(j-d);
                }
                // SAND - stop
                if (c[j] == '.' && hits[j] > s)
                {
                    hits[j] = s;
                    nextRound.Add(j);
                }
                // HOLE return strikes
                if (c[j] == 'o')
                    return s;
            }
        }
        // No possible path found
        if (nextRound.Count == 0)
            return -1;
    }
}
