15
\$\begingroup\$

As in, the 5 speed transmission from the original VW Golf GTI.

Print the transmission pattern in as few bytes as possible.

Yes I know this isn't what it actually looks like but the GTI 5 speed shift knob pattern is a lot worse.

1  3  5
|  |  |
|--|--|
|  |  |
2  4  R
\$\endgroup\$
7
  • \$\begingroup\$ Is extra whitespace that doesn't affect the image's presentation acceptable? \$\endgroup\$
    – noodle man
    Nov 18 at 0:36
  • \$\begingroup\$ @noodleman A trailing newline is generally acceptable \$\endgroup\$ Nov 18 at 1:02
  • \$\begingroup\$ Sorry, my comment wasn't clear enough, I'm referring to having e.g. trailing whitespace on each line, or a consistent amount of leading whitespace on each line. Many ascii-art challenges allow this so I was wondering if it's applicable here. \$\endgroup\$
    – noodle man
    Nov 18 at 1:06
  • \$\begingroup\$ yeah extra whitespace is fine sure \$\endgroup\$ Nov 18 at 6:20
  • 1
    \$\begingroup\$ “the GTI 5 speed shift pattern looks a lot worse” citation-needed \$\endgroup\$
    – noodle man
    Nov 20 at 17:35

13 Answers 13

9
\$\begingroup\$

Japt, 25 bytes

7Ç%3?-:°U+'|³+°U÷û Õr6'R

Test it

Japt beatsties with Jelly! The Jelly submission has improved a lot, but unfortunately I don’t think this solution can.

I'll explain this part by part as it's a bit hard to visualize without seeing the in-between results.

7Ç%3?-:°U+'|³+°U÷­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏‏​⁡⁠⁡‌⁢⁤​‎‎⁡⁠⁢⁡⁡‏‏​⁡⁠⁡‌⁣⁡​‎‎⁡⁠⁢⁡⁢‏‏​⁡⁠⁡‌­
7Ç                  # ‎⁡For each number from 0 to 6:
  %3                # ‎⁢  Take it modulo 3.
    ?-              # ‎⁣  If it's truthy (nonzero), return a dash "-".
      :             # ‎⁤  Otherwise:
       °U           # ‎⁢⁡    Increment variable U (starts at zero).
         +'|³       # ‎⁢⁢    Append "|" three times.
             +°U    # ‎⁢⁣    Append U incremented again.
                Ã   # ‎⁢⁤End map over range.
                 ·  # ‎⁣⁡Join this list on newlines.
💎

Created with the help of Luminespire.

This gives:

1|||2
-
-
3|||4
-
-
5|||6

Next, û centers each line:

1|||2
  -  
  -  
3|||4
  -  
  -  
5|||6

And Õ transposes the rows and columns:

1  3  5
|  |  |
|--|--|
|  |  |
2  4  6

Finally, r6'R replaces the final 6 with "R" to get the proper image:

1  3  5
|  |  |
|--|--|
|  |  |
2  4  R
\$\endgroup\$
6
\$\begingroup\$

Jelly,  26 25  24 bytes

-1 thanks to Unrelated String!

6s2j€”|$⁺Zj"⁾ -KŒBḤ¤YṖ”R

A full program that prints.

Try it online!

How?

6s2j€”|$⁺Zj"⁾ -KŒBḤ¤YṖ”R - Main Link: no arguments
6                        - six
 s2                      - split into twos     -> [[1,2],[3,4],[5,6]]
   j€”|$                 - join each with '|'  -> [[1,'|',2],[3,'|',4],[5,'|',6]]
        ⁺                - repeat that         -> [[1,'|','|','|',2],[3,'|','|','|',4],[5,'|','|','|',6]]
         Z               - transpose           -> [[1,3,5],['|','|','|'],['|','|','|'],['|','|','|'],[2,4,6]]
                   ¤     - nilad followed by link(s) as a nilad:
            ⁾ -          -   [' ', '-']          -> [' ','-']
               K         -   join with spaces    -> [' ',' ','-']
                ŒB       -   bounce              -> [' ',' ','-',' ',' ']
                  Ḥ      -   double (vectorises) -> ["  ","  ","--","  ","  "]
                            - (multiplying each character by 2 in Python)
           "             - zip with:
          j              -   join              -> [[1,"  ",3,"  ",5],['|',"  ",'|',"  ",'|'],['|',"--",'|',"--",'|'],['|',"  ",'|',"  ",'|'],[2,"  ",4,"  ",6]]
                    Y    - join with newlines  -> [1,"  ",3,"  ",5,'\n','|',"  ",'|',"  ",'|','\n','|',"--",'|',"--",'|','\n','|',"  ",'|',"  ",'|','\n',2,"  ",4,"  ",6]
                     Ṗ   - pop (remove the 6)
                         - implicit, smashing print
                      ”R - 'R'
                         - implicit print
\$\endgroup\$
2
  • 2
    \$\begingroup\$ For what it's worth, 5Ṿ€;”Rs2j€”|$⁺Zj"⁾ -KŒBḤ¤Y ties. Hard to think of anything to bring that idea to 25 though. \$\endgroup\$ Nov 18 at 4:38
  • 1
    \$\begingroup\$ Not so hard for me since the only reason I had used Ṿ€ rather than R was because the implementation of ¦ does not ignore errors for elements not being affected and » cannot compare ints and chars. \$\endgroup\$ Nov 18 at 16:45
4
\$\begingroup\$

Charcoal, 20 bytes

⁶⸿⸿↑E⪪2143R5²⟦⟦⪫ι|||

Try it online! Link is to verbose version of code. Explanation:

Output 6 -s to the canvas.

⸿⸿

Move to the start of the line below next.

↑E⪪2143R5²⟦⟦⪫ι|||

Loop over 21, 43, R5, inserting ||| between each pair, and output vertically and triple-spaced.

\$\endgroup\$
4
\$\begingroup\$

Vyxal, 154 bitsv2, 19.25 bytes

\|3*5ɾ\RJ2ẇvj\-dd½½YføĊ§

(24 bytes SBCS)

Try it Online! | | -6 bits with L

Optimizing this was a fun process, especially with Vyncode!

Bitstring:

0110101010001111001101000011000011101011101011110001101000001010010011110100010010101010100111111110100100011011101101100010011011010001010111110000101110
\|3*5ɾ\RJ2ẇvj\-dd½½YføĊ§­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏⁠‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁢⁢⁢‏⁠‎⁡⁠⁢⁢⁣‏⁠‎⁡⁠⁢⁢⁤‏‏​⁡⁠⁡‌­
\|3*                      # ‎⁡Push `|||`
    5ɾ\RJ                 # ‎⁢Append "R" to range [1,5]
         2ẇvj             # ‎⁣Split into chunks of length 2, join by "|||"
             \-dd½½       # ‎⁤Double "-" twice, halve twice (Push [["-","-"],["-","-"]])
                   Yf     # ‎⁢⁡Interleave and flatten
                     øĊ§  # ‎⁢⁢Centre, transpose and join by newlines
💎
\$\endgroup\$
4
\$\begingroup\$

APL+WIN, 47 bytes

5 7⍴(,⍉(7⍴2)⊤⎕av⍳'II⌷II')\'135||||--|--||||24R'

Try it online!Thanks to Dyalog Classic

Explanation:

⎕av⍳'II⌷II' Convert characters to integers 73 73 127 73 73 

,⍉(7⍴2)⊤ Convert to boolean matrix, transpose and flatten to a vector

 1 1 1 1 1
 0 0 1 0 0
 0 0 1 0 0
 1 1 1 1 1
 0 0 1 0 0
 0 0 1 0 0
 1 1 1 1 1

 1 0 0 1 0 0 1
 1 0 0 1 0 0 1
 1 1 1 1 1 1 1
 1 0 0 1 0 0 1
 1 0 0 1 0 0 1

 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 1 0 0 1 0 0 1

 This vector has as many 1s as the characters to be displayed.

 \'135||||--|--||||24R'  Inserts spaces into the character vector  corresponding to the 0s

1  3  5|  |  ||--|--||  |  |2  4  R

5 7⍴ Reshapes output as a matrix

Trivial answer for 41 bytes

5 7⍴'1  3  5|  |  ||--|--||  |  |2  4  R'
\$\endgroup\$
2
  • \$\begingroup\$ I don't know any APL but I tried moving some of the code around and it looks like this is constructing a matrix of every slot where characters should be placed, and filling them in? That's a really interesting method I never would have thought of. Maybe there's a way to golf the string being filled in? It does have a whole repeated section. \$\endgroup\$
    – noodle man
    Nov 18 at 2:06
  • \$\begingroup\$ @noodleman I have added an explanation to show what is going on. I have not yet managed to reduce it. Perhaps some Apler can improve it. \$\endgroup\$
    – Graham
    Nov 18 at 8:35
2
\$\begingroup\$

///, 36 bytes

/a/  //b/
|a|a|
/1a3a5b|--|--|b2a4aR

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Haskell, 53 bytes

"1  3  5"++a++"|--|--|"++a++"2  4  R"
a="\n|  |  |\n"

Attempt This Online!

The boring 45 byte answer:

"1  3  5\n|  |  |\n|--|--|\n|  |  |\n2  4  R"

Attempt This Online!

\$\endgroup\$
0
2
\$\begingroup\$

Retina, 35 bytes


1x3x5y|--|--|y2x4xR
y
¶|x|x|¶
x
  

Attempt This Online!

The last line contains two spaces. Replaces the input the fixed string 1x3x5y|--|--|y2x4xR, then replaces y with ¶|x|x|¶, where the pilcrows are newlines, and finally replaces x with two spaces.

Old Answer, 45 39 bytes bytes


135$&7*|24R
.
$&  
3`\|
|--|--|
L`.{9}

Attempt This Online!

-6 bytes thanks to Neil

How it works

  1. Ignored the input and replaces it by 135, 7 |s (we actually need 9, but these are inserted in step 4) and 24R
  2. Replaces every character by itself, followed by two spaces
  3. Replaces the third pipe (0-indexed) by |--|--|
  4. Formats into lines of 9 characters each
\$\endgroup\$
2
2
\$\begingroup\$

05AB1E, 28 25 24 bytes

0'|…|--)û.B7δ∍»¾5L'Rªι.;

Try it online.

Explanation:

0          # Push "0"
 '|       '# Push "|"
   …|--    # Push "|--"
       )   # Wrap all three values into a list
        û  # Palindromize it: ["0","|","|--","|","0"]
.B         # Box it: add trailing spaces to make all strings the same length:
           #  ["0  ","|  ","|--","|  ","0  "]
   δ       # Map over each string:
  7 ∍      #  Extend it to length 7:
           #   ["0  0  0","|  |  |","|--|--|","|  |  |","0  0  0"]
     »     # Join by newlines:
           #  "0  0  0\n
           #   |  |  |\n
           #   |--|--|\n
           #   |  |  |\n
           #   0  0  0"
¾          # Push 0
 5L        # Push list [1,2,3,4,5]
   'Rª    '# Append "R"
      ι    # Uninterleave it into two parts: [[1,3,5],[2,4,"R"]]
       .;  # Replace every first 0 one by one with the flattened values of this list
           # (after which the result is output implicitly)
\$\endgroup\$
4
  • \$\begingroup\$ I think your second version is a bit closer to @mathscat’s Vyxal submission than it is to my Japt. They are both pretty similar to each other though. \$\endgroup\$
    – noodle man
    Nov 20 at 13:20
  • \$\begingroup\$ @noodleman I've already got a different approach than both of my initial answers. :) \$\endgroup\$ Nov 20 at 13:24
  • \$\begingroup\$ Ooh, this is really nice! Very clever thinking to use repeat-to-length for that. I’m going to try this method in Japt but I think it’ll come out to closer to 30 bytes. \$\endgroup\$
    – noodle man
    Nov 20 at 13:38
  • \$\begingroup\$ Actually, it didn’t work because Japt doesn’t have a translate builtin. \$\endgroup\$
    – noodle man
    Nov 20 at 14:39
2
\$\begingroup\$

Python 3, 52 51 bytes

Boring, straightforward answer. Prints to STDERR.

exit("1  3  5\n|  |  |\n|--|--|\n|  |  |\n2  4  R")

In a REPL, or Notepad & PHP (39 bytes), or paper (0 bytes), we can shorten that to this:

'''1  3  5
|  |  |
|--|--|
|  |  |
2  4  R'''
\$\endgroup\$
7
  • \$\begingroup\$ Do the site rules permit you to drop the "print("? \$\endgroup\$ Nov 18 at 7:54
  • \$\begingroup\$ Now that you say that, it could count as an anonymous string, which is referenced to by adding a f=\ (omit the space) in the header, which is allowed for anonymous functions. I'm not sure whether rules permit us to make our submission an anonymous string. \$\endgroup\$ Nov 18 at 8:13
  • \$\begingroup\$ I am arguing that, entered straight in the Python REPL, the string will print out the right answer as requested. Whether this permitted depends on local rules. \$\endgroup\$ Nov 18 at 8:17
  • \$\begingroup\$ Well then, that's a submission for a Python REPL, not a Python interpreter. I'll include that as well though \$\endgroup\$ Nov 18 at 8:19
  • \$\begingroup\$ The REPL method would work the same in Notepad or TextEdit but with less input. The task is to "Print the transmission pattern in as few bytes as possible." Taken literally, you can do that with a pencil on a piece of paper, using zero bytes of computer memory. \$\endgroup\$ Nov 18 at 8:43
1
\$\begingroup\$

JavaScript, 55 bytes

Another one of those boring answers:

console.log(`1  3  5
|  |  |
|--|--|
|  |  |
2  4  R`)

I am aware the shaving off the pair of those pesky parentheses saves 2 bytes, but sadly the result is not as requested.

Trying to do some actual cool golfing performs worse (59 56 bytes in this case from noodle man):

console.log(`1  3  5${v=`
|  |  |
`}|--|--|${v}2  4  R`)

(No Try It Online button because you can run the snippets right here!)

\$\endgroup\$
1
1
\$\begingroup\$

PowerShell, 41 bytes

Unfortunately, the shortest I could create was simple a string of the required output... quite boring I know!

"1  3  5
|  |  |
|--|--|
|  |  |
2  4  R"

Try it online!

\$\endgroup\$
1
\$\begingroup\$

C# .NET 6, 152 146 bytes

int a=124,b=45,c=10;foreach(var x in new[]{49,0,51,0,53,c,a,0,a,0,a,c,a,b,b,a,b,b,a,c,a,0,a,0,a,c,50,0,52,0,82})Console.Write((x>0?(char)x:"  "));

Edit: Stored 124 '|', 45 '-', and 10 '\n' into vars to eliminate a char each call

\$\endgroup\$
3
  • \$\begingroup\$ Isn't this a snippet, not a program or function? Meta Meta 2 \$\endgroup\$ Nov 22 at 15:07
  • 1
    \$\begingroup\$ Nope, that's a full program now that top-level statements exist. \$\endgroup\$ yesterday
  • \$\begingroup\$ Ah, interesting! Someone at Microsoft must be into code golf ;) \$\endgroup\$ 22 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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