title: It was just an input-bug

text:
# Question
Title: It was just an input-bug
Continuing my *It was just a bug* challenge:

### Input:

A string consisting of printable ASCII characters without white-spaces nor new-lines.

### Output:

First turn the input into a palindrome by reverting the input, and adding it before itself, excluding the middle character (i.e. with an input `1234567890`, it will becomes `0987654321234567890`).

And then output this text:

```
0        9        8        7        6        5        4        3        2        1        2        3        4        5        6        7        8        9        0
         0       9       8       7       6       5       4       3       2       1       2       3       4       5       6       7       8       9       0
                  0      9      8      7      6      5      4      3      2      1      2      3      4      5      6      7      8      9      0
                           0     9     8     7     6     5     4     3     2     1     2     3     4     5     6     7     8     9     0
                                    0    9    8    7    6    5    4    3    2    1    2    3    4    5    6    7    8    9    0
                                             0   9   8   7   6   5   4   3   2   1   2   3   4   5   6   7   8   9   0
                                                      0  9  8  7  6  5  4  3  2  1  2  3  4  5  6  7  8  9  0
                                                               0 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 0
                                                                        0987654321234567890
                                                               0 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 0
                                                      0  9  8  7  6  5  4  3  2  1  2  3  4  5  6  7  8  9  0
                                             0   9   8   7   6   5   4   3   2   1   2   3   4   5   6   7   8   9   0
                                    0    9    8    7    6    5    4    3    2    1    2    3    4    5    6    7    8    9    0
                           0     9     8     7     6     5     4     3     2     1     2     3     4     5     6     7     8     9     0
                  0      9      8      7      6      5      4      3      2      1      2      3      4      5      6      7      8      9      0
         0       9       8       7       6       5       4       3       2       1       2       3       4       5       6       7       8       9       0
0        9        8        7        6        5        4        3        2        1        2        3        4        5        6        7        8        9        0

```

(From the middle outward in both directions, each character is separated by one more space than the previous line.)

## Challenge rules:

* You need to print twice the length of the input, minus 3 lines. So with the input `1234567890`, the output displayed above is 17 lines (length 10 * 2 - 3).
* The input will only contain printable ASCII (excluding space, tab and new-line).
* Trailing spaces are optional.
* A single trailing new-line is optional.
* (Additional) leading spaces or leading new-lines are not allowed.
* You can assume the input will always be at least four characters long.
* Unlike my *It was just a bug* challenge, both the input and output formats are flexible. So you are allowed to output the result as a String-array, String-list, etc.

## General rules:

* This is , so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
* Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
* Default Loopholes are forbidden.
* If possible, please add a link with a test for your code.
* Also, please add an explanation if necessary.

## Test cases:

```
Input: 1234567890
Output:
0        9        8        7        6        5        4        3        2        1        2        3        4        5        6        7        8        9        0
         0       9       8       7       6       5       4       3       2       1       2       3       4       5       6       7       8       9       0
                  0      9      8      7      6      5      4      3      2      1      2      3      4      5      6      7      8      9      0
                           0     9     8     7     6     5     4     3     2     1     2     3     4     5     6     7     8     9     0
                                    0    9    8    7    6    5    4    3    2    1    2    3    4    5    6    7    8    9    0
                                             0   9   8   7   6   5   4   3   2   1   2   3   4   5   6   7   8   9   0
                                                      0  9  8  7  6  5  4  3  2  1  2  3  4  5  6  7  8  9  0
                                                               0 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 0
                                                                        0987654321234567890
                                                               0 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 0
                                                      0  9  8  7  6  5  4  3  2  1  2  3  4  5  6  7  8  9  0
                                             0   9   8   7   6   5   4   3   2   1   2   3   4   5   6   7   8   9   0
                                    0    9    8    7    6    5    4    3    2    1    2    3    4    5    6    7    8    9    0
                           0     9     8     7     6     5     4     3     2     1     2     3     4     5     6     7     8     9     0
                  0      9      8      7      6      5      4      3      2      1      2      3      4      5      6      7      8      9      0
         0       9       8       7       6       5       4       3       2       1       2       3       4       5       6       7       8       9       0
0        9        8        7        6        5        4        3        2        1        2        3        4        5        6        7        8        9        0

Input: ABCD
Output:
D  C  B  A  B  C  D
   D C B A B C D
      DCBABCD
   D C B A B C D
D  C  B  A  B  C  D

Input: =>)}]
Output:
]   }   )   >   =   >   )   }   ]
    ]  }  )  >  =  >  )  }  ]
        ] } ) > = > ) } ]
            ]})>=>)}]
        ] } ) > = > ) } ]
    ]  }  )  >  =  >  )  }  ]
]   }   )   >   =   >   )   }   ]

Input: XXxxXX
Output:
X    X    x    x    X    X    X    x    x    X    X
     X   X   x   x   X   X   X   x   x   X   X
          X  X  x  x  X  X  X  x  x  X  X
               X X x x X X X x x X X
                    XXxxXXXxxXX
               X X x x X X X x x X X
          X  X  x  x  X  X  X  x  x  X  X
     X   X   x   x   X   X   X   x   x   X   X
X    X    x    x    X    X    X    x    x    X   X

```

# Answer
> 3 votes
# Vyxal `C`, 11 bytes

```
ṪẏṘ∞ƛ?Ṙ∞$Ij

```

Try it Online!

## Explanation

```
ṪẏṘ∞ƛ?Ṙ∞$Ij
Ṫ           # Remove the last element (removing the first element would be fine too)
 ẏ          # Make a range [0, length)
  Ṙ         # Reverse
   ∞        # Palindromize, a + a[::-1][1:]
    ƛ       # Map, and for each:
     ?Ṙ     #  Push the input reversed
       ∞    #  Palindromize that (call this X)
        $   #  Swap so the current item is at the top
         I  #  Push that many spaces
          j #  Join the characters of X by that
            # C flag centers and joins on newlines

```

# Answer
> 8 votes
# Japt, ~~22~~ 21 bytes

```
¬Å£¬qYîÃy w ê y w ê ·

```

Test it online!

### Explanation

The first 8 bytes generate the bottom-right quadrant of the pattern:

```
 ¬ Å  £    ¬ qYîÃ
Uq s1 mXY{Uq qYî}

Uq                 : Split the input into characters.
   s1              : Slice off the first.
      mXY{      }  : Map each item X and index Y to
          Uq       :   the input split into chars,
             q     :   joined with
              Yî   :     Y spaces.

```

At this point we have an array of e.g. `["ABCD", "A B C D", "A B C D"]`. Unfortunately, it takes 13 bytes to square this:

```
y w ê y w ê ·
y w ê y w ê qR
y                : Pad each line to the same length with spaces and transpose.
  w              : Reverse the array, and
    ê            : palindromize. Now we have the bottom half of the output transposed.
      y          : Transpose back.
        w ê      : Reverse and palindromize again, giving the full output.
            qR   : Join with newlines.
                 : Implicit: output result of last expression

```

# Answer
> 5 votes
# Python 3, ~~149 141~~ 95 bytes

```
def f(s):l=len(s)-1;[print((' '*abs(i)).join(s[:0:-1]+s).center(2*l*l+1))for i in range(1-l,l)]

```

Try it online!

Thanks to @KevinCruijssen and @ETHproductions for saving some bytes

***Special thanks to @notjagan for saving 46 bytes!***

# Answer
> 5 votes
# 05AB1E, 17 bytes

```
g<F¹RSðN×ýû})Rû.c

```

Try it online!

-1 thanks to kalsowerus.

# Answer
> 5 votes
# Charcoal, 14 bytes

```
Ｅ⁻Ｌθ¹⪫θ× ι‖Ｏ←↑

```

Try it online!

AST:

```
Program
├Print
│└Ｅ: Map
│ ├⁻: Difference
│ │├Ｌ: Length
│ ││└θ: Identifier θ
│ │└1: Number 1
│ └⪫: Join
│  ├θ: Identifier θ
│  └×: Product
│   ├' ': String ' '
│   └ι: Identifier ι
└‖Ｏ: Reflect overlap
 └Multidirectional
  ├←: Left
  └↑: Up

```

# Answer
> 5 votes
# JavaScript (ES6), 159 136 129 127 bytes

```
f=(i,x=1-(l=i.length-1),y=x<0?-x:x,[,...b]=i)=>l>x?''.padEnd(l*(l+~y))+[...b.reverse(),...i].join(''.padEnd(y))+`
`+f(i,x+1):''

```

Try it online! Explanation below

```
// This is a recursive function
// First, inputs and various variable initializations
// by using defaults
let func = (
  // Text input, will not be modified through recursion
  input,

  // Current line, for the first function call we start from -lines to +lines
  // It's roughly equivalent to lines*2 but this helps us computing the spacing
  // Also computing the total amount of lines
  currentLine = 1 - (totalLines = input.length - 1),

  // Getting the absolute value of the current line (like Math.floor)
  absCurrentLine = currentLine < 0 ? -currentLine : currentLine,

  // Getting the input without it's first letter, useful for the palidrome of the input
  [,...slicedInput] = input

// Base case, stopping the recursion if the current line
// is still below the total amount of lines
) => totalLines > currentLine

  // Leading spacing
  ? ''.padEnd(totalLines * (totalLines + ~absCurrentLine)) +

  // Putting together the palindrome version and adding spaces between the chars
    [...slicedInput.reverse(), ...input].join(''.padEnd(absCurrentLine)) + `

  // Line return + recursion call
` + f(input, currentLine + 1)
  : ''

```

First entry to codegolf, I apologise in advance for any obvious mistakes.

Thanks to Justin Mariner for saving 23 bytes! Thanks to Craig Ayre for saving 11 bytes and for the bug report.

# Answer
> 4 votes
# SOGL V0.12, ~~22~~ 18 bytes

```
ā,⁄H{,čFH@*∑Κ}▓±╬-

```

Try it Here!

Explanation:

```
ā                   push an empty array - canvas
 ,⁄H{        }      input length-1 times do
     ,                push the input
      č               chop it into chars
       FH@*           get the current iteration-1 amount of spaces
           ∑          join the chopped input with the spaces
            Κ         prepend it to the array
              ▓     space to a square
               ±    reverse each string in that list
                ╬-  quad-palindromize with 1 X and 1 Y overlap and without swapping characters

```

# Answer
> 4 votes
# PHP, ~~145~~ 131 bytes

It took some thinking to golf that additional byte; but it was worth it.

```
while($y<=2*$e=strlen($a=$argn)-1)echo($p=str_pad)("
",$e*($e-$d=abs($y++-$e))+1),chunk_split($a.substr(strrev($a),1),1,$p("",$d));

```

prints a leading newline. Run as pipe with `-nR` or try it online.

**breakdown**

```
while($y<=2*$e=strlen($a=$argn)-1)  # $e=length-1, loop through rows
                                        # 1. print linebreak and left padding
    echo($p=str_pad)("\n",$e*($e-$d=abs($y++-$e))+1),
        chunk_split(
            $a.substr(strrev($a),1)     # 2. palindromize input
            ,1,$p("",$d));              # 3. insert $e..0..$e spaces between characters

```

**alternative solution**, same length:

```
for($d=-$e=strlen($a=$argn)-1;$d<$e;)echo($p=str_pad)("
",$e*($e-$b=abs($d++))+1),chunk_split($a.substr(strrev($a),1),1,$p("",$b));

```

# Answer
> 3 votes
# APL (Dyalog), 37 bytes

Requires `⎕IO←0` which is default on many systems.

```
{⍉m(2-d)↓⍉(m←⊖⍪1↓⊢)↑∊¨(1↓⍳d←≢⍵)↑¨¨⊂⍵}

```

`{``}` anonymous function where the argument is represented by

`(``)↑¨¨⊂⍵` for each (`¨`) of the following numbers take () that many characters from each (`¨`) of the entire () argument, padding with spaces as necessary:

`≢w` the number of characters in the argument

`d←` store that in *d*

that many **ɩ**ndices (0 … *d* − 1)

`1↓` drop one (the zero)

`∊¨`**ϵ**nlist (flatten) each

raise the rank (convert the list of lists into a matrix)

`(m←``)` apply the following tacit function *m*, defined as:

the upside-down argument

on top of

`1` one \[row\]

dropped from

the argument

transpose

`(``)↓` drop:

`2-d` = −(*d* − 2), i.e. *d* − 2 rows from the bottom

`m` apply *m*

transpose

Try it online!

# Answer
> 3 votes
# Java (OpenJDK 8), ~~201~~ 196 bytes

```
s->{for(int l=s.length()-1,i=-l,x=0;++i<l;x+=i<0?l:-l)System.out.printf("%1$"+(x<1?"":x)+"s"+s.join("%1$"+(i<0?-i:i>0?i:"")+"s",(new StringBuffer(s.substring(1)).reverse()+s).split(""))+"%n","");}

```

Try it online!

It's the same idea as the one I used for the previous challenge, except that the generator string is now a tad longer and with more hard to handle cases.

```
%1$Ns0%1$Ns9%1$Ns8%1$Ns7%1$Ns6%1$Ns5%1$Ns4%1$Ns3%1$Ns2%1$Ns1%1$Ns2%1$Ns3%1$Ns4%1$Ns5%1$Ns6%1$Ns7%1$Ns8%1$Ns9%1$Ns0%n

```

# Answer
> 3 votes
# Python 3, ~~134~~ 124 bytes

```
f=lambda s:'\n'.join([' '*(len(s)-1)*abs(len(s)-abs(i)-2)+(' '*abs(i)).join(s[::-1]+s[1:]) for i in range(2-len(s),len(s)-1)])

```

Try it online!

First post to PPCG after lurking for a while. Looking for any suggestions/advice!

---

Thanks to @LyricLy and @Łukasz Rogalski for improvements!

# Answer
> 3 votes
# Haskell, ~~177~~ 163 bytes

```
import Data.List
k n=[1..n]>>" "
f s=let n=length s in map(\x->(k(((n-1)*(n-(abs x)))))++(intercalate (k(abs x))$map(\z->[z])$((++)=<<reverse.tail) s))[n,n-1.. -n]

```

The function `f` is the challenge function and returns a list of strings (`[String]`), using `unlines` on it should provide the same visual output as the test cases (`main = putStr $ unlines $ f "test string"` to compile it).

Try it online!

-14 bytes thanks to @nimi

# Answer
> 3 votes
# Thunno 2 `N`, 14 bytes

```
ḣı$ṅṣj;ðƬrⱮṬrⱮ

```

Try it online!

I have *absolutely* no idea why this works, but it does.

#### Explanation

```
ḣı$ṅṣj;ðƬrⱮṬrⱮ  # Implicit input
ḣı    ;         # len(input) - 1 times:
  $  j          #   Join the input by...
   ṅṣ           #   ...loop index spaces
       ðƬ       # Transpose with filler space
         rⱮ     # Reverse and palindromise
           Ṭ    # Tranpose it
            rⱮ  # Reverse and palindromise
                # Implicit output, joined on newlines

```

I did quite a bit of experimenting, producing a lot of buggy outputs. Here's my favourite:

```
                                                                        0987654321234567890
                                                               0 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 0
                                                      0  9  8  7  6  5  4  3  2  1  2  3  4  5  6  7  8  9  0
                                             0   9   8   7   6   5   4   3   2   1   2   3   4   5   6   7   8   9   0
                                    0    9    8    7    6    5    4    3    2    1    2    3    4    5    6    7    8    9    0
                           0     9     8     7     6     5     4     3     2     1     2     3     4     5     6     7     8     9     0
                  0      9      8      7      6      5      4      3      2      1      2      3      4      5      6      7      8      9      0
         0       9       8       7       6       5       4       3       2       1       2       3       4       5       6       7       8       9       0
0        9        8        7        6        5        4        3        2        1        2        3        4        5        6        7        8        9        0
         0       9       8       7       6       5       4       3       2       1       2       3       4       5       6       7       8       9       0
                  0      9      8      7      6      5      4      3      2      1      2      3      4      5      6      7      8      9      0
                           0     9     8     7     6     5     4     3     2     1     2     3     4     5     6     7     8     9     0
                                    0    9    8    7    6    5    4    3    2    1    2    3    4    5    6    7    8    9    0
                                             0   9   8   7   6   5   4   3   2   1   2   3   4   5   6   7   8   9   0
                                                      0  9  8  7  6  5  4  3  2  1  2  3  4  5  6  7  8  9  0
                                                               0 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 0
                                                                        0987654321234567890

```

# Answer
> 2 votes
# Mathematica, 141 bytes

```
Column[Join[Reverse@(s=Row/@Table[Riffle[Reverse@Rest@b~Join~b,""<>Table[" ",i]],{i,0,Length[b=Characters@#]-1}]),Rest@s],Alignment->Center]&

```

# Answer
> 2 votes
# Japt `-R`, 15 bytes

```
ÊÆÔ¬qXç)êÃÔÅê û

```

Try it

```
ÊÆÔ¬qXç)êÃÔÅê û     :Implicit input of string
Ê                   :Length
 Æ                  :Map each X in the range [0,length)
  Ô                 :  Reverse U
   ¬                :  Split
    q               :  Join with
     Xç             :    X spaces
       )            :  End join
        ê           :  Palindromise
         Ã          :End map
          Ô         :Reverse
           Å        :Slice off first element
            ê       :Palindromise
              û     :Centre pad each element with spaces to the length of the longest
                    :Implicit output joined with newlines

```

# Answer
> 2 votes
# Julia 1.0, <sup>~~100~~</sup> 90 bytes

```
s->(l=length(s)-2;[' '^(-~l*(l-j))*prod(s[abs(i)+1]*' '^j for i=~l:l+1) for j=abs.(-l:l)])

```

Try it online!

-10 bytes thanks to @KevinCruijssen

# Answer
> 2 votes
# Canvas, 14 bytes

```
Ｌ╷ｒＨ ×⁸；＊∔｝↔↕┼

```

Try it here!

## Explanation

```
L|rH ×⁸;*∔}↔↕┼
L              length of input
 |r            decrement, make range [0..n-1]
   H           create an empty art object, start a loop with i
     ×         repeat space i times
      ⁸;       swap with the input
        *      join input with i spaces
         ∔     add to the bottom of the previous iteration
          }    close the loop
           ↔↕  mirror horizontally and vertically
             ┼ quad palindromize with 1 character overlap

```

# Answer
> 1 votes
# 05AB1E, 14 bytes

```
¦ε\RðN×ýû}Rû.c

```

Input as a list of characters.

Try it online or verify all test cases.

**14 bytes alternative:**

```
ā¨RjJíðδÜ€ûû.c

```

Also takes a list of characters as input.

Try it online or verify all test cases.

**Explanation:**

```
¦              # Remove the first item of the (implicit) input-list
               # (could have removed the last as alternative as well)
 ε             # Map over each character:
  \            #  Discard the character
   R           #  Reverse the (implicit) input-list
     N         #  Push the 0-based map-index
    ð ×        #  Repeat a space character that many times as string
       ý       #  Join the reversed input-list with this spaces-string as delimiter
        û      #  Palindromize the entire string
 }R            # After the map: reverse the resulting list
   û           # Palindromize this entire list
    .c         # And centralize it, which also implicitly joins by newlines
               # (after which the result is output implicitly)

ā              # Push a list in the range [1, (implicit) input-length]
 ¨             # Remove the last item to make the range [1, input-length)
  R            # Reverse the list to (input-length, 1]
   j           # Pad each character in the (implicit) input-list with leading spaces so
               # the string lengths become equal to the current integer
    J          # Join each inner list of strings together to a single string
     í         # Reverse each string
       δ       # Map over each string:
      ð Ü      #  And remove all trailing spaces
         €û    # Palindromize each string
           û   # Palindromize the entire list
            .c # And centralize it, which also implicitly joins by newlines
               # (after which the result is output implicitly)

```

# Answer
> 1 votes
# Zsh, ~~117~~ ~~113~~ ~~109~~ 112 bytes

```
b=`rev<<<$1`${1:1};j=$#1
for c ({$j..1} {2..$j}){printf %$[(j-1)*(j-c)]s
for x (${(s::)b})printf %-$c\s $x;echo}

```

Try it online! <sub>~~109b invalid~~</sub> <sub>~~113b~~</sub> <sub>~~117b~~</sub>

`b` is the palindrome; `j` is the length of input string `$1`. Iterate `c` over the range `{j..1..j}`. For each `c`, print a prefixed number of spaces. For every character `x` in `b`, print `x` with `c` spaces between each.

---
Tags: code-golf, ascii-art
---


# Question
Title: Most elegant one-liner to generate sqlite INSERTs
# Challenge

You find yourself in a `bash` terminal, and want to do some simple tests on `sqlite3`.

So you issue the following command:

```
echo "CREATE TABLE T (id INT NON NULL PRIMARY KEY)" | sqlite3 test.db

```

Now you want to insert the first `N` integers (starting from 0, excluding N) into the table `T`.

For convenience, you execute the following

```
N=5 # value arbitrary and large, not known for purposes of the challenge

```

Now for the example case of `N == 5`, you would have to execute the following SQL command:

```
echo "INSERT INTO T VALUES (0), (1), (2), (3), (4);" | sqlite3 test.db

```

But of course, `N` is large, so you want to come op with a `bash` oneliner to dynamically generate and execute the SQL statement to insert these values.

---

# Rules

* The result of entering the command string into the presented `bash` teminal session (and pressing enter) should be the modification of `test.db` as described in the challenge.
* You must not leave behind any unintended artifacts on disk (ignoring command histories etc.)
* Any cli tool can be called and considered installed, e.g. `python -c`, `ghci -e`, `awk`, ...
* The final command string must be a **single** line of characters enterable in the `bash` terminal session described above (if we want to get technical, the command string cannot contain a byte with value 10 (LF))
* Your command string must be valid UTF-8
* You don't absolutely have to end in `| sqlite3 test.db`, if the tools you are using have some built in way to write to `test.db`, that can be used aswell. (Although it might not help you that much, see the scoring).
* If you are using tools where it is not obvious how to install them for others (let's just say, if the are not available as a Debian Package), please add a link on where to get them.

---

# Scoring

Score shall be based on the following metric, which tries to favor elegant and readable solutions:

* +100 Points by default so we don't have to look at that many negative scores.
* -5 points for every character not in the printable ASCII range (values 32-127, )
* -3 points for every 10 characters above 80 (e.g. 89: -0, 90: -3, 99: -3, 100: -6)
* -2 points for every use of `\`
* -1 point for every use of any of these characters: `(){}[]'"`` (trying to punish nesting here, sorry LISP fans)

The tie breaker are the upvotes, which I hope will respect the spirit of elegant / readable solutions.

Highest Score wins !

---

Non competing example solution in Haskell to demonstrate Scoring:

```
ghci -e 'import Data.List' -e 'putStr $ "insert into T values" ++ (concat $ intersperse "," $ map (\i -> "(" ++ show i ++ ")") [0..'$N']) ++ ";"' | sqlite3 test.db

```

```
Default:                  = 100
Non Ascii:        0  * -5 =  -0
Length: 164:      8  * -3 = -24
Backslashes:      1  * -2 =  -2
Special Chars:    24 * -1 = -24
--------------------------------
Total Points:                50

```

# Answer
# Score 100 (optimal)

```
echo seq $1Uxargs MRE sqlite3 testNdb Binsert into t values HEMQIB | tr A-Z !-1Iz-~| bash

```

Attempt This Online!

This is the version below, but encoded so that it contains no literal `()"` characters (and with some whitespace removed, so the final thing fits in under 90 characters)

# Score 96

```
seq $1 | xargs -I % sqlite3 test.db "insert into t values (% - 1)"

```

Attempt This Online!

Gratuitous whitespace, in the spirit of elegance, since it's still well under 90 bytes.
> 4 votes

---
Tags: code-challenge, bash, sql
---


title: Print invisible text

text:
# Question
Title: Print invisible text
Given a string as input, output a number of whitespace characters (0x0A and 0x20) equal to the length of the string.

For example, given the string `Hello, World!` your code would need to output exactly 13 whitespace characters and nothing else. These can be any mix of spaces and newlines.

Your code should not output any additional trailing newlines or spaces.

## Testcases:

```
     Input      -> Amount of whitespace to output
"Hello, World!" -> 13
"Hi"            -> 2
"   Don't
Forget about
Existing
Whitespace!   " -> 45
""              -> 0
"             " -> 13
"
"               -> 1

```

## Scoring:

This is so fewest bytes wins!

# Answer
> 153 votes
# Whitespace, ~~311~~ ~~150~~ ~~77~~ ~~68~~ ~~65~~ ~~46~~ ~~41~~ 38 bytes

-3 bytes thanks to Kevin Cruijssen
-27 bytes thanks to Ephphatha

```

```

Try it online!

A visible format

```
'\n  \n   \t \t \n \n  \n \t\n\t \t\t\t\n\t  \n\t\n  \n \n\n'

```

Explanation (s = space, t = tab, n = new line)

```
nssn     # label(NULL) - loop start
ssststsn # push 10 in the stack -> [10]
sns      # duplicate the top of the stack -> [10, 10]
sns      # duplicate the top of the stack -> [10, 10, 10]
tnts     # read a single char from input, pop the stack and store at that address -> [10, 10] [10:<char that was read>]
ttt      # pop the stack and put the value at that adress on stack -> [10,<char>] [10:<char>]
ntssn    # jump to label(0) - since label(0) is not defined, the interpreter jumps to the end of the program - if the top of the stack (char) is 0 -> [10] [10:<char>]
tnss     # pop the top of the stack and print as ascii -> [] [10:<char>]
nsnn     # go back to the label(NULL)

```

# Answer
> 61 votes
# Japt, 1 byte

```
ç

```

Try it online!

# Answer
> 40 votes
# Haskell, 7 bytes

```
(>>" ")

```

Try it online! Usage: `(>>" ") "Hello, world!"`.

Given two lists (and strings are lists of characters in Haskell) the `>>` operator will repeat the second list as many times as the first list has elements. Setting `" "` as second argument means we concatenate as many spaces as the input string is long.

---

**Alternative** (same byte count):

```
(' '<$)

```

Try it online! Usage: `(' '<$) "Hello, world!"`.

Given some value and a list, the `<$` operator replaces each value in the list with the given value. Thus `5 <$ "abc"` results in `[5,5,5]`, and `' ' <$ "abc"` in `" "`.

The function can equivalently be written as `(<$)' '`, in case you want to find some more marine creatures in my code.

# Answer
> 21 votes
# brainfuck, 18 bytes

```
++++++++++>,[<.>,]

```

Try it online!

Prints one newline for each byte of input. Printing spaces instead would add 4 bytes.

# Answer
> 20 votes
# Python, 19 bytes

```
lambda s:' '*len(s)

```

# Answer
> 18 votes
# Brainfuck, 16 bytes

Prints newlines.

```
,[>++++++++++.,]

```

# Answer
> 17 votes
# Retina, ~~3~~ 4 bytes

```
S\`.

```

Old version, doesn't work because Retina prints a trailing line feed.

```
.

```

(The second line contains a space).

# Answer
> 14 votes
# sed, 7 bytes

```
s/./ /g

```

Try it online!

# Answer
> 12 votes
# C#, ~~28~~ 24 bytes

```
s=>"".PadLeft(s.Length);

```

Old version using the `string` constructor for 28 bytes:

```
s=>new string(' ',s.Length);

```

# Answer
> 9 votes
# JavaScript ES6, 22 bytes

```
a=>a.replace(/./g," ")

```

```
f=a=>a.replace(/./g," ");

var test = f("Hello, World!");
console.log(test, test.length);
```

# Answer
> 9 votes
# Retina, 5 bytes

```
\`.
¶

```

Try it online! Changes everything into newlines. The `\`` suppresses the extra newline Retina would normally output.

# Answer
> 8 votes
# Mathematica, 21 bytes

```
StringReplace[_->" "]

```

# Answer
> 8 votes
# C, 31 bytes

```
f(char*c){puts(""),*c++&&f(c);}

```

# Answer
> 7 votes
# 05AB1E, 3 bytes

```
vð?

```

Try it online!

```
v   # For each character...
 ð? #    Output a space without a newline

```

### Other 3 byte solutions (Thanks Magic Octopus Urn and Kevin Cruijssen for most of these)

```
v¶? # For each character print a newline (without adding a newline)
võ, # For each character print the empty string with a newline
gð× # Get the length, concatenate that many copies of space
g¶× # Get the length, concatenate that many copies of newline
Sð: # Split, push a space, replace each char in input with a space
ðs∍ # Push ' ', swap, make the string of spaces as long as the input was
võJ # For each char, push a space and ''.join(stack)
v¶J # For each char, push a newline and ''.join(stack)
€ðJ # For each char, push a space. Then ''.join(stack)
€¶J # For each char, push a newline. Then ''.join(stack)

```

# Answer
> 7 votes
# Excel VBA, ~~17~~ 15 Bytes

Anonymous VBE immediate window funtion that takes input from cell `[A1]` and outputs spaces of length of the input to the VBE immediate window

```
?Spc([Len(A1)])

```

# Answer
> 7 votes
# PHP, 28 Bytes

```
for(;a&$argn[$i++];)echo" ";

```

Try it online!

# PHP, 29 Bytes

```
<?=str_pad('',strlen($argn));

```

Try it online!

# Answer
> 6 votes
# JavaScript (ES6), 23 bytes

```
s=>" ".repeat(s.length)

```

# Answer
> 6 votes
# Octave, 14 bytes

```
@(a)["" 0*a+32]

```

# Answer
> 6 votes
# CJam, 4 bytes

```
q,S*

```

Try it online!

### Explanation

```
q     e# Read input
 ,    e# Length
  S*  e# Repeat space that many times

```

# Answer
> 6 votes
# , 2 bytes

```
Ò

```

Try it online!

Note the trailing space!

# Answer
> 6 votes
# C, 45 bytes

Using main. Compile with gcc, ignore warnings.

```
main(c,v)char**v;{while(*(v[1]++))puts("");}

```

Usage:

```
$./a.out "Hello, World!"

```

# Answer
> 5 votes
# Python 2, 25 bytes

```
exec'print;'*len(input())

```

-2 bytes thanks to Loovjo
-2 bytes in the invalid code thanks to totallyhuman :p
-3 bytes

# Answer
> 5 votes
# Perl 5, 7 bytes

*-1 byte thanks to @Xcali*

6 bytes of code + `-p` flag.

```
y// /c

```

Try it online!

Quite straight forward : replaces every character with a space.

# Answer
> 5 votes
# Excel, 18 bytes

```
=REPT(" ",LEN(A1))

```

Pretty boring and one byte longer than the VBA answer.

# Answer
> 5 votes
## \>\<\>, 7 bytes

```
i0(?;ao

```

The program is a loop

```
i         //Push a character from the input onto the stack
 0        //Add a 0 to the stack
  (       //Pop the top two values of the stack, and push a 1 if the second is less than the first (In this case, the input has all been read), else push a 0
   ?      //Pop the top of the stack. If the value is a 0, skip the next instruction
    ;     // Terminate the program
     a    // Add a newline to the stack
      o   // Pop the top character of the stack and print it

```

# Answer
> 5 votes
# Pyth, 3 bytes

```
*dl

```

Try it!

Python equivalent: `len(input())*" "`

```
jmk

```

Try this!

Python equivalent: `"\n".join(map("", input()))`

```
smb

```

Try that!

Python equivalent: `"".join(map("\n",input())`

```
VQk

```

Try!

Python equivalent: `For N in input():print("")`

# Answer
> 5 votes
# Hexagony, ~~12~~ 11 bytes

-1 byte thanks to Martin Ender

```
,<.;.M@.>~8

```

Try it online!

Here is the expanded hex:

```
  , < .
 ; . M @
. > ~ 8 .
 . . . .
  . . .

```

While there is input, this code runs:

```
,        # Get input
 <       # Turn right (SE) if we didn't get EOF
  M8     # Set the memory edge to 778 which is 10 (mod 256)
    ;    # Print as a character (newline)
     >   # Redirect East
      ~  # Multiply by -1. This makes the pointer go to the top when it runs off the edge
       8 # Effectively a no-op.

```

When EOF is reached:

```
,    # Get input
 <   # Turn left (NE)
  8  # Effectively a no-op
   @ # End program

```

# Answer
> 4 votes
# PHP, 36 bytes

```
<?=str_repeat('
',strlen($argv[1]));

```

Try it online!

Outputs newlines because spaces are too mainstream

# Answer
> 4 votes
# Jelly, 2 bytes

```
⁶ṁ

```

Try it online!

# Answer
> 4 votes
# C (tcc), 31 bytes

I opted to output newlines since it's shorter...

```
f(char*s){for(;*s++;puts(""));}

```

Try it online!

# Answer
> 4 votes
# Cubix, 6 bytes

Wahoo a 6 byter!

```
wi?@oS

```

Cubified

```
  w
i ? @ o
  S

```
* `i` gets input
* `?` test top of stack
    + if negative (EOI) redirect onto `w` lane change which umps to the `@` halt
    + if 0 (null) halt this shouldn't be hit
    + if positive `Sow` push space to the stack, output and change lane onto `i`

Try it online!

# Answer
> 4 votes
# C, 32 bytes

**Try Online** modifying characters into spaces

```
f(char*t){(*t=*t?32:0)&&f(t+1);}

```

### C, 37 bytes

**Try Online** Left-padding the end-of-string with its length

```
f(char*t){printf("%*c",strlen(t),0);}

```

# Answer
> 4 votes
# APL (Dyalog) 13.2, 1 byte

Prints only spaces.

prototype (numbers become zeros, characters become spaces)

Try it online!

# Answer
> 4 votes
# Pepe, ~~46~~ 37 bytes

```
REEeRREeeeREEEEErEeeEeeeeerEEeeeEreee

```

Try it online!

**Explanation:**

```
REEe       # Input (string) in R
RREeee     # Push reverse pointer position, or length of input - 1
           # R flag: push in beginning
REEEEE     # ...add 1
rEeeEeeeee # Push space in r
rEEeeeE    # ...R times
reee       # Output whole stack

```

# Answer
> 4 votes
# Poetic, 81 bytes

```
the berenstein bears
i remember a series i spelled wrong
o m gee,i do remember it

```

Try it online!

The misspelling is intentional. (...or *is* it?)

# Answer
> 3 votes
# Gema, 4 characters

```
?=\

```

(There is a space at the end of code.)

Sample run:

```
bash-4.4$ echo -n 'Hello, World!' | gema '?=\ '
             bash-4.4$ echo -n 'Hello, World!' | gema '?=\ ' | wc
      0       0      13

```

# Answer
> 3 votes
# APL (Dyalog), 3 bytes

Prints only newlines.

```
0/⍪

```

Try it online!

table (makes string into column matrix)

`0/` replicate each column zero times

# Answer
> 3 votes
# Scala, 15 bytes

```
s=>" "*s.length

```

# Answer
> 3 votes
# dc, ~~25~~ 18 bytes

-1 byte thanks to brhfl

```
Z[1-d0<L32P]sLd0<L

```

Try it online!

Explanation:

```
Z[1-d0<L32P]sLd0<L
                    Implicit input
Z                   Get length
 [         ]sL      Create a funcion and saves in L
              d0<L  If length > 0, call L
  1-                Subtract 1 from the length
    d0<L            If length > 0, call L
        32P         Print space

```

# Answer
> 3 votes
# shortC, 16 bytes

```
f(C*a){W*a++)P'

```

Note the trailing space at end of code.

Conversions in this program:

* `C` -\> `char`
* `W` -\> `while(`
* `P` -\> `putchar(`

The resulting program looks like this:

```
f(char *a){while(*a++)putchar(' ');}

```

How *that* works:

* `while(*a++)` loops until it reaches the last index of the string `a`.
* `putchar(' ');` prints a space for each index of `a`.

Try it online!

# Answer
> 3 votes
# Java 8, 24 bytes

```
s->s.replaceAll("."," ")

```

Try it here.

# Java 7, 49 bytes

```
String c(String s){return s.replaceAll("."," ");}

```

Try it here.

# Answer
> 3 votes
# Chip, 2 bytes

```
*f

```

Try it online!

Chip reads in a byte, does whatever calculations are in the code, and writes a byte. So, for each byte of input, we ignore the input and write `0x20` instead. The empty Chip program would replace each byte of input with a null byte of output.

```
*    Source element, activates any neighbor elements
 f   Output element for the bit 0x20, when active this bit is set in the output

```

Transposing the two characters would result in the same thing. I opted to use spaces, since `0x20` requires only one bit to be set. `0x0a` requires setting two bits. Code for that could be:

```
b*d

```

# Answer
> 3 votes
# Shell utils, ~~14~~ 12 bytes

```
tr ' -~' ' '

```

tr translates characters in the first parameter, into the corresponding one in the second parameter. (space)-~ is a range for space (32) to tilda (126), the first and last printable ASCII characters. They are mapped into a space; tr duplicates the last character in the output list if it is shorter than the input list.

# Answer
> 3 votes
# Powershell, ~~18~~ 12 bytes

-6 bytes thanks @Julian

```
$args|%{' '}

```

Try it online!

Testscript (use `LF only` mode in your editor):

```
$f = {
$args|% t*y|%{' '}
}

@(
,(13, "Hello, World!")
,(2, "Hi")
,(45, "   Don't
Forget about
Existing
Whitespace!   ")
,(0, "")
,(13, "             ")
,(1,"
")
) | % {
    $len,$source=$_
    $r = &$f $source
    $l=$r.length
    "$($l-eq$len): $l"
}

```

Output:

```
True: 13
True: 2
True: 45
True: 0
True: 13
True: 1

```

## Powershell + Regex, 20 bytes

```
$args-replace'.',' '

```

# Answer
> 3 votes
# Ruby -p, 10 bytes

```
$_=$/*~/$/

```

Try it online!

Explanation:

```
$_=          Output equals
   $/        the output separator (defaults to newline)
     *       repeated a number of times equal to
      ~      the index in the input of the first match of
        /$/  the regular expression for "end of line"

```

# Answer
> 3 votes
# Trilangle, 11 bytes

```
i7#'@"o.:2L

```

Unfolds to this:

```
    i
   7 #
  ' @ "
 o . : 2
L . . . .

```

This has to be the most creative way I've used `@` yet: when hit in one direction, it ends the program; when hit in a different direction, it's divided by 2 to get a space.

Roughly equivalent to this C code:

```
#include <stdio.h>

int main() {
    while (getchar() != EOF) {
        printf(" ");
    }
}

```

# Answer
> 2 votes
# APL, ~~11~~ 6 bytes

*5 bytes saved thanks to @Adám*

```
' '⍴⍨≢

```

Uses the Dyalog Classical character set.

# Answer
> 2 votes
# PowerShell, 21 bytes

```
[char[]]"$args"|%{""}

```

Try it online!

prints newlines.

# Answer
> 2 votes
# Perl 6, 10 bytes

```
{S:g/./ /}

```

Basic string substitution.

# Answer
> 2 votes
# JavaScript (ES8), 22 bytes

```
s=>"".padEnd(s.length)

```

# Answer
> 2 votes
# Convex, 2 bytes

```
,*

```

Try it online!

Simply takes the length of the input and multiplies by newlines (which are at the bottom of the stack)

# Answer
> 2 votes
# Bash, 16 bytes

```
printf %*s ${#1}

```

Try it online!

Uses parameter expansion count the length of the argument `${#1}`, and then `printf` to output an empty string space-padded to that same length.

# Answer
> 2 votes
# Perl 5, 6 + 1 = 7 bytes

Uses the `-p` flag.

```
y// /c

```

`y///` is the transliteration operator: the first list is translated to the corresponding character in the second list. Without the `c`, this does nothing, but the `c` complements the first list, so all characters are transliterated to a space.

# Answer
> 2 votes
# Aceto, 5 bytes

Trivial in Aceto:

```
p
,'O

```

Reads a character, pushes a space, prints it, and goes back to the start.

# Answer
> 2 votes
# q/kdb+, ~~14~~ 9 bytes

**Solution:**

```
{" "}each

```

**Example:**

```
q){" "}each"Hello, World"
"            "

```

**Explanation:**

Returns " " for each character of the input.

**Notes:**

I've made a shorter version (7 bytes) that does something similar:

```
{y}'" "

```

... but you have to prepend the input rather than append:

```
q)"hello world"{y}'" "
"           "

```

# Answer
> 2 votes
# T-SQL, 32 bytes

```
SELECT SPACE(LEN(a+'x')-1)FROM t

```

Microsoft SQL's `LEN` function ignores trailing spaces, so this hacky workaround is required.

Input is stored in `varchar` column **a** in pre-existing table **t**, per our input rules.

# Answer
> 2 votes
# TI-Basic, 13 bytes

```
For(I,2,length(Ans
Disp "
End

```

Loop starts at 2 because an additional newline is printed before `Done` at the end of the program.

# Answer
> 2 votes
# MATL, ~~3~~ 4 bytes

```
nqZ"

```

Try it online!

Today I learnt that MATLAB has a function for creating a string of spaces!

`n` \- count the number of bytes in input string
`q` \- decrement by 1, because the implicit `disp` at the end adds a newline (so the number of spaces required is `string length - 1`)
`Z"` \- `blanks` command: create a string with the specified number of spaces in it
(Implicit output at end, with trailing newline.)

# Answer
> 2 votes
# , ~~37~~ 23 bytes

```
gsub("."," ",scan(,""))

```

Try it online!

14 bytes saved by ngm.

# Answer
> 2 votes
# , 4 bytes

```
LF"0

```

Try it online!

Converts each cell (each character in this case) to the linefeed character. `LF` is a built-in noun for `'\n'`. `"0` attached to a noun converts it to a verb with the given rank.

# Answer
> 2 votes
# Runic Enchantments, 9 bytes

```
" "il͍*@

```

Try it online!

Note that spaces and newlines need to be escaped in the input, as input is automatically split otherwise.

# Answer
> 2 votes
# Cascade, ~~14~~ ~~11~~ ~~9~~ 8 bytes

```
? .'
,^\

```

Try it online!

-1 byte thanks to Jo King realizing it's shorter to just turn into two lines

Since the program never uses the return values of anything other than `,` and `'`, and the order spaces are printed in doesn't matter (since they're indistinguishable), `^` can be used backwards: instead of printing a space then recurring, this recurs then prints a space.

Ungolfed, this looks something like:

```
 @
 ?
 |\
 , \
    ^
   / \
  /   .
 |    \
 |     '
 |

```

If tabs are legal whitespace alongside spaces and newlines:

# Cascade, 7 bytes

```
? .
,^9

```

Try it online!

thanks to Jo King.

# Answer
> 2 votes
# Gol\>\<\>, 5 bytes

```
iEH~a

```

Try it online!

**Explanation**

```
i      Push 1 char from the input to the stack
 E     If EOF was reached execute next, else skip 1
  H    Output the entire stack as chars and halt
   ~a  Discard the last read char and push 0x0a to the stack

```

Since Gol\>\<\> is actually a 2D language the programm counter loops back to the other side when it hits a border. This is used to loop back to the beginning after the discard & 0x0a push step.

# Answer
> 2 votes
# Labyrinth, 6 bytes

```
 ,
\"@

```

Try it online!

A character input command, a newline-printing command, a halt command, and a three-way junction for branching. I don't think we can do better than that. (A conditional halt without a three-way junction should involve division by zero, which gets unnecessarily verbose)

```
    Start at the first valid command
,   Take a character input (-1 on EOF)
"   A no-op at 3-way junction: turn left if negative, turn right if positive
    (we can assume the input string consists of printable ASCII, which is > 0)

\   If positive: print a newline, turn backwards
"   3-way junction: top > 0, so turn right (which is reflected to left by a wall)
,   Repeat from the start of the program until it hits EOF

@   If EOF, halt

```

# Answer
> 2 votes
# GolfScript, 3 bytes

```
,n*

```

Try it online!

pretty self explanatory, and I don't think there is a way to make it smaller unless there is some really weird thing with % or /.

# Answer
> 2 votes
# K (ngn/k), ~~14~~ 13 bytes

```
{x,(1+#x)#""}

```

Try it online!

*-1 byte thanks to ngn!*

Dead simple.

Explanations:

```
{x,(1+#x)#""}    Main function. Takes x as input
 x,              x concat with
          ""     An empty string (Implicit whitespace)
         #       Duplicate with the amount of
   (  #x)        Length of x
    1+           + 1 times

```

# Answer
> 2 votes
# str, 1 byte

```
s

```

Try it online!

Since str manipulates streams byte-by-byte, this outputs 1 `s`pace for each input character.

# Answer
> 2 votes
# makina, 28 bytes

```
v>>>n0;
>wPH
vO*OL
ti ^C
> ;

```

Uses a few clever tricks, like using the space literal to stop the input instruction. Sadly, it's pretty difficult to explain makina, but you can look at the esolangs.org page if you want to figure out how this program works.

# Answer
> 2 votes
# Japt `-m`, 1 byte

```
S

```

Try it

```
S     :Implicit map of each character in input string
S     :Literal space

```

## Less Trivial (w/o flag), 3 bytes

```
r.S

```

Try it

```
r.S     :Implicit input of string
r       :Replace
 .      :RegEx /./g
  S     :With space

```

## Even Less Trivial, 6 bytes

```
©SißUÅ

```

Try it

```
©SißUÅ     :Implicit input of string U
©          :Logical AND with
 Si        :Space prepended with
   ß       :  Recursive call with argument
    UÅ     :    U with first character removed

```

# Answer
> 1 votes
# SmileBASIC 3, 22 bytes

Asks for a string from the console as input, then prints *length* spaces. `PRINT` (or `?` here) adds a trailing newline by default, so we use the `;` to disable it.

```
LINPUT A$?" "*LEN(A$);

```

# Answer
> 1 votes
## Mathematica, 30 bytes

```
Row@Table[" ",StringLength@#]&

```

# Answer
> 1 votes
# Lua, 25 bytes

```
for i=1,#...do
print()end

```

Same length as:

```
io.write((' '):rep(#...))

```

Try it online!

# Answer
> 1 votes
# tcl, 19

```
regsub -all . $s \

```

demo

To test it, click "Run it" button and then select the white space on the white bottom area. A better test is to add a space and a letter before the `]` as I describe:

```
puts [regsub -all . $s \  x]
                        ^^ Two spaces here

```

and it will output the count of characters of each string exactly equal to the ones on the question.

# Answer
> 1 votes
# Rust, 23 bytes

```
|s|" ".repeat(s.len());

```

First time using Rust so not 100% sure I've got everything correct, let me know if I need to change anything. I couldn't work out how to test this, as I'm still new to it, but judging from the documentation it should work. Also any improvements are more than welcome!

# Answer
> 1 votes
# ZX80 (4K ROM version with sanity check)

~58 bytes (listing)

```
 1 INPUT A$
 2 IF A$="" THEN GO TO 1
 3 PRINT " ";
 4 LET A$=TL$(A$)
 5 IF A$="" THEN STOP
 6 GO TO 3

```

Line 2 can be removed to save RAMs. However, if an empty string is entered without line 2 then it will `PRINT` one space.

# Answer
> 1 votes
# Brain-Flak, 28 bytes

```
{{}<>((()()()()()){})<>}<>{}

```

Try it online!

```
{{}                    }     # For every input character...
     ((()()()()()){})        #    Push 10...
   <>                <>      #    on the other stack
                        <>   # Switch to the stack with all of the newlines
                          {} # Pop a newline because the interpreter prints a newline :(

```

# Answer
> 1 votes
# pb \- 17 bytes

```
^w[B!0]{>}<vb[32]

```

Goes to the last character of the input and puts a space on the canvas cell representing it. Because output in pb is 2D, the empty cells before it are automatically filled in with spaces when it's outputted.

# Answer
> 1 votes
# x64 ASSEMBLY (linux nasm) - 131 bytes

```
mov r8, [rsp+16]
mov rdi, 1
mov rdx, 1
mov rax, 1
mov rsi,n
l:syscall
inc r8
cmp byte [r8],0x00
jnz l
mov rax,60
syscall
n: db " "

```

build and run with:

```
nasm -felf64 invisible_golfed.asm
ld invisible_golfed.asm
./a.out

```

This will give the warning

```
ld: warning: cannot find entry symbol _start; defaulting to 00000000000400080

```

warning free version below

**without warnings - 152**

```
global _start
_start:mov r8, [rsp+16]
mov rdi, 1
mov rdx, 1
mov rax, 1
mov rsi,n
l:syscall
inc r8
cmp byte [r8],0x00
jnz l
mov rax,60
syscall
n: db " "

```

# Answer
> 1 votes
# C, ~~57~~ ~~33~~ 30 bytes

-3 thanks to Tas.

```
f(int*a){while(*a++)puts("");}

```

Try it online!

# Answer
> 1 votes
# PowerShell, 18 bytes

```
' '*"$args".Length

```

Try it online!

# Answer
> 1 votes
**Python, 23 bytes**

```
print(''*len(input()))

```

First time

# Answer
> 1 votes
# Lua, 17 Bytes

`s=s:gsub("."," ")`

Simple regular expression substitution, replaces any character found with a space.

# Answer
> 1 votes
# Befunge-98 (PyFunge), 5 bytes

```
#@~a,

```

Try it online!

For every character in the input (`#@~`), this prints a new line (`a,`).

# Answer
> 1 votes
# Z80Golf, 9 bytes

```
00000000: d5cd 0380 3001 763e 20                   ....0.v>

```

Try it online!

Disassembly:

```
  push de     ; push $0000
  call $8003  ; getchar(A)
  jr nc, k    ; jump if not EOF
  halt
k:ld a, ' '   ; replace A with space
              ; memory from $000a through $7fff is $00=NOP...
              ; PC reaches $8000=putchar(A) and RETs to pushed address.

```

(If you remove the last two bytes, this is a `cat` program.)

# Answer
> 1 votes
# Julia 0.6, 15 bytes

```
s->" "^endof(s)

```

Try it online!

`^` applied to strings is the repetition operator, and `endof` gives the last index of the string, which is equal to the length of the string (since Julia indexing is 1-based).

# Answer
> 1 votes
# dc, 12 bytes

```
Z256r^25.5/P

```

Try it online!

Takes input from the stack, outputs **newlines** to stdin.

I know there's two dc answers here already, but this one uses a different approach, with math! Plus it's 6 bytes shorter, so I guess that's all right.

# Explanation

One of dc's three explicit printing commands is `P`, which takes a number and outputs it as a base 256 (technically base UCHAR\_MAX+1, works on my machine) byte stream. So I need to feed it the number (where `n` is the length of the given string, and `10` is the codepoint of the linefeed character):

```
   10*256^(n-1) + 10*256^(n-2) + ... + 10
 = 10 * (256^(n-1) + 256^(n-2) + ... + 1)   (factoring out 10)
 = 10 * (256^n - 1) / (256 - 1)             (geometric series formula)
 = (256^n - 1) / 25.5                       (combining constants)
~= (256^n) / 25.5                           (because dc's default precision is 0)

```

The code is a straightforward calculation of this number, followed by `P`.

# Answer
> 1 votes
# Octave / Matlab, ~~25~~ 23 bytes

```
@(x)repmat(' ',size(x))

```

Saved 2 bytes thanks to Giuseppe

Try it online!

# Answer
> 1 votes
# Java (JDK), 84 bytes

```
static String m(String n){int i=0;String d="";while(i++<n.length())d+=" ";return d;}

```

Try it online!

# Answer
> 1 votes
# Keg,`-lp` `-ir`, 3 bytes

```
( ,

```

Try it online!

This takes input as characters and prints a space for each character The `-lp` flag makes the `length()` function take input if the stack is empty and the `-ir` flag ensures that the implicit input is as characters.

# Answer
> 1 votes
# Wren, 22 bytes

Multiply the space by the length of the string.

```
Fn.new{|a|" "*a.count}

```

Try it online!

# Answer
> 1 votes
# Brain-Flak, 28 bytes

```
{}{{}<>((()()()()()){})<>}<>

```

Try it online!

```
{}                  pop one input character (because Brain-Flak always outputs a trailing newline
{                   for each input character
  {}                pop that character
  <>                switch to other stack
  ((()()()()()){})  push 10 (newline)
  <>                back to input stack
}
<>                  switch to other stack. This is printed implicitly when the program ends

```

# Answer
> 1 votes
# x86-16 ASM, IBM PC DOS, 11 bytes

**Binary:**

```
00000000: 8a0e 8000 49b8 200a cd10 c3              ....I. ....

```

**Unassembled:**

```
D1 EE       SHR  SI, 1          ; SI to 80H (SI intialized at 100H)
AC          LODSB               ; load string length into AL
91          XCHG AX, CX         ; put input string length into CX
49          DEC  CX             ; remove leading whitespace from length
AC          LODSB               ; load whitespace delimiter into AL
B4 0A       MOV  AH, 0AH        ; BIOS "write character CX number of times" function
CD 10       INT  10H            ; call BIOS, display to console
C3          RET                 ; return to DOS

```

**Explanation:**

Input is via command line, though all that's important is the length. Command line input length is always stored at memory address `DS:0080H` in DOS, so put that into `CX`. DOS includes the space between the executable name and the command line args string in this number.

For example: in `FOO.COM Hello`, length is 6 and command line string is `" Hello"`, or calling as `FOO.COM/Hello`, command line string is `"/Hello"` (Note: those are the the only valid characters for the character immediately after the executable name). This first character (will be a space when called normally) is what is displayed as the "invisible text" for output. This builds in a handy little "debug mode" where you can use a slash instead of a space to actually be able to test your output is the right length.

Then, use the IBM PC BIOS's INT 10H "Write character only at cursor position" (`0AH`) function that writes the same character `CX` number of times.

**Example Output:**

Admittedly, displaying 13 chars of whitespace is not very interesting in a screenshot. However, by using a slash instead of a space ("debug mode") you can actually see that you are displaying the right number of chars.

# Answer
> 1 votes
# naz, 40 bytes

```
2a2x1v1x1f1r3x1v2e0m4a8m1o1f0x1x2f0a0x1f

```

Works for any input string terminated with the control character STX (U+0002).

**Explanation** (with `0x` commands removed)

```
2a2x1v                 # Set variable 1 equal to 2
1x1f1r3x1v2e           # Function 1
                       # Read a byte of input
                       # Jump to function 2 if it equals variable 1
            0m4a8m1o1f # Otherwise, output a space and jump back to the start of function 1
1x2f0a                 # Function 2
                       # Add 0 to the register
1f                     # Call function 1

```

# Answer
> 1 votes
# GolfScript, 5 bytes

Port of CJam answer.

```
," "*

```

Try it online!

# Answer
> 1 votes
# Ahead, 12 bytes

```
S0d3-' \k:W@

```

Try it online!

# Answer
> 1 votes
# Python 3, 23 bytes

```
print(' '*len(input()))

```

Try it online!

# Answer
> 1 votes
# Java, 24 bytes

```
s->s.replaceAll("."," ")

```

TIO

# Answer
> 1 votes
# Flurry `-bnb`, 42 bytes

```
[]{(){}{}}[]{({})}<((({<({}){}>})){}){}{}>

```

Try it online!

### Run example (using Haskell interpreter)

```
$ printf "Hello World!" | ./flurry -bnb a.flr

$ printf "Hello World!" | ./flurry -bnb a.flr | wc -c
12

```

It takes 24 bytes just to construct a single space (32): `<((({<({}){}>})){}){}{}>`. Even worse is that it takes 2 more byets to construct a single newline (10): `(<><<>()>)<(<({}){}>{}){}>`...

The algorithm is: empty the stack, preserving the value of stack height, and then push space that many times.

```
main = height pop-I height push-I 32

// Return self, popping and discarding one item from stack
pop-I = \x. K x pop
// (height pop-I height) returns original stack height with
// the stack emptied as a side effect

// Return self, pushing itself to the stack once
push-I = \x. push x

32 = 2**2 * 2**2 * 2
= <(2 2)(2 2)2>
= <(push ((push (push 2)) pop)) pop pop>

```

# Answer
> 1 votes
# Rockstar, 27 bytes

```
listen to S
cut S
say " "*S

```

Try it here (Code will need to be pasted in)

Replace the last line with the below to wrap the output in single quotes.

```
say "'"+" "*S+"'"

```

# Answer
> 1 votes
# Husk, 4 bytes

```
R' L

```

Try it online! (Note: prints `x`s instead of spaces so that the output is visible; change the `x` to  to \[not\] see the real version)

# Answer
> 1 votes
# Nim, 38 bytes

```
for _ in stdin.readAll:stdout.write" "

```

Try it online!

Since Nim is *style-insensitive*, something like this also works:

```
fOr _ iN sTdIn.rEaDaLl:sTdOuT.wRiTe" "

```

Try it online!

# Answer
> 1 votes
# 05AB1E, 3 bytes

```
gð×

```

Try it online!

```
gð×  # full program
 ð   # a space...
  ×  # repeated...
g    # length of input...
  ×  # times

```

# Answer
> 1 votes
# Vyxal, 2 bytes

```
LI

```

Try it Online!

# Vyxal `S`, 2 bytes

Try it Online!

### If we want to port the Jelly answer, then:

# Vyxal `rs`, 3 bytes

```
fð•

```

Try it Online!

# Answer
> 1 votes
# C (gcc), ~~50~~ 36 bytes

Totally pays off that `printf` doesn't automatically print a newline.

36 bytes by ceilingcat

```
f(char*n){for(;printf(" "+!*n++););}

```

# Answer
> 1 votes
# Nibbles, 2.5 bytes (5 nibbles)

```
.$' '

```

A function that returns a string of spaces the same length as its argument.
(This won't work as a full program, since Nibbles will write a newline at the end of its output).

```
.                   # map over
 $                  # characters of the argument
  ' '               # returning a space for each

```

Obviously the output is invisible, but we can call this function from within a program that wraps the output into quotes to see the output string:

```
;~                  # save this function:
  .$' '             # <convert to invisible text>
         :'"'$      # prepend saved function results with a quote
        :     '"'   # and append that with another quote

```

---

# Nibbles, 3.5 bytes (7 nibbles)

```
>>.$' '

```

Full program. We can't stop Nibbles from writing the trailing newline at the end of its output, so we shorten the invisible string by one character.

```
  .                 # map over
   $                # characters of the argument
    ' '             # returning a space for each
>>                  # and then remove the first character

```

# Answer
> 1 votes
# Python 3, 36 bytes

```
lambda x:re.sub('.',' ',x)
import re

```

Try it online!

# Answer
> 1 votes
# Go, 66 bytes

```
import."strings"
func f(s string)string{return Repeat(" ",len(s))}

```

Attempt This Online!

As far as I'm aware, you can't multiply strings and numbers to repeat a string in Go - you have to use `strings.Repeat`.

# Answer
> 1 votes
# (,) ~~40~~ 34 Chars or \\$34\log\_{256}(3)\approx6.74\\$ Bytes

```
(,,,()()()()()()()()()(),((()())))

```

Or, printing spaces (54 Chars or 10.7 Bytes):

```
((),()()()()()()()())(,,,(())(())(())(()),((()())),())

```

# Answer
> 1 votes
# TI-BASIC, 27 bytes

```
Input Str1
For(X,1,length(Str1
Disp "
End

```

I love TI-84 because it completes my parentheses and quotes for me.
At the same time, it is quite annoying indeed how there is no string repeat (as far as I know). ~~Even more annoying is that (as far as I know) all input is int not str and any text passed will result in a single newline. I hope this is still valid despite that.~~ That was my bad. I was using an int variable.

Bytecount on TI-BASIC is kind of complex, the best way that I know of is going to TI Connect \[CE\] and looking for your program there.

*Explained:*

```
Input Str1                Ask for input and store in string variable

  length(Str1             Length of Str1
For(X,1,...               Loop through following code that many times
Disp "                    Display a blank string (with newline)
End                       End loop, go back to the For.

```

### Test cases:

Typing on a TI-84 Plus CE is hard.
In these examples "-" is displayed instead of newline so you don't have to count.

# Answer
> 0 votes
# REXX 27 Bytes

```
say left("",length(arg(1)))

```

# Answer
> 0 votes
# Powershell, 22 Bytes

```
' '*(Read-Host).length

```

# Answer
> 0 votes
TXR Lisp, ~~22~~ 19 bytes:

```
(op regsub #/./" ")

```

Previously:

```
(op mapcar(ret[" "0]))

```

That is a function to which we can pass a string:

REPL:

```
1> (op regsub #/./" ")
#<interpreted fun: lambda #:rest-0164>
2> [*1 "abc"]
"   "

"   "

```

# Answer
> 0 votes
# Clojurescript, 27 bytes

```
#(apply str(map(fn[]" ")%))

```

Because it's based on js, clojurescript doesn't care about arity errors. That saves one byte over the clojure eqivalent.

# Answer
> 0 votes
# Windows batch, 115 bytes

```
@set i=%~1
@set p=0
@set/ac=-1
:N
@call set t=%%i:~%p%,1%%
@set/ac+=1
@set/ap+=1
@if "%t%" NEQ "" @goto N
@echo %c%

```

*Re-used code from my answer in* ***Is the checkbox not not unchecked?***

# Answer
> 0 votes
# Ruby, ~~12~~ 11+1 = ~~13~~ 12 bytes

Uses the `-p` flag. -1 byte from Martin Ender.

```
gsub /./,$/

```

Try it online!

# Answer
> 0 votes
## Check, 6 bytes

```
," "*o

```

Pass the input by the command-line arguments as a list of code points, i.e. `[72,101,108,108,111,44,32,87,111,114,108,100,33]`.

Explanation:

* `,` gets the length of the input.
* `" "` pushes an array containing `32` (for space).
* `*` repeats that array as many times as the length of the input.
* `o` displays the result as a list of characters.

# Answer
> 0 votes
**Bash + Coreutils, 11 Bytes**

`tr -c \ \`

# Answer
> 0 votes
# , 6 bytes

```
' '#~#

```

Try it online!

## Explanation

```
' '#~#
   #~    repeat
' '      spaces
     #   for length of input

```

# Answer
> 0 votes
# Common Lisp, 32 bytes

```
(format t"~va"(length(read))#\ )

```

Try it online!

# Answer
> 0 votes
# Carrot, 12 bytes

```
#^//()/gS" "

```

Try it online! (append a `^@^v@` after the code to see the spaces bounded between `@`s)

### Explanation

```
#^            Set the stack-string to be equal to the input
/             Get matches of this regex
 /()/g         any position (not character) in the string (shorter than /\b|\B/ by 3 bytes)
              If the length of the string is 3, this returns a 4-element array
               consisting of empty strings
S" "          Join on spaces, so the example 4-element array will result in 3 spaces

```

The space can even be replaced with a literal newline or tab for the same bytecount.

# Answer
> 0 votes
# dc, 18 bytes

```
?Zd[9P1-d0<r]sr0<r

```

Try it online!

# Answer
> 0 votes
# Ly, 9 bytes

```
iy[' o,];

```

Try it online!

Explanation:

```
iy[' o,];

iy        # push length of input
  [    ]  # while loop
   ' o    # output a space
      ,   # decrement input length
        ; # terminate (avoids implicit output)

```

# Answer
> 0 votes
# RProgN 2, 3 bytes

```
L•*

```

Uncreative solution is uncreative.

Just gets the length of the input, and multiplies , which is predefined to be a space, by it.

Try it online!

# Answer
> 0 votes
# Jq 1.5, ~~69~~ ~~68~~ ~~66~~ 64 bytes

```
def L:length;$x|if L<1then empty elif L<2then""else L-1|.*" "end

```

This is longer then usual to compensate for newline jq normally emits and the odd behavior of `*` with N\<2

Sample runs:

```
$ jq -Mrn --arg x 'Hello, World!' 'def L:length;$x|if L<1then empty elif L<2then""else L-1|.*" "end'

$ jq -Mrn --arg x 'Hello, World!' 'def L:length;$x|if L<1then empty elif L<2then""else L-1|.*" "end' | wc -c
      13
$ echo -n 'def L:length;$x|if L<1then empty elif L<2then""else L-1|.*" "end' | wc -c
      64

```

Shout out to Jonathan Frech for finding 3 superfluous spaces!

# Answer
> 0 votes
# Vim, 4 bytes

```
VGr

```

(a trailing space)

# Answer
> 0 votes
# Yabasic, 37 bytes

Takes input, and outputs as many new lines as the length of the input

```
Line Input""s$
For i=1TO Len(s$)?Next

```

Try it online!

# Answer
> 0 votes
# C# .NET, 84 bytes

```
class P{static void Main(string[]a){System.Console.Write("".PadLeft(a[0].Length));}}

```

Try Online

# Answer
> 0 votes
# Kotlin, 20 bytes

```
{" ".repeat(length)}

{" ".repeat           // repeat space
           (length)}  // length of input

```

Try it online!

# Answer
> 0 votes
# Vyxal, 3 bytes

```
Lð*

```

Try it Online!

Command-line usage:

```
python3 Vyxal.py file_name "" input_string

```

## Explained

```
L    # Push the length of the implicit input
  ð  # Push a space character
   * # Multiply that space by the length and output.

```

# Answer
> 0 votes
# Forth (gforth), 9 bytes

```
typewhite

```

Try it online!

It is a gforth built-in. A string in gforth is commonly represented as `addr length`, and `typewhite` consumes `addr length` and prints `length` spaces.

# Answer
> 0 votes
# Add++, 21 bytes

```
D,f,@@,bL*
$f>" ">?
o

```

Try it online!

# Answer
> 0 votes
# Duocentehexaquinquagesimal, 7 bytes

```
1Â×^c¤E

```

Try it online!

# Answer
> 0 votes
# Zsh, 12 bytes

```
<<<${1//?/ }

```

Try it online!

* `<<<`: print
* `${1}`: the input,
* `///`: replacing
* `?`: any character
* : with a space

# Answer
> 0 votes
# Factor, 20 bytes

```
[ [ drop bl ] each ]

```

Try it online!

For each character in the input string, drop it from the data stack and output a space.

# Answer
> 0 votes
# Fig, \\$4\log\_{256}(96)\approx\\$ 3.292 bytes

```
;M/

```

Try it online!

Note the space at the end.

```
;M/<space>
;M         # Replace all in the input
  /<space> # With a space
;          # Print without newline

```

# Answer
> 0 votes
## Pascal, 82 B

This `program` merely requires a processor complying to ISO standard 7185 “Pascal”. Since it is not guaranteed that `writeLn` produces exactly one character (on some platforms the line separator is `CR+LF`), we’ll have to use `write(' ')`:

```
program p(input,output);begin while not EOF do begin write(' ');get(input)end end.

```

If input was simply a `string` value, when an ISO standard 10206 “Extended Pascal” processor is used the following is the shortest solution (**≥ 24 B**):

```
writeStr(outputStringVariable, '':length(inputMyString))

```

The `:someNonNegativeIntegerValue` after the empty string `''` will (left) pad the given argument to the specified width using space characters (`' '`). A complete demonstration:

```
program paddingDemo(output); begin write('':length('Hello, World!')) end.

```

# Answer
> 0 votes
# Thunno, \\$ 6 \log\_{256}(96) \approx \\$ 4.94 bytes

```
L1-A_*

```

Attempt This Online!

Note: `A\` will also work instead of `A_` if you want newlines rather than spaces.

#### Explanation

```
L1-A_*  # Implicit input
L       # Length
 1-     # Minus one
     *  # Multiplied by
   A_   # A space
        # Implicit print
        # with a newline

```

# Answer
> 0 votes
# Thunno 2, 3 bytes

```
l⁻ṣ

```

Attempt This Online!

#### Explanation

```
l⁻ṣ  # Implicit input
l    # Length
 ⁻   # Decrement
  ṣ  # Spaces
     # Implicit output with newline

```

---
Tags: code-golf, string
---


title: Overlapping Polyglots

text:
# Question
Title: Overlapping Polyglots
*Unlike many C&R challenges, this does not require a separate robbers post; the goal of the robbers is to crack the previous answer and then post a new one as a cop.*

As answerers, you will write a series of polyglots that look like this (each column is a language, and each entry is the output of the answer in that language):

```
Language:  1  2  3  4  5  6  7  8  ...
Answer 1:  0  1  2
Answer 2:     1  2  3
Answer 3:        2  3  4
Answer 4:           3  4  5
Answer 5:              4  5  6
Answer 6:                 5  6  7
...

```

(blank spaces mean that no behavior is required in that case).

Each answer should work in 3 languages and print 3 different consecutive numbers which are each one more than the numbers printed by the previous answer (the first answer prints `0`, `1`, and `2`). Each answer uses two languages from the previous submission, and a third new language. The answerer should try to obfuscate what this third language is.

To post a new answer, you should:

* Crack the most recent answer by finding what its third language is.
* Preferably, add an explanation for your crack and notify the poster of the answer. Once your submission has been cracked, you should preferably add an explanation as well.
* Write a polyglot consisting of this answer's second and third languages, along with another language of your choice. Reveal your first two languages, but do not reveal your new one. It will be the next poster's goal to find this language (or any other language in which it works), so you should try to obfuscate it.

## Specifications

* The criteria for a valid programming language are the same as those of The Programming Language Quiz, Mark II - Cops:

>
* Each answer must run in less than a minute on a reasonable PC.
* You *can* reuse programming languages, but there must be at least two answers in between (so an individual answer cannot reuse a language).
* Cracking a submission consists of finding *any* programming language that prints the correct result, not just the intended one. If a submission is run in any language that was not declared or found to work, there are no requirements to do anything.
* You may not post twice (or more) in a row.

## Winning Criterion

The winning answer is whichever answer took to most time to be cracked. The challenge will never end, so it is always possible for the winning answer to change.

# Answer
> 14 votes
# Hexagony, Klein (101) and ???

```
  xx={puts/}
gets87!@xx=p

main\

>9.*5,6v

```

This prints `7` in Hexagony, `8` in Klein (101), and `9` in ???.

The `9` does not work if a newline is added at the end of the code. Be careful if you're testing locally.

**Edit:** Being live for 20 hours is already a record, so I'll give some hints from now on. (Also because the language in question is IMO not yet well-known.)

### Hints

1. "The `9` does not work if a newline is added at the end" is *very* significant, as well as the first two spaces (which are ignored by both Hexagony and Klein).
2. The language is on TIO.
3. The first two spaces make the program jump to the last line. (It's *not* a 2D language.)
4. There's no explicit output command, and the `v` command ends the program.

### Explanation (cracked post)

In the source code

```
abcd={} -- a gaffe avoiding tactic in C++/C#
abcd[!1]=   1+2+3+4+5+6+7+8+9+10+11+12+13+17!
print(abcd[0>1+2+3 and 4+8+6<0-0]//35)
if 0>1 then a.next=';' en\
                    >1+6.@.@

```

The relevant instructions in Klein (101) are:

```
IP->.....................^...........IP->/
.........................|...................
.........................8
.........................\<-.............IP<-
                         @

```

Klein is fungelike 2D language where crossing the boundary of code area (which is a square) depends on the Klein topology. `/` and `\` are mirrors.

The IP starts at upper left corner facing right. It meets a mirror towards the top boundary, and re-enters the code area on the right side as shown above. Then it hits the mirror again, 8 is pushed, and then (after passing through the boundary several times) stops at `@`. Then the content of the stack is printed to stdout, which is single 8.

# Answer
> 10 votes
# Befunge-96, Hexagony and ???

```
abcd={} -- a gaffe avoiding tactic in C++/C#
abcd[!1]=   1+2+3+4+5+6+7+8+9+10+11+12+13+17!
print(abcd[0>1+2+3 and 4+8+6<0-0]//35)
if 0>1 then a.next=';' en\
                    >1+6.@.@

```

This prints `6` in Befunge-96, `7` in hexagony and `8` in ???.

### Explanation

The hexagony code, when "prettified" is:

```
       a b c d = { } -
      - a g a f f e a v
     o i d i n g t a c t
    i c i n C + + a b c d
   [ f a l s e ] = 1 + 2 +
  3 + 4 + 5 + 6 + 7 + 8 + 9
 + 1 0 + 1 1 + 1 2 + 1 3 + 1
7 ! p r i n t ( a b c d [ 0 >
 1 + 2 + 3 a n d 4 + 5 + 6 <
  0 - 0 ] / / 3 5 ) i f 0 >
   1 t h e n a . n e x t =
    ' ; ' e n d > 1 + 6 .
     @ . . . . . . . . .
      . . . . . . . . .
       . . . . . . . .

```

The path of execution begins in the top left heading East. The top row doesn't do much. `-` changes the current memory edge so the value in it is `0`. Execution continues heading east on the middle row where `7!` loads `7` in the current memory edge and prints is as an integer. `[` changes the instruction pointer to North East starting back at `7`. After `7+3`, execution then reaches `[` which changes the instruction pointer to North West starting in the South East corner. Finally the path is `..@` where `@` terminates the program.

# Answer
> 9 votes
# Trigger, JavaScript and ???

```
[ //aТ/\\ ][ //е"6
console.log(111-111+12)]
//!'!/-²6-²52

```

Prints `11` in Trigger, `12` in JavaScript, and `13` in ***`REDACTED`***.

Since this has not been cracked for longer than any other answer so far, here are some hints:

* In case you didn't notice, the `Т` and `е` on the first line are multibyte characters.
* `[ //` and `\\ ][ //` are no-ops.
* The second line, as well as `-²52`, is dead code.
* The language does not have a concept of termination, so `²6` forms an infinite loop.
* To be specific, the second byte of the UTF-8 encoding of `²`, together with the `6`, forms an infinite loop.
* The number being outputted is encoded by the `/!'!/`
* The language is not on Try It Online, Rosetta Code or Esolangs.
* The only available form of output is a 1bpp screen.
* The screen's aspect ratio is 2.
* While the language was not originally intended as machine code, FPGA implementations do exist.
* According to Wikipedia, the intended purpose of the language were video games.
* The only way to access the screen is a special instruction, that takes coordinates in selectable registers, and the height as an immediate, and XORs an 8 by n bitmap onto the screen. To make collision detection easier, as well as make it possible to clear the screen, one of the registers will be set when any pixel gets set back to off.

## Explanation

Well, this took some time to get cracked. Let's see how the code looks:

```
0200 5b20    SE VB, V2   ; Skip the next instruction if VB = V2. Since all
0202 2f2f    CALL 0xF2F  ; registers start at 0, this call will be skipped. This
                         ; hides the bytecode from JavaScript.
0204 61d0    LD V1, 0xD0 ; A useless load. Necessary to use a UTF-8 continuation
0206 a22f    LD I, 0x22F ; byte as an instruction and load the address of
                         ; the sprite.
0208 5c5c    SE VC, V5   ; A red herring supposed to suggest symmetry is
                         ; important, as well as a totally intended eliminator
                         ; of inaccurate implementations. Most documentation
                         ; claims that the lowest nibble must be zero, but in
                         ; the original COSMAC VIP implementation it's
                         ; a don't-care.

```

This means that, while many available emulators behave correctly, the by-the-rules implementation is linked to in the second sentence of the Wikipedia page. Of course, it can't be run directly on an average PC, but I've found the Emma 02 emulator linked to on the COSMAC VIP page to work the best.

```
020A 205d    CALL 0x05D    ; Skipped.
020C 5b20    SE VB, V2     ; Same as with the very beginning. Red herring.
020E 2f2f    CALL 0xF2F
0210 d0b5    DRW V0, VB, 5 ; Draw the sprite pointed to by I. Since V0 and VB
                           ; haven't been written to yet, the sprite will be drawn
                           ; in the top-left corner of the screen. The height is
                           ; an immediate.
0212 2236    CALL 0x236    ; Jump over the JavaScript and Trigger code. It doesn't
                           ; matter that we never return.
0214-022E *never used*
022F 2f      DB %00101111  ; Sprite data.
0230 21      DB %00100001
0231 27      DB %00100111
0232 21      DB %00100001
0233 2f      DB %00101111
0234-0235 *never used*
0236 b236    JP V0, 0x236  ; Since V0 is still zero, this is an infinite loop.
0238-023C *never used*     ; Together with the previous two lines, it's the
                           ; -²6-²52. It's a red herring supposed to suggest
                           ; prefix, or Polish, notation.

```

# Answer
> 8 votes
# Python 2, Python 3, ???

```
a={1,2}
print(1+#a
--bool(1/2)
)

```

This prints 1 in Python 2, 2 in Python 3, and 3 in ???.

Crack explanation (Cracked post):

```
#define print(A) main(){puts("0");}
print(1+bool(1/2))

```
* `0`: C: The first line defines a function-like macro `print` that ignores its single argument and evaluates to `main(){puts("0");}`, a full program that prints `0` and exits. The whole expression `1+bool(1/2)` is ignored when the `print( )` macro on the second line is expanded to `main(){puts("0");}`.
* `1`: Python 2: The first line is a comment. `1/2` uses integer division in Python 2, giving 0. This value is then interpreted as a boolean (`bool(0)` -\> `False`) and then added to `1` (`1+False` -\> `1`), and then printed.
* `2`: Python 3: The first line is a comment. `1/2` uses float division in Python 3, giving 0.5. This value is then interpreted as a boolean (`bool(0.5)` -\> `True`) and then added to `1` (`1+True` -\> `2`), and then printed.

# Answer
> 8 votes
# Lua, brainfuck, ???

```
abcd={} -- a gaffe avoiding tactic in C++
abcd[false]=1+2+3+4+5+6+7+8+9+10+11+12+13+14
print(abcd[0>1+2+3 and 4+5+6<0-0]//35)
if 0>1 then a.next=';' end
```

Prints 3 in Lua, 4 in brainfuck and 5 in ???.

Explanation for cracked post:

```
a=1+2+3+3+4+5+6+7+8+9
b=1+1+1
f=3--(-1)
c=7+9+13+11+12+3--1
g=a+b+c+1+2+3+4+5
j=9+7+g+c+b+a+g+g+g+g+g+g+1+2+3+4+1+1
h=1+1+1+1+333+1+1+1+111+1+1+1+333+1+1+1+1+1.
print(f)
```
* In Python 3, `3--(-1)` is 2, so `print(f)` prints 2 (the other stuff is unnecessary)
* In Lua, `--` again is a comment, so `3--(-1)` is just 3, so `print(f)` prints 3 (other stuff is again unnecessary)
* In brainfuck, there are 57 plusses and 5 minuses setting the first cell on the tape to 52, and the `.` outputs character 52 which is 4.

# Answer
> 8 votes
# JavaScript, CHIP-8, and ???

```
[ //aТ/\\ ][ //е"6
console.log(111-111+12)]
//!'!/-²6-²52@++++2345

```

`12` in JavaScript, `13` in CHIP-8, and `14` in ???

I'm going to go out on a limb and call this one cracked, although I can't quite get it to work I'm sure of the language (which seems to be what the rules ask for.)

Here is an imperfect explanation of the cracked post

The code in hexadecimal "is" (I might be slightly off):

```
[ 0x5b, 0x20, 0x2f, 0x2f, 0x61, 0xD0, 0xA2, 0x2f, 0x5c,
0x5c, 0x20, 0x5d, 0x5b, 0x20, 0x2f, 0x2f, 0xD0, 0xB5,
0x22, 0x36, 0x0a, 0x63, 0x6f, 0x6e, 0x73, 0x6f,
0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x31,
0x31, 0x31, 0x2d, 0x31, 0x31, 0x31, 0x2b, 0x31,
0x32, 0x29, 0x5d, 0x0a, 0x2f, 0x2f, 0x21, 0x27,
0x21, 0x2f, 0x2d, 0xb2, 0x36, 0x2d, 0xb2, 0x35, 0x32 ]

```

You can go here, click "Binary Tools" and paste this into the byte array box. Click "Decompile".

The key elements of the code are: instructions to say where the "number" is, the `sprite` command that prints the number, the correct amount of junk here and there, and the following:

```
: label-0
    0x2F
    0x21
    0x27
    0x21
    0x2F

```

To see what this represents you can click "Sprite Editor" and paste these hexadecimals into the box underneath. You'll see the answer:

I'm pretty sure you can then put anything you like at the end and the CHIP-8 result will not change, hence the new entry.

I would be delighted if someone could get this fully working, rather than the "proof" of the answer I've given here.

# Answer
> 6 votes
# C, Python 2, ???

```
#define print(A) main(){puts("0");}
print(1+bool(1/2))

```

This prints `0` in C, `1` in Python 2, and `2` in ???.

This will be extremely easy to crack for people who know Python, but I wanted a starting-off point for other answers. Subsequent answers should try to obfuscate the third language (I did not do this).

# Answer
> 6 votes
# Python 3, Lua, ???

```
a=1+2+3+3+4+5+6+7+8+9
b=1+1+1
f=3--(-1)
c=7+9+13+11+12+3--1
g=a+b+c+1+2+3+4+5
j=9+7+g+c+b+a+g+g+g+g+g+g+1+2+3+4+1+1
h=1+1+1+1+333+1+1+1+111+1+1+1+333+1+1+1+1+1.
print(f)

```

Prints 2 in Python 3, 3 in Lua and 4 in ???.

Explanation for cracked post:

```
a={1,2}
print(1+#a
--bool(1/2)
)

```
* In Lua, -- is a comment. In Python 2 and 3, -- indicates double negative in arithmetic.
* In Python 2 and 3, # is a comment. In Lua, # is the length operator.
* In Python 2, 1/2 is floor division, so it evaluates to zero. In Python 3 this is not the case. Because both versions of Python evaluate 0 to False, bool(1/2) evaluates to False in Python 2 and True in Python 3. When used in arithmetic, False is cast to 0 and True is cast to 1.

# Answer
> 6 votes
# Beatnik, Rust, ???

```
fn avreg(){}
fn/*azxzzz avreg k zqyzzz ax quke
>>P0 ++puts++puts[pov]
\@�{>*}++puts++puts++puts++puts++puts++puts++puts++puts%
*/main(){print!("17")}

```

This prints 16 in Beatnik, 17 in Rust, and 18 in ???.

The  character on line 4 should be replaced with ASCII character 18 (this was not done in the TIO links since it's not relevant to either of them).

## Explanation (cracked):

The previous answer's language was Rust: specifically, Rust compiled with mrustc. mrustc is an experimental compiler, and as it is mostly intended for bootstrapping a valid version of `rustc`, it ignores borrow checking and mutability checking, allowing @NieDzejkob's snippet to compile without errors.

This program will work with the normal Rust compiler, so you don't need to install mrustc to test it.

## Hints

Since this answer has now gone the longest without being cracked, I'll leave a hint, and continue to do so regularly until it is cracked:

* The secret language is two-dimensional and can be found on the Esolang wiki page for two-dimensional languages.
* As I mentioned in the comments, the language is not on TIO.
* The  character is a red herring and has very little significance. Most bytes can be substituted in its place and the program will still work.

# Answer
> 5 votes
# \>\<\>, Befunge-96 and ???

```
abcd={} -- a gaffe avoiding tactic in C++
abcd[false]=1+2+3+4+5+6+7+8+9+10+11+12+13+17!
print(abcd[0>1+2+3 and 4+5+6<0-0]//35)
if 0>1 then a.next=';' end
                    >1+6.@

```

This prints 5 in `><>`, 6 in `Befunge-96` and `7` in ???.

I know the intended solution was Befunge-93, but I couldn't resist.

### Explanation:

Befunge-96 follows the same path as `><>`, but ignores unknown instructions, ending up adding one to the 5 and multiplying it by 9 to get 54, the ascii code for `6`.

# Answer
> 5 votes
# Klein (100), Commentator, ???

```
/@++++2345
start:
program:
 db 'function',10
 add program,program
 jp null+$8
 sbc rbp,rbp
 jnz program
 jr program
 add start
 halt
ex:

```

Outputs 14 in Klein (100), 15 in Commentator, 16 in ???.

I'm seriously bad at obfuscating polyglots.

### Explanation (Cracked post)

```
 %/    <#> 13
        14
 +   15

```

In Commentator, common comment tokens and spaces are the important commands, and any other characters are ignored.

* Space increments the current memory cell.
* `<#` does XOR 1 on the current memory cell.
* `%` is used to reset the current memory cell to zero.

Wait, there are 16 spaces after `%`, what happened?

It's actually a small bug (or feature?) in the interpreter. `/` is treated as the start of a 2-char command, so the space after it is consumed. But `/<space>` is undefined command (thus a no-op), so the space is effectively skipped.

# Answer
> 5 votes
# Commentator, Beatnik, ???

```
// k... nak... naKaka pagpAbaGaBag
static answer: Option<&String> = None;

fn llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch(s: &String){
  answer = Some(s);
}

fn pneumonoultramicroscopicsilicovolcanoconiosis(){
  println!("{}", answer.unwrap());
}

fn main(){
  let s = String::from("17");
  let t = "Hi! I am a cat. AOOOWRRRWWW! Me need Whiskas! Noow! Mee hungry hast bekommen. Feedme! sudo !!. Sad... six cable hostage wire cable diediediediee #               */";
  llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch(&s);
  pneumonoultramicroscopicsilicovolcanoconiosis();
}

```

Outputs 15 in Commentator, 16 in Beatnik, and 17 in the hopefully one language you are supposed to find.

Okay, it's clue time:

* The name of the language refers to a compound of two elements, both of which make up your body, but with wildly varying percentages (which way depending on whether you're a robot).
* The language itself is on TIO, but the implementation isn't.
* Oh come on.

# Answer
> 4 votes
# Brainfuck, \>\<\>, and ???

```
abcd={} -- a gaffe avoiding tactic in C++
abcd[false]=1+2+3+4+5+6+7+8+9+10+11+12+13+14
print(abcd[0>1+2+3 and 4+5+6<0-0]//35)
if 0>1 then a.next=';' end
                    >1+9*,@

```

Prints `4` in Brainfuck, `5` in \>\<\>, and `6` in ???

* In brainfuck, nothing changes.
* In \>\<\>, `v` redirects the flow of the program downwards. The `n` is **n**umeric output. `;` ends execution.

# Answer
> 4 votes
# Klein (101), Z80Golf, ???

```
!!8@e6v+4>9 \
Almost everything you can find on the internet is true
~Albert Einstein
 ~HUMAN IMAGE MACROS

```

Prints `8` in Klein (101), `9` in Z80Golf, and `10` in ???.

# Answer
> 3 votes
# Z80Golf, Somme, ???

```
!!8@e6v+4>9 \
1((111+111)/111)
00
~tz

```

This prints 9 in Z80Golf, 10 in Somme and 11 in ???.

Credit to Bubbler for cracking the previous post as Somme, which takes the column sum as the instructions. The first three columns evaluate to

```
A.;

```

Which pushes 10, prints it and exits.

# Answer
> 3 votes
# Somme, Trigger and ???

```
[,,E,D,,$,H,_,K,,$,,_,F,L]=!
[]+[]+!![]+[][111]
_=[111][F+L+E+E];[,J,,A,I,,B,C,S]=
[]+_;$=A+B+C+D+I+H+J+A+I+B+H
R=_[$](H+K+I+J+H+C+S+H+B+B+I)();G=($[$]+[])[14]
R[A+B+C+D+B+E+K][E+B+G](12);`
iP<`

```

This prints `10` in Somme, `11` in Trigger, and `12` in ???.

Since the last two languages are easy to polyglot, I decided to mix *that language* in.

### Explanation (cracked post)

Trigger sees the whole code as a series of tokens (tokenization is greedy):

* Single byte (denote `A`)
* Two same bytes followed by a different byte (denote `AAB`)
* Three same bytes (denoted `AAA`)
* Four same bytes (denoted `AAAA`)

In the source code

```
!!8@e6v+4>9 \
1((111+111)/111)
00
~tz

```

the significant tokens are `((1` `11+` `111` `111`, where the first two does nothing and the last two prints 1 each - thus 11.

# Answer
> 3 votes
# CHIP-8, Klein (100), ???

```
[ //aТ/\\ ][ //е"6
console.log(111-111+12)]
//!'!/-²6-²52@++++2345
 %/    <#> 13
       say 14
 + not not 15

```

Outputs 13 in CHIP-8 (I assume), 14 in Klein, and 15 in ???.

*Another* Klein topology, tsk tsk. I've preserved the code before the `@`, since I don't know what will affect CHIP-8.

### Clues

I'm kinda overdue for these, sorry. I'll try and add one a day.

* Removing the first half (first three lines) of the program still works.
* This is not a 2D language
* The language is on TIO
* The `not`s and the `say` can be removed without affecting the program

For reference, the program without that stuff looks like this:

```
 %/    <#> 13
        14
 +   15

```

Try it online!

# Answer
> 3 votes
# Rust, BrainSpace, ???

```
fn v(){}
/*{>*}+++++++++++++++++++++++++[[[%]]]*\
\mop+p+p+pox
*/fn main(){print!("17")}             //print!(19)$f($f(-x++this::id()++x)++x@);"v2"
  //):/
//////////////////////////////////////[]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

```

This prints 17 in Rust, 18 in BrainSpace, and 19 in ???.

## Crack explanation

Remembered this existed looking through old messages, figured I could scrape Esolangs for every implemented 2D language where the article body has an `o` surrounded by non-letters, and fortunately couldn't be bothered to filter out languages that are on TIO because it turns out BrainSpace got added to TIO about five months after it was confirmed not on TIO. (It's also fortunate that it was alphabetically the second candidate out of 48.)

For posterity (as comments can be ephemeral), the full sequence of hints given was:

* The language is not on TIO. (as of 2019/4/3)
* The language is 2D and listed as such on Esolangs.
* The ASCII character 18 is a red herring.
* `s` doesn't square, `[` doesn't halve, and `o` doesn't end the program.
* `o` performs output.

BrainSpace is some kind of weird half-Brainfuck-half-fungeoid where `{}` move the tape head, `*` is a conditional jump, `%` is an omnidirectional reflect, all three of `pP+` are equivalent increment commands, and all three of `oO0` are equivalent output commands. The instruction pointer starts in the top left moving right, so `fn avreg(){}` sends the pointer down in column 5, `{>*}` sends it careening into a bunch of increments that it gets bounced through again on the way back then passes it right along to the left, and `P0 ++puts++puts[pov]` increments 48 to 49, prints that, slaps another 7 on, prints, then terminates the program by leaving the edge--BrainSpace's field is not toroidal.

---

This should be considerably easier, but you might take some wrong turns.

---
Tags: cops-and-robbers, polyglot, obfuscation, answer-chaining
---