Race Around the Track

24

2

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.

aoemica

Posted 2018-04-19T01:21:05.137

Reputation: 793

I take it no or non-usable input? – Veskah – 2018-04-19T03:24:46.233

@Veskah Correct. Edited the post to include this. – aoemica – 2018-04-19T03:51:05.000

2Very nice first challenge! – Stewie Griffin – 2018-04-19T05:23:04.733

Answers

4

Canvas, 131 bytes

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

Try it here!

dzaima

Posted 2018-04-19T01:21:05.137

Reputation: 19 048

6

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

Arnauld

Posted 2018-04-19T01:21:05.137

Reputation: 111 334

3

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

TFeld

Posted 2018-04-19T01:21:05.137

Reputation: 19 246

609 bytes – None – 2018-04-19T15:18:34.193

Possibly 578 bytes.

– Jonathan Frech – 2018-04-20T19:48:33.723

[1,-1][i>12] -> 2*(i<13)-1. – Jonathan Frech – 2018-04-20T19:50:43.810

@JonathanFrech Thanks :) – TFeld – 2018-04-23T06:50:46.003