24
\$\begingroup\$

I'm looking to find the fastest racer around. Show me your fastest lap around this 18x14 track shown below.

      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/

Your job is to move the car below around the track once in all possible positions.

 _
| |
|_|

 /\
/ /
\/

 __
|__|

/\
\ \
 \/

The car can drive in 3 spaces in a row before turning. Here's an example of what a lap should look like.

      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /_  /      \   \
|| ||        |   |
||_||        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
| _ |        |   |
|| ||        |   |
||_||        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
| _ |        |   |
|| ||        |   |
||_||        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
| /\|        |   |
 \\ \\      /   /
  \\/ \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \ /\\      /   /
  \\ \\____/   /
   \\/        /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \ /\\____/   /
   \\ \       /
    \\/      /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \   __     /
    \ |__|   /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \    __    /
    \  |__|  /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \     __   /
    \   |__| /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____//\ /
   \       / //
    \      \//
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      //\ /
  \   \____// //
   \        \//
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |/\ |
 \   \      // //
  \   \____/ \//
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        | _ |
|   |        || ||
|   |        ||_||
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        | _ |
|   |        || ||
|   |        ||_||
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \   \
 /   /      \  _\
|   |        || ||
|   |        ||_||
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  /   /    \ /\\
 /   /      \\ \\
|   |        |\/ |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____ /\\
  /   /    \\ \\
 /   /      \\/ \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /      /\\
   /   ____\ \\
  /   /    \\/ \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /   __ \
    /   |__| \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /  __  \
    /  |__|  \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     / __   \
    / |__|   \
   /   ____   \
  /   /    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    //\      \
   // /____   \
  / \//    \   \
 /   /      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   //\ ____   \
  // //    \   \
 / \//      \   \
|   |        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/
      ______
     /      \
    /        \
   /   ____   \
  //\ /    \   \
 // //      \   \
| \/|        |   |
|   |        |   |
|   |        |   |
|   |        |   |
 \   \      /   /
  \   \____/   /
   \          /
    \        /
     \______/

Rules

  • The output should show the car in all possible positions. 3 positions in each of the 8 sections of the track mean there are 24 possible positions to show.
  • The car positions must be shown in sequence. (You can't teleport to another part of the track!)
  • The starting position and direction (clockwise/counter clockwise) are not important.
  • Output can be in any reasonable format for text.
  • No input.
  • Standard code-golf rules. The fewer bytes your code has, the faster your car runs.
\$\endgroup\$
3
  • \$\begingroup\$ I take it no or non-usable input? \$\endgroup\$ – Veskah Apr 19 '18 at 3:24
  • \$\begingroup\$ @Veskah Correct. Edited the post to include this. \$\endgroup\$ – aoemica Apr 19 '18 at 3:51
  • 2
    \$\begingroup\$ Very nice first challenge! \$\endgroup\$ – Stewie Griffin Apr 19 '18 at 5:23
4
\$\begingroup\$

Canvas, 131 bytes

{↔]
ø5/22╋___71╋__84╋|¶|17╋|¶|57╋2/65╋╬
3[⁵ __¶|__|²6+2╋]
3[⁵ _¶| |¶|_|25²+╋]
3[⁵ /\¶/ /¶\/6²-2²+╋]
⁷⁸⇵{↕]∔⁶{↕]∔⁸{↕↔]∔⁷⇵⁴∔⁸⇵⁴∔⁶⁴∔⁸∔

Try it here!

\$\endgroup\$
6
\$\begingroup\$

JavaScript (ES6), 371 bytes

Rotates clockwise. Probably still golfable.

f=(i=24,A=[])=>i--?A.map(r=>r.join``,g=(s,x,y)=>[...s].map(c=>(j=c.charCodeAt(),d='12221',m=k=>(x-=~-d[j&7],y-=~-d[j-2&7],k--)&&((A[y]=A[y]||Array(18).fill` `)[x]='|/_\\'[j&3],k&&m(k)))(j/8&7)),g('voF`ir@kBdm',5,1),g('fWF`Qb@SBdU',6,4),g(['NFPJAT','MDWFI@S','VFHRAL','UDOFQ@K'][i/3&3],'0x'+'111123678ABCEEECBA876321'[i],'0x'+'678BCDDDDEDC876654222567'[i])).join`
`+f(i):A

Try it online!

Animated version

f=(i=24,A=[])=>i--?A.map(r=>r.join``,g=(s,x,y)=>[...s].map(c=>(j=c.charCodeAt(),d='12221',m=k=>(x-=~-d[j&7],y-=~-d[j-2&7],k--)&&((A[y]=A[y]||Array(18).fill` `)[x]='|/_\\'[j&3],k&&m(k)))(j/8&7)),g('voF`ir@kBdm',5,1),g('fWF`Qb@SBdU',6,4),g(['NFPJAT','MDWFI@S','VFHRAL','UDOFQ@K'][i/3&3],'0x'+'111123678ABCEEECBA876321'[i],'0x'+'678BCDDDDEDC876654222567'[i])).join`
`+f(i):A

F = 0;
setInterval(_ => O.textContent = f().substr((F++ % 24) * 285 + 1, 285), 200)
<pre id=O style="font-size:9px"></pre>

Less golfed

// i = frame counter, A[] = drawing matrix
f = (i = 24, A = []) =>
  i-- ?
    A.map(r =>
      r.join``,
      // g() draws the shape described by s, starting at (x, y)
      g = (s, x, y) =>
        [...s].map(c => (
          // j holds the direction in bits 0-2 and the length in bits 3-5
          // a length of 0 means 'move without drawing'
          j = c.charCodeAt(),
          d = '12221',
          // m() either draws a line or just moves the pen by 1 step
          m = k => (
            x -= ~-d[j & 7],
            y -= ~-d[j - 2 & 7],
            k--
          ) && (
            (A[y] = A[y] || Array(18).fill` `)[x] = '|/_\\'[j & 3],
            k && m(k)
          )
        )(j / 8 & 7)),
      // draw the outer boundary of the track
      g('voF`ir@kBdm', 5, 1),
      // draw the inner boundary of the track
      g('fWF`Qb@SBdU', 6, 4),
      // draw the car, using the correct shape for this frame and hard-coded coordinates
      g(['NFPJAT', 'MDWFI@S', 'VFHRAL', 'UDOFQ@K'][i / 3 & 3],
        '0x'+'111123678ABCEEECBA876321'[i],
        '0x'+'678BCDDDDEDC876654222567'[i]
      )
    ).join`\n` + f(i)
  :
    A
\$\endgroup\$
3
\$\begingroup\$

Python 2, 641 639 592 576 bytes

for i in range(24):
 t='s  ______s  Xs / 642  \s Xs/875310  \sX   /:;8____   \   X  /<9:/s\   \  X />=</s  \   \ X|A@?|ss|   |X|BCB|ss|   |X|DED|ss|   |X|FHG|ss|   |X \ILK\s  /   / X  \KJM\____/   /  X   \MNPRTVs/   Xs\POQSUW  /sXs \______/s '.replace('s',4*' ')
 for c,C in[zip([chr(x)for x in range(48,88)],' '*ord(s)+r+' '*40)for s,r in zip("\0\n	!",'|____|?| ____|?\/\/?/\/\ ?\  / //\ ?_| ||_?_ | |_?_| ||_?\/\/\ ?\/\/?/  \ /\ ?| ____|?| ____|'.split('?'))][abs(12-i)]+zip('\/!','!\/')*(i>12):t=t.replace(c,C)
 print'\n'.join(l[::2*(i<13)-1]for l in t.split('X'))

Try it online!

  • -2 bytes, thanks to Kevin Cruijssen
  • -30 bytes, thanks to Mnemonic
  • -16 bytes, thanks to Jonathan
\$\endgroup\$
4
  • \$\begingroup\$ 609 bytes \$\endgroup\$ – user48543 Apr 19 '18 at 15:18
  • \$\begingroup\$ Possibly 578 bytes. \$\endgroup\$ – Jonathan Frech Apr 20 '18 at 19:48
  • \$\begingroup\$ [1,-1][i>12] -> 2*(i<13)-1. \$\endgroup\$ – Jonathan Frech Apr 20 '18 at 19:50
  • \$\begingroup\$ @JonathanFrech Thanks :) \$\endgroup\$ – TFeld Apr 23 '18 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.