Berlomba di Sekitar Lintasan

24

Saya mencari pembalap tercepat. Tunjukkan lap tercepat Anda di sekitar trek 18x14 yang ditunjukkan di bawah ini.

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

Tugas Anda adalah memindahkan mobil di bawah lintasan sekali di semua posisi yang memungkinkan.

 _
| |
|_|

 /\
/ /
\/

 __
|__|

/\
\ \
 \/

Mobil dapat melaju dalam 3 ruang berturut-turut sebelum berbelok. Ini adalah contoh dari bagaimana putaran seharusnya terlihat.

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

Aturan

  • Output harus menunjukkan mobil di semua posisi yang memungkinkan. 3 posisi di masing-masing dari 8 bagian trek berarti ada 24 posisi yang mungkin untuk ditampilkan.
  • Posisi mobil harus ditunjukkan secara berurutan. (Anda tidak dapat berteleportasi ke bagian trek yang lain!)
  • Posisi dan arah awal (searah jarum jam / berlawanan arah jarum jam) tidak penting.
  • Output dapat dalam format teks apa pun yang masuk akal.
  • Tidak ada input
  • Aturan standar kode-golf. Semakin sedikit byte kode Anda, semakin cepat mobil Anda berjalan.
aoemica
sumber
Saya tidak menerima atau tidak menggunakan input?
Veskah
@Veskah Benar. Mengedit pos untuk memasukkan ini.
aoemica
2
Tantangan pertama yang sangat bagus!
Stewie Griffin

Jawaban:

4

Kanvas , 131 byte

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

Coba di sini!

dzaima
sumber
6

JavaScript (ES6), 371 byte

Putar searah jarum jam. Mungkin masih golf.

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

Cobalah online!

Versi animasi

Kurang golf

// 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
sumber
3

Python 2 , 641 639 592 576 byte

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'))

Cobalah online!

  • -2 byte, terima kasih kepada Kevin Cruijssen
  • -30 byte, terima kasih untuk Mnemonic
  • -16 byte, terima kasih kepada Jonathan
TFeld
sumber
Mungkin 578 byte .
Jonathan Frech
[1,-1][i>12]-> 2*(i<13)-1.
Jonathan Frech
@JonathanFrech Terima kasih :)
TFeld