# Question
Title: Halloween Golf: The 2spooky4me Challenge!
A current internet meme is to type 2spooky4me, with a second person typing 3spooky5me, following the `(n)spooky(n+2)me` pattern.

Your mission is to implement this pattern in your chosen language. You should write a program or function that takes a value `n` (from standard input, as a function argument, or closest alternative), and outputs the string `(n)spooky(n+2)me` (without the parentheses; to standard output, as a return value for a function, or closest alternative).

Your solution should work for all inputs, from `1` up to 2 below your language's maximum representable integer value (`2^32-3` for C on a 32-bit machine, for example).

Example implementation in Python:

```
def spooky(n):
    return "%dspooky%dme"%(n,n+2)

```

`spooky(2) -> "2spooky4me"`

This is , so standard loopholes are forbidden, and the shortest answer in bytes wins!

# Leaderboard

The Stack Snippet at the bottom of this post generates the leaderboard from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```
## Language Name, N bytes

```

where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:

```
## Ruby, <s>104</s> <s>101</s> 96 bytes

```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header:

```
## Perl, 43 + 2 (-p flag) = 45 bytes

```

You can also make the language name a link which will then show up in the snippet:

```
## [><>](http://esolangs.org/wiki/Fish), 121 bytes

```

```
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 62350; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 45941; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }</script>
```

# Answer
# gs2, 15 bytes

I outgolfed Dennis!

CP437:

```
spooky•me♣╨V↕0B

```

Hex dump:

```
73 70 6f 6f 6b 79 07 6d 65 05 d0 56 12 30 42

```

At the start of the program, STDIN is pushed (e.g. the string `"3"`) and stored in variable `A`. The first ten bytes of the program push two strings, `"spooky"` and `"me"`, to the stack. Then:

* `d0` pushes variable `A`.
* `56` parses it as a number.
* `12` `30` increments it by two.
* `42` swaps the top two elements on the stack, leaving `"3" "spooky" 5 "me"`.

The final stack is printed as `3spooky5me`.
> 46 votes

# Answer
# GS2, 17 bytes

```
56 40 27 27 04 73 70 6F 6F 6B 79 05 42 04 6D 65 05

```

I CAN'T OUTGOLF DENNIS HELP
> 29 votes

# Answer
# Stuck, 17 bytes

```
i_2+"spooky";"me"

```

EDIT: GUESS YOU COULD SAY I'M STUCK AT 17 BYTES
> 25 votes

# Answer
# GolfScript, 17 bytes

```
~.2+"spooky"\"me"

```

Try it online on Web GolfScript.

### How it works

```
~.2+"spooky"\"me"
~                 # Evaluate the input.
 .2+              # Push a copy and add 2.
    "spooky"      # Push that string.
            \     # Swap it with the computed sum.
             "me" # Push that string.

```
> 21 votes

# Answer
# Chef, 414 bytes

```
S.

Ingredients.
g i
2 g t
115 l s
112 l p
111 l o
107 l k
121 l y
109 l m
101 l e

Method.
Take i from refrigerator.Put e into mixing bowl.Put m into mixing bowl.Put i into mixing bowl.Add t.Put y into mixing bowl.Put k into mixing bowl.Put o into mixing bowl.Put o into mixing bowl.Put p into mixing bowl.Put s into mixing bowl.Put i into mixing bowl.Pour contents of mixing bowl into the baking dish.

Serves 1.

```

A recipe for disaster. Do not try this at home.
> 16 votes

# Answer
# Pyth - 17 bytes

```
s[Q"spooky"hhQ"me

```

Try it online here.
> 11 votes

# Answer
# Pip, 18 bytes

Looks like I'm in the second tier of golfing languages here. :^P

```
[a"spooky"a+2"me"]

```

Try it online!

Takes the number as a command-line argument and puts the appropriate elements in an array, which is joined together and autoprinted at the end of the program.

---

Five and a half years later, here's a much more interesting 18-byte solution:

```
"0spooky2me"RXD_+a

```

Try it online!

In the string `0spooky2me`, `R`eplace each digit (built-in regex variable `XD`) with itself plus the command-line argument (`_+a`).
> 11 votes

# Answer
# CJam, 18 bytes

```
ri_2+"spooky"\"me"

```

Try it online.
> 10 votes

# Answer
# TeaScript, 18 bytes

```
x+`spooky${x+2}me`

```

Unfortunately this string can't be compressed so this is basically as short as it will get
> 9 votes

# Answer
# dc, 20 bytes

```
?dn[spooky]P2+n[me]P

```
> 8 votes

# Answer
# Japt, ~~17~~ 16 bytes

```
U+"spooky{U+2}me

```

**Japt** (**Ja**vascri**pt** shortened) is a language of my invention. **It is newer than this challenge; thus, this answer is non-competing.** Unlike my other seven unpublished languages, this one has an actual interpreter that is currently being developed and is already partially working.

I wanted to post this because I like how it's the same length as all the existing ~~first-place~~ second-place answers. Here's how it works:

```
U+"spooky{U+2}me"    implicit: [U,V,W,X,Y,Z] = eval(input)
U+                   input +
  "spooky     me"     this string
         {U+2}         with input+2 inserted here
                     implicit: output last expression

```

And there you have it. The spec for all functionality used here was finalized on Oct 29th; nothing was changed to make this answer any shorter. Here's the interpreter, as promised.
> 8 votes

# Answer
# 05AB1E, ~~14~~ 10 bytes

```
DÌs’ÿæªÿme

```

Try it online.

## Explanation

```
DÌs’ÿæªÿme

D                get input n and duplicate it
 Ì               increment by 2
  s              Swap. Stack is now [n+2, n].
   ’ÿæªÿme       Compressed string that expands to "ÿspookyÿme". The first ÿ is then replaced by n and the second by n+2.

```
> 7 votes

# Answer
# Julia, 23 bytes

```
n->"$(n)spooky$(n+2)me"

```

This creates an unnamed lambda function that accepts an integer and returns a string. The output is constructed using Julia's string interpolation.
> 6 votes

# Answer
# Gol\>\<\>, 21 bytes

```
I:n"emykoops"6Ro{2+nH

```

I guess I'm... tied with Perl? Try it online.

```
I:n            Input n, output n
"emykoops"     Push chars
6Ro            Output top 6 chars (spooky)
{2+n           Output n+2
H              Output stack and halt (me)

```
> 6 votes

# Answer
# Vitsy, 21 Bytes

Note: the `Z` command was made after this challenge began, but was not made for this challenge.

```
VVN"ykoops"ZV2+N"em"Z
V                      Grab the top item of the stack (the input) and make it a
                       global variable.
 V                     Call it up - push the global variable to the top of the stack.
  N                    Output it as a number.
   "ykoops"            Push 'spooky' to the stack.
           Z           Output it all.
            V2+N       Call the global variable again, add two, then output as num.
                "em"Z  Push 'me' to the stack and output it all.

```

More spoopy variation using multiple stacks (27 Bytes):

```
&"ykoops"&"em"?DN?Z??2+N??Z

&                           Make a new stack and move to it.
 "ykoops"                   Push 'spooky' to the current stack.
         &"em"              Do the last to things with 'me'.
              ?             Move over a stack.
               DN           Output the input.
                 ?Z         Move over a stack (the one with 'spooky') and print it.
                   ??       Move back to the original stack.
                     2+N    Add 2 to the input and output it as a number.
                        ??Z Move to the stack with 'me' in it and print it.

```

Try it online!
> 6 votes

# Answer
# Jelly

**13 bytes**

```
+0,2ż“×¥X“ŀ`»

```

I CAN'T OUTGOLF QUARTATA HELP

Try it online!

### How it works

```
+0,2ż“×¥X“ŀ`»  Main link. Input: n

+0,2           Add [0, 2] to n, resulting in [n, n + 2].
     “×¥X“ŀ`»  Yield ['spooky, 'me'] by indexing into a dictionary.
    ż          Zip the results to left and right with each other.
               This yields [[n, 'spooky'], [n + 2, 'me']], which is flattened
               before printing.

```
> 6 votes

# Answer
## Javascript(ES6) ~~23~~ 21 Bytes

A simple function that will be crushed by golfing lanqs:

```
_=>_+`spooky${_+2}me`

```
~~```
_=>`${_}spooky${_+2}me`

```~~

Special thanks to ETHproductions for saving 2 bytes
> 5 votes

# Answer
# Ruby, 25 bytes

```
->n{"#{n}spooky#{n+2}me"}

```

This creates an unnamed lambda that accepts an integer and returns a string. The string is constructed using Ruby's string interpolation.
> 5 votes

# Answer
# APL, ~~25~~ 22 bytes

```
⍕,'spooky','me',⍨∘⍕2+⊢

```

This creates an unnamed monadic function train that accepts an integer on the left and returns a string.

Numeric values are converted to strings using . The array of strings is joined into a single string using .

Try it online

Saved 3 bytes thanks to Thomas Kwa!
> 5 votes

# Answer
# PHP, ~~55~~ ~~47~~ ~~46~~ ~~42~~ 34 bytes

```
<?=($a=$argv[1]).spooky.($a+2).me;

```

Accepts the number as command line input.

### Credits :)

Thanks to manatwork for saving 4 bytes!

Thanks to insertusernamehere for saving 8 bytes!
> 4 votes

# Answer
# Chaîne, 15 bytes

*noncompeting, language postdates question*

```
{i~}:-,}:{2+}me
{i~}            | input duplicate write
    :   :       | access dictionary with inner base-93 key
     -,}        | entry for "spooky"
         {2+}   | push 2, add previous two, write
             me | write me

```

Implicit output.
> 4 votes

# Answer
# Perl 5, ~~20~~ 19 bytes

```
$\=spooky.($_+2).me

```

The code requires the `-p` switch. *Thanks to @Xcali for golfing off 1 byte!*

Try it online!
> 3 votes

# Answer
# Lua for windows, 41 bytes

```
n=io.read()print(n.."spooky"..n+2 .."me")

```

test with lua for windows

it takes the input through io.read then stored in variable n then on the same line prints the variable n then "spooky" then n+2 finally it prints "me"
> 3 votes

# Answer
# Mathematica, 45 27 bytes

```
Print[#,"spooky",#+2,"me"]&

```

`g=ToString[#]<>"spooky"<>ToString[#+2]<>"me"&`

Thanks to Martin Büttner for the significant improvement (and the warm welcome).
> 3 votes

# Answer
# Simplex v.0.7, 20 bytes

Simplex simply isn't feeling golfy today. \>\_\<

```
i@R"spooky"&IIR"me"g
i@                   ~~ take input and copy to register
  R"spooky"          ~~ write that string to the strip (increment byte after every character)
           &II       ~~ write the register (incremented twice) to the strip
              R"me"  ~~ write that string to the strip
                   g ~~ output the strip

```
> 3 votes

# Answer
## C, 58 bytes

```
main(a,b)char**b;{printf("%sspooky%dme",*++b,atoi(*b)+2);}

```

`atoi()` may be unnecessary.
> 3 votes

# Answer
## Minkolang 0.10, 49 bytes

I have no way to convert integers to strings (yet!), so this is much longer.

```
"me"nd2+(dl%"0"+$rl:d)"spooky"2g(dl%"0"+$rl:d)$O.

```

Try it here.

### Explanation

`(dl%"0"+$rl:d)` does the job of converting an int to a string. If this were replaced by a single character (like `Z`), then my solution would be just **23 bytes**.

```
"me"nd2+Z"spooky"2gZ$O.

```

`nd` takes an integer from input and duplicates it. `2+` adds 2 and `2g` later gets the initial input and puts it on top of stack. `$O.` outputs the whole stack as integers and stops.
> 3 votes

# Answer
# Rotor, 15 bytes

```
&"spooky"~2+"me

```

Language was created after the challenge. Does not work in the online interpreter (uses input eval.)
> 3 votes

# Answer
## Cookie, 16 bytes

Note that the recent changes to the Github page were **not** made for this challenge, Cookie is still in development.

```
wŕspooky[r+2]me"

```

Explanation:

```
wŕspooky[r+2]me"
w                 start write command
 ŕ                take input
  spooky          write spooky
        [r+2]     compute input + 2
             me   write me
               "  close write command.

```
> 3 votes

# Answer
# Factor, 30 bytes

```
[ dup 2 + [I ${}spooky${}meI]]

```

TIO doesn't have the `interpolate` vocab, so have a screenshot:
> 3 votes

# Answer
# Vim, ~~18~~ 17 bytes

```
C<C-r>"spooky<C-r>"<esc><C-a><C-a>ame

```

Try it online!

### Explanation

```
C

```

Delete the input number (storing it in the register) and enter insert mode.

```
<C-r>"spooky<C-r>"

```

Insert the number from the register, followed by `spooky`, followed by the number from the register again.

```
<esc><C-a><C-a>

```

Leave insert mode and increment the number under the cursor twice.

```
ame

```

Insert `me` after the number.
> 3 votes

# Answer
# Python, 31 bytes

```
lambda n:"%dspooky%dme"%(n,n+2)

```

Ask and you shall receive.
> 2 votes

# Answer
# Java, ~~39~~ 35 bytes

```
n->"".format("%dspooky%dme",n,n+2);

```

A lambda expression that takes an `int` and returns a string.
> 2 votes

# Answer
# Mouse, 25 bytes

```
?N:N.!"spooky"2N.+!"me"$

```

Ungolfed:

```
? N:         ~ Read an integer N from STDIN
N. !         ~ Write N to STDOUT
"spooky"     ~ String literals go straight to STDOUT
2 N. + !     ~ Print N+2
"me"
$            ~ End of program

```
> 2 votes

# Answer
# Gema, 21 characters

```
*=*spooky@add{$0;2}me

```

Sample run:

```
bash-4.3$ echo -n 42 | gema '*=*spooky@add{$0;2}me'
42spooky44me

```
> 2 votes

# Answer
# jq, 21 characters

(20 characters code + 1 character command line option.)

```
"\(.)spooky\(.+2)me"

```

Sample run:

```
bash-4.3$ jq -r '"\(.)spooky\(.+2)me"' <<< 42
42spooky44me

```

On-line test (Passing `-r` through URL is not supported – check Raw Output yourself.)
> 2 votes

# Answer
# Bash, 24 bytes

```
echo $1spooky$(($1+2))me

```

Takes input as command line argument
> 2 votes

# Answer
## PowerShell, ~~31~~ ~~30~~ 29 bytes

```
param($x)"$x`spooky$($x+2)me"

```

Try it online!

Takes input `$x`, constructs and leaves a string on the pipeline with implicit output. The string is formed from `$x` `spooky` `$x+2` `me`, with the trick being the ``` that allows the variable name to be escaped to be just `$x` instead of `$xspooky`.

*-1 byte thanks to Veskah.*
> 2 votes

# Answer
# pl, 12 bytes

```
_spooky_2┼me

```

Try it online.

Non-competing since pl was invented after this challenge.
> 2 votes

# Answer
# Scala, 30 bytes

```
(n:Int)=>s"${n}spooky${n+2}me"

```
> 2 votes

# Answer
# Jolf, 15 bytes

Try it here! I forgot about inline string interpolation until after @quartata posted his solution.

```
"¦jspooky¦+2jme

```

## Explanation

```
"¦jspooky¦+2jme
"               string containing
 ¦j              the input,
   spooky        "spooky"
         ¦+2j    2 + the input,
             me  and "me"
                implicitly printed.

```
> 2 votes

# Answer
# Java 8, 24 bytes

`n->n+"spooky"+(n+2)+"me"`

That moment when Java is actually competitive... (and by competitive I mean top 40 :P)

Try it online!
> 2 votes

# Answer
# Pyramid Scheme, 624 bytes

```
   ^      ^      ^      ^     ^      ^      ^      ^      ^
  / \    / \    / \    / \   / \    / \    / \    / \    / \
 /set\  /out\  /out\  /out\ /out\  /out\  /out\  /out\  /out\
^-----^^-----^ -----^ -----^----- ^----- ^-----^ -----^ -----^
-    ^--    / \    / \    / \    / \    / \   /+\    / \    / \
    /#\    /chr\  /chr\  /chr\  /chr\  /chr\ ^---^  /chr\  /chr\
   ^---   ^----- ^----- ^----- ^----- ^-----/2\  - ^----- ^-----
  /l\    / \    / \    / \    / \    / \    ---   / \    / \
 /ine\  /115\  /112\  /111\  /107\  /121\        /109\  /101\
 -----  -----  -----  -----  -----  -----        -----  -----

```

Try it online!

Very straightforward. Gets an integer from input and saves it to the blank variable. Prints it. Prints "spooky". Prints blank+2. Prints "me". Follows the same pattern as Hello, World, for the most part.
> 2 votes

# Answer
# Wren, 31 bytes

Not special, just uses some formatting

```
Fn.new{|n|"%(n)spooky%(n+2)me"}

```

Try it online!
> 2 votes

# Answer
# MarioLANG, 221 bytes

```
;>+>+>+>+>.>)
:"+"+"+"+"-"-
)++++++++.-:-
+++++++++--+-"
+++++++++.-+-.
+++++++++-.(--
+++++++++-+.--
+++++++++-++--
+++++++++.++--
++++++++++++--
++++++++++++--
++++++++++++--
++++++++++++--
+!+!+!+!+!+!.!
=#=#=#=#=#=#=#

```

Try it online!
> 2 votes

# Answer
# Canvas, 13 bytes

```
╶spooky╶├me）∑

```

Try it here!
> 2 votes

# Answer
## Aussie++, 60 bytes

```
THE HARD YAKKA FOR f IS(n)<BAIL ""+n +"spooky"+(n +2)+"me";>

```

Tested in commit e0091bc.

For some reason, the space in `n +` is required. The empty string at the beginning seems unnecessary but isn't, see this issue.
> 2 votes

# Answer
# Regenerate, 19 bytes

```
$~1spooky${$~1+2}me

```

Attempt This Online!

### Explanation

```
$~1spooky${$~1+2}me
$~1                  First command-line input
   spooky            spooky
         ${     }    Treat the result of this expression as a string:
           $~1         First command-line input
              +2       Plus 2
                 me  me

```
> 2 votes

# Answer
# Go, 70 bytes

```
import."fmt"
func f(n int)string{return Sprintf("%dspooky%dme",n,n+2)}

```

Attempt This Online!
> 2 votes

# Answer
# Groovy, ~~24~~ 22 bytes

```
{it+"spooky${it+2}me"}

```
> 1 votes

# Answer
## Burlesque, 21 bytes

```
J2?+Cl"~spooky~me"jf~

```

Needs fixed stack layout. Not usable except as a stand-alone program. Otherwise use one of the versions below that are more generic.

Alternative versions:

```
"~spooky~me"jbxJ2?+_+f~ [24 bytes]
J"spooky"?+j2?+"me"?+?+ [24 bytes, too]

```
> 1 votes

# Answer
# , 20 bytes

```
j.o"spooky"o))o"me"o
```

Kinda long Try it online

```
j          Get input as Number
.          Clone the number to add to later
o          Print the number
"spooky"o  Print spooky
))o        Increment the input by two and print
"me"o      Print me

```
> 1 votes

# Answer
# JS (ES5) 41

Oh, ES6...

```
function(a){alert(a+"spooky"+(a+2)+"me")}

```
> 1 votes

# Answer
# Coffeescript, 23 bytes

```
(n)->n+"spooky#{n+2}me"

```

Anonymous function that takes `int` `n` and returns `<n>spooky<n+2>me`.
> 1 votes

# Answer
# C++11, 142 130 108 bytes

*Self-imposed challenge: no C headers*

```
#include<sstream>
#include<string>
[](int x){std::stringstream q;q<<x<<"spooky"<<x+2<<"me";return q.str();}

```

Thanks to Mego for saving a few bytes with the return logic everything.
> 1 votes

# Answer
# C# 33 bytes

```
string s(n)=>$"{n}spooky{n+2}me";

```
> 1 votes

# Answer
# Carrot (version ^3), 14 bytes

```
#spooky(#+2)me

```

Explanation:

Carets `^` have now been made optional if you do not want to use commands. The `#` is the variable representing the input. Every instance of `#` is replaced with the value of input. Going to the parentheses, the expression inside the parentheses is evaluated and a number is returned.

Test it online here. Please note that this is not permalinked.
> 1 votes

# Answer
# Retina, 17 bytes

This assumes that the integer `n` may be expressed in unary in the output. Each line would go in its own file, with one byte added per additional file.

```
1+
$_spooky$_11me

```

If the input is `11`, the output is `11spooky1111me`.

For non-unary output (but still unary input), use this (27 bytes):

```
1+
$_spooky$_11me
(\d)+
$#1

```

**Try it online**
> 1 votes

# Answer
# \>\<\>, 25 (+2) = 27 bytes

```
:n'emykoops'oooooo{2+noo;

```

Starting with a value (n) on top of the stack from -v (2 byte penalty). Explanation:

```
:            Duplicates top item on stack
 n           Pops and outputs top value on stack as number -> n
  'emykoops' Pushes each character onto the stack
   o         x5 Pops and outputs top value on stack as character -> "spooky"
    {        Shift stack leftwards making input value top value
     2       Pushes 2 on the stack
      +      Pops top 2 elements, sums them and pushes result
       n     Pops and outputs top value on stack as number -> n+2
        o    x2 Pops and outputs top value on stack as character -> "me"
         ;   Ends execution

```
> 1 votes

# Answer
## Seriously, 20 bytes

```
"me",;⌐@"spooky"@kεj

```

Since this challenge partially inspired this language, I figured I should go ahead and add a solution. Try it online!
> 1 votes

# Answer
## F#, 33 bytes

```
fun n->printf"%ispooky%ime"n<|n+2

```
> 1 votes

# Answer
# Squirrel, 25 bytes

```
@(n)n+"spooky"+(n+2)+"me"

```
> 1 votes

# Answer
# D, 71 bytes

```
import std.string;string s(int i){return format("%sspooky%sme",i,i+2);}

```

More verbose than Java...
> 1 votes

# Answer
# Jolf, 16 bytes

```
"%spooky%me"J+2J

```

Try it online.
> 1 votes

# Answer
## Applesoft BASIC, 28 bytes

```
0input n:?n;"spooky";n+2;"me

```

The question mark expands to `PRINT` and the missing final double quotation mark is implied.

Tested with Joshua Bell's online emulator.
> 1 votes

# Answer
## R, 38 bytes

```
n=scan();sprintf("%dspooky%dme",n,n+2)

```

or (same length)

```
sprintf("%dspooky%dme",n<<-scan(),n+2)

```

Example:

```
n=scan();sprintf("%dspooky%dme",n,n+2)
1: 999
999spooky1001me

```
> 1 votes

# Answer
# Pylongolf, 20 bytes

```
_:AA"spooky"A2+"me"~

```

`_` asks for input and `:A` puts it into the variable A.
`A"spooky"` pushes A, and spooky then `A2+` adds the input + 2.
After that we push "me" into the stack and print it with `~`.
> 1 votes

# Answer
# LOLCODE, ~~100~~ 99 bytes

```
HAI 1.3
I HAS A J
GIMMEH J
VISIBLE J!
VISIBLE "spooky"!
VISIBLE SUM OF J AN 2!
VISIBLE "me"
KTHXBYE

```

Try it online!
> 1 votes

# Answer
# Stacked, 21 bytes

```
[:2+,'spooky'#`'me'+]

```

Try it online!

Function returning the string.

## Explanation

```
[:2+,'spooky'#`'me'+]
[                   ]  function                stack: (y)
 :                     duplicate               stack: (y y)
  2+                   add 2                   stack: (y y+2)
    ,                  pair                    stack: ((y y+2))
     'spooky'#`        join by "spooky"        stack: ("{y}spooky{y+2}")
               'me'+   append the string "me"  stack: ("{y}spooky{y+2}me")

```
> 1 votes

# Answer
# Kotlin, 24 bytes

```
{"${it}spooky${it+2}me"}

```

Try it online!
> 1 votes

# Answer
# Forth (gforth), 39 bytes

```
: f 0 2dup .r ." spooky"2 m+ .r ." me";

```

Try it online!

### Code Explanation

```
: f            \ start a new word definition
  0 2dup       \ add 0 to the top of the stack and duplicate the top two stack values
  .r           \ print the input with no following space
  ." spooky"   \ print "spooky"
  2 m+ .r      \ add 2 to the input and print with no following space
  ." me"       \ print "me"
;              \ end the word definition

```
> 1 votes

# Answer
# Stax, 12 bytes

```
ïöeO¬‼3ì╡☻↔G

```

Run and debug it

Uses an unterminated template literal to embed instructions in an output string.
> 1 votes

# Answer
# Assembly (MIPS, SPIM), 221 bytes

```
.data
a: .asciiz "spooky"
c: .asciiz "me"
.text
.globl main
main:
li $2 5
syscall
la $9 a
la $10 a
move $8 $2
l:
move $4 $8
li $2 1
syscall
li $2 4
move $4 $9
syscall
bne $10 $9 e
la $9 c
addi $8 2
j l
e:
li $2 10
syscall

```

Try it online!

Couldn't get SPIM and TIO to play nice with argc/argv, so had to take it via input. String formatting in Assembly isn't pleasant.
> 1 votes

# Answer
# Keg, `-no` 13 bytes

```
:&spooky&2+me

```

This was *way* too spooky. It's not even October!

Pushes the evaluated input and stores it in the register, pushes the sequence `spooky`, adds two to the value in the register and then pushes the sequence `me`.

Uses the latest version of the interpreter which hasn't been updated on TIO thus far.
> 1 votes

# Answer
## tq, 16 bytes

```
?"spooky"?+2"me"

```

## Explanation

<pre><code># Define an array with 4 items
?                # First item: input
 "spooky"        # Second item: "spooky"
         ?+2     # Third item: input + 2
            "me" # Fourth item: "me"

# Print without a separator
```

> 1 votes

# Answer
## `d`, 14 bytes

```
♠╚z[·7♦÷U# 1╘╖

```

## Explanation

Uncompressed:

```
"a"spooky"a2+"me"

```

```
""                 % Push an empty string for the first operand to render
  a                % The 1st operand
   "spooky"        % Push "spooky"
           a2+     % The 1st operand + 2
              "me" % Push me

```
> 1 votes

# Answer
# BRASCA, 27 bytes

```
ig:an`ykoops`[o]A}}n`em`[o]

```

Try it online!

## Explanation

```
<implicit input>             - Push STDIN on the stack
ig                           - Turn the codepoints of 0-9 into 0-9, and concatenate stack
  :a                         - Store a copy into register A
    n                        - Print the original (this disables implicit output)
     `ykoops`[o]             - Push and print "spooky"
                A}}          - Get the copy from register A and increment twice
                   n         - Print the incremented copy.
                    `em`[o]  - Push and print "me"

```
> 1 votes

# Answer
# Zsh, ~~21~~ 20 bytes

```
<<<$1spooky$[$1+2]me

```

try it online!
> 1 votes

# Answer
## Swift, 26 bytes

```
{n in"\(n)spooky\(n+2)me"}

```

TIO link
> 1 votes

# Answer
## Python 3, 28 bytes

```
lambda n:f'{n}spooky{n+2}me'

```

Try it online!
> 1 votes

# Answer
# Rust, ~~37~~ 33 bytes

Thanks @xigoi for tip on removing i32 type signature for n

```
|n|{print!("{}spooky{}me",n,n+2)}

```

Try it Online!
> 1 votes

# Answer
# QBasic, 52 bytes

```
INPUT n
?MID$(STR$(n),2)"spooky"MID$(STR$(n+2),2)"me

```

Try it at Archive.org.

### Explanation

QBasic's annoying number-to-string formatting is on full display here. Printing a number directly adds a leading and trailing space, so that's out. `PRINT USING` seems tailored for fixed-width columns and doesn't do well with numbers of different lengths. `STR$(n)` is a little better: it only adds a leading space, which we can remove by taking a substring starting at the second character with `MID$`.

```
INPUT n                                       Get a number from the user
?                                             Print
 MID$(STR$(n),2)                              The number w/o leading space
                "spooky"                      That string
                        MID$(STR$(n+2),2)     The number + 2 w/o leading space
                                         "me  That string (close-quote implied)

```
> 1 votes

# Answer
# Whitespace, 142 bytes

```
[S S S N
_Push_0][S N
S _Duplicate_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][T  N
S T _Print_as_integer][S S S T  T   T   N
_Push_7_y][S S T    T   T   T   N
_Push_-7_k][S S T   T   T   N
_Push_-3_o][S N
S _Duplicate__o][S S T  T   S N
_Push_-2_p][S S S T N
_Push_1_s][N
S S N
_Create_Label_LOOP][S N
S _Duplicate_top][N
T   S S N
_Jump_to_Label_DONE_if_0][S S S T   T   T   S S T   S N
_Push_constant_114][T   S S S _Add][T   N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_DONE][T   T   T   _Retrieve_input][S S S T    S N
_Push_2][T  S S S _Add][T   N
S T _Print_as_integer][S S S T  T   S T T   S T N
_Push_109_m][T  N
S S _Print_as_character][S S S T    T   S S T   S T N
_Push_101_e][T  N
S S _Print_as_character]

```

Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.
`[..._some_action]` added as explanation only.

**Try it online** (with raw spaces, tabs and new-lines only).

**Explanation in pseudo-code:**

```
Push 0
Integer n = STDIN as number
Print n as integer to STDOUT
Push codepoint-integers c for "ykoops", each lowered by 114
Start LOOP:
  If top == 0: Go to function DONE
  Add 114 to the top c
  Print c as character to STDOUT
  Go to next iteration of LOOP

function DONE:
  Print n as integer to STDOUT
  Print "me" as characters to STDOUT
  (stop the program implicitly with an error: no exit defined)

```

The constant `114` is generated by this Java program, based on this Whitespace tip of mine.
> 1 votes

# Answer
# Fig, \\$17\log\_{256}(96)\approx\\$ 13.993 bytes

```
%"%spooky%me"$w}}

```

Try it online!

Sadly, "%spooky%me" is incompressible in Fig.

```
%"%spooky%me"$w}}
               }} # Increment twice
              w   # Wrap it in a list with the original number
             $    # Reverse the list
%"%spooky%me"     # Replace all '%' in "%spooky%me" with the elements in ^

```
> 1 votes

# Answer
# Rattle, 23 bytes

```
\&spooky&me|Ig0bb1+2bb2

```

Try it Online!

# Explanation

```
           |                 everything before this is input
\                            as input, take an input string
 &spooky                     ...and "spooky" (hard-coded)
        &me                  ...and "me" (hard-coded)
            I                split input list and store in consecutive memory slots
             g0              get the first element
               b             add this to the print buffer
                b1           add the element in memory slot 1 ("spooky")
                  +2         add 2 to the top of the stack
                    b        add the top of the stack to the print buffer
                     b2      add "me" to the print buffer (buffer output implicitly)

```
> 1 votes

# Answer
# Arturo, 25 bytes

```
$[n]->~"|n|spooky|n+2|me"

```

Try it
> 1 votes

# Answer
# Thunno `J`, \\$ 19 \log\_{256}(96) \approx \\$ 16 bytes

(actually 15.64 bytes but the leaderboard doesn't take floats)

```
D2+"spooky"s"me"ZMr

```

Attempt This Online!

**Explanation:**

```
D2+"spooky"s"me"ZMr   # Implicit input
D2+                   # Duplicate and add 2
   "spooky"s          # Push "spooky" and swap
            "me"      # Push "me"
                ZMr   # Push the stack, reversed
                      # J flag joins by ""
                      # Implicit output

```
> 1 votes

# Answer
# Thunno 2 `j`, 10 bytes

```
ƙ`me+‘ọṣ‘$

```

Attempt This Online!

#### Explanation

```
ƙ`me+‘ọṣ‘$  # Implicit input
ƙ           # Increment the input twice
 `me+       # Append the string "me"
     ‘ọṣ‘   # Push compressed string "spooky"
         $  # Push the input again
            # Implicit output of joined stack

```
> 1 votes

# Answer
# Uiua, 17 bytes

```
$"_spooky_me"∶+2.

```

Try it!
> 1 votes

# Answer
# MATLAB, 33 bytes

```
@(x)fprintf('%dspooky%dme',x,x+2)

```

Pretty self explanatory. Tried a few ways and this was the shortest I could find.

You should be able to run this with the **Octave** online interpreter.
> 0 votes

# Answer
# O, 20 characters

```
Q"spooky"Q2+"me"+++p

```

Sample run:

```
bash-4.3$ o.sh 'Q"spooky"Q2+"me"+++p' <<< 42
42spooky44me

```
> 0 votes

# Answer
# Fourier, 32 bytes

```
I~zo115a-3avaa-4a121az+2o109a-8a

```

Still using @isaacg's golfing algorithm ;)
> 0 votes

# Answer
# Haskell, 38 bytes

```
a n=show(n)++"spooky"++show(n+2)++"me"

```

Defines a function named `a` that takes a `Num` `n`. Returns `<n>spooky<n+2>me`.
> 0 votes

# Answer
## Clojure, 26 bytes

```
#(str %"spooky"(+ 2%)"me")

```

First post. It's a function, as required. I *think* I took as many liberties with the tokenizer as possible, but I don't know. Here it is in action in the REPL:

```
user=> #(str %"spooky"(+ 2%)"me")
#<user$eval1176$fn__1177 user$eval1176$fn__1177@2d2d2f69>
user=> (*1 55)
"55spooky57me"

```
> 0 votes

# Answer
# Dart, 27 Bytes

```
t(n)=>'${n}spooky${n+2}me';

```

Unremarkable but competitive.
> 0 votes

# Answer
# Factor, 79 bytes

```
: f ( x -- ) dup 2 + [ number>string ] bi@ "spooky" swap "me" 4array concat . ;

```

First stab at it, just did it the obvious way.
> 0 votes

# Answer
## Lua, 41 Bytes

There's this other lua answer, but it doesn't work anymore since lua 5.3. It will now print `2spooky4.0me` Here comes a code working under all versions of lua, and who's still in 41 Bytes:

```
print(("%dspooky%dme"):format(...,...+2))

```
> 0 votes

# Answer
# ,,,, 18 bytes

```
:↓2+"spooky"↓↓"me"

```
> 0 votes

# Answer
# Acc!!, 99 bytes

```
N
Write _
Write 115
Write 112
Write 111
Write 111
Write 107
Write 121
Write _+2
Write 109
Write 101

```

Try it online!
> 0 votes

# Answer
# Implicit, ~~20~~ ~~17~~ 16 bytes

```
ì¯spooky]ì..ìme"

```

Try it online!

```
ì¯spooky]ì..ìme"
ì                 « implicit integer input, convert to string     »;
 ¯                « copy input to memory                          »;
  spooky          « push the ASCII character codes for each letter in `spooky` individually »;
        ]         « copy memory to stack                          »;
         ì        « convert string to integer                     »;
          ..      « increment twice                               »;
            ì     « and back to string                            »;
             me   « push character codes for `me`                 »;
               "  « stringify the entire stack                    »;

```
> 0 votes

# Answer
# Python ≥ 3.6, 28 bytes

```
lambda x:f'{x}spooky{x+2}me'

```

Try it online!

Makes use of formatted string literals, a feature that was introduced in Python 3.6.
> 0 votes

# Answer
# SmileBASIC, 26 bytes

```
INPUT N?N;"spooky";N+2;"me

```
> 0 votes

# Answer
# T-SQL, 40 bytes

```
SELECT CONCAT(n,'spooky',n+2,'me')FROM t

```

Input taken via a pre-existing table **t** with integer column **n**, per our input standards.

`CONCAT` does an implicit type conversion, otherwise I'd have to do something like `CONVERT(n,varchar(9))`.
> 0 votes

# Answer
# MATL, 18 bytes

```
'spooky'yUQQV'me'v

```

Try it on MATL Online
> 0 votes

# Answer
## OCL, ~~52~~ 46 bytes

```
Function a b Print b+"spooky"+(b + 2)+"me" End

```

This one is pretty straight forward, I just wanted to show off an obscure language.

Edit: I found out you can omit the spaces between the pluses when doing concatenation, but not addition. Weird.
> 0 votes

# Answer
# Pip, 23 bytes

```
(a:q)."spooky".a+2."me"

```

Try it online!
> 0 votes

# Answer
# Stax, 14 bytes

```
ü╫2┐╚╘Wö»§W╟╛╨

```

Run and debug it at staxlang.xyz!

### Unpacked (16 bytes)

```
.me;2+`tNCrf`,Wp
.me                 Literal "me"
   ;2+              Peek from input stack, push to stack, and add 2
      `tNCrf`       Literal "spooky"
             ,      Pop from input stack; push to stack
              Wp    Pop and print everything from the stack with no additional newlines

```
> 0 votes

# Answer
# Excel, 22 bytes

```
=A1&"spooky"&A1+2&"me"

```
> 0 votes

# Answer
# Runic Enchantments, 18 bytes

```
i:2+"me"S9´334E{@

```

Try it online!

Saves 1 byte by using `9´334E` to pull "spooky" out of the word dictionary. `8b*E` for "me" is the same length.
> 0 votes

# Answer
# Japt, 14 bytes

```
`èï`ri@°+T°

```

Try it

## Japt, 13 bytes

```
+`spooky{+2}´

```

Try it
> 0 votes

# Answer
# AWK, 21 bytes

```
$0=$0"spooky"$0+2"me"

```

Try it online!

Substitutes the input for `(input)spooky(input+2)me`. As the new value of `$0` is not zero nor null, prints `$0`.
> 0 votes

# Answer
## Lua, 39 bytes

```
w=io.write w(...)w'spooky'w(...+2)w'me'

```

Test

```
> lua -v & echo -------- & lua ./spooky.lua 2
Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
--------
2spooky4me

```
> 0 votes

# Answer
## JAVA, 60 bytes

```
class p {String main(int n) {return n+"spooky"+(n+2)+"me";}}

```

Works fine on blueJ but not on TIO idk why?
> 0 votes

# Answer
# Vyxal , 12 bytes

```
:⇧‛me«½↵*←«∇

```

Try it Online!

2spooky4joe

## Explained

```
:⇧‛me«½↵*←«∇
:⇧             # Without popping, push input + 2 - this leaves the stack as [input, input + 2]
  ‛me          # push the string "me"
     «½↵*←«    # and the string "spooky"
           ∇   # rotate the top three items and output the sum of the stack

```
> 0 votes

# Answer
# tinylisp, 72 bytes

```
(load library
(q((N)(strcat(string N)(join2(q spooky)(q me)(string(a N 2

```

Anonymous function that takes a number and returns a name (tinylisp's equivalent of a string). Try it online!

### Ungolfed/explanation

```
(load library)         ; Needed for strcat, join2, and ungolfed aliases

(lambda (N)            ; Anonymous function with one argument
  (strcat              ; Concatenate these two names as a single string:
    (string N)         ; Convert the input number to a string, and
    (join2             ; Join these strings together:
      (q spooky)       ;   "spooky" and
      (q me)           ;   "me", with the following separator:
      (string          ;   Convert to a string
        (add2 N 2))))) ;   the input number plus 2

```
> 0 votes

# Answer
# Python, 39 bytes

```
x=int(input());print(f"{x}spooky{x+2}me)

```

*Don't remove the `int()`. That will cause an error. Tested on `Python 3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin`*
> 0 votes

# Answer
# BQN, ~~30~~ 28 bytes

```
•Fmt∾"spooky"∾"me"∾˜·•Fmt+⟜2

```

Anonymous tacit function. Try it at BQN online

### Explanation

Reading right-to-left:

* `+⟜2` adds 2 to the argument
* `•Fmt` converts that number to a string
* `·` helps with parsing
* `"me"∾˜` concatenates `me` to the end of the string
* `"spooky"∾` concatenates `spooky` to the beginning of the string
* `•Fmt∾` concatenates the argument, stringified, to the beginning of the string
> 0 votes

# Answer
# , 24 bytes

```
'me',~":,'spooky',":@+&2

```

Attempt This Online!

If you've seen the BQN or APL golfs then you've seen this one.
> 0 votes

# Answer
# MathGolf, 11 bytes

```
k╕o3╣Rk⌠ûme

```

Try it online.

**Explanation:**

```
k           # Push the input-integer
 ╕o3        # Push compressed string "spoo"
    ╣R      # Push compressed string "ky"
      k     # Push the input-integer again
       ⌠    # Increase it by 2
        ûme # Push string "me"
            # (after which the entire stack joined together is output implicitly)

```

`k...k⌠` could alternatively have been `└)...@` for the same byte-count: try it online.

```
└           # Increase the (implicit) input-integer by 1 without popping
 )          # Pop and increase it by 1 again
       @    # Reverse triple-swap the top three values on the stack

```
> 0 votes

# Answer
# \>\<\> (Fish), 26 bytes

```
:n'ykoops'oooooo2+n'em'oo;

```

Try it
> 0 votes

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


# Question
Title: The Euclidean Algorithm (for finding the greatest common divisor)
# The Challenge

Write a program or function that takes two input integers, `i` and `j`, and outputs their greatest common divisor; calculated by using the Euclidean algorithm (see below).

---

# Input

Input may be taken as a space-delimited string representation of `i` and `j` or as two separate integers. You can assume that integers will be less than or equal to 10,000. You can also assume that the input integers will not be prime to one another.

---

# Euclidean Breakdown

The larger number between `i` and `j` is divided by the smaller as many times as possible. Then, the remainder is added. This process is repeated with the remainder and the previous number, until the remainder becomes `0`.

For example, if the input was `1599 650`:

```
1599 = (650 * 2) + 299
 650 = (299 * 2) +  52
 299 =  (52 * 5) +  39
  52 =  (39 * 1) +  13
  39 =  (13 * 3) +   0

```

The final number, `13`, is the greatest common divisor of the two input integers. It can be visualized like this:

---

# Output

Your output must be the breakdown in the form above, followed by a newline and the GCD. It can be output through any medium.

---

# Examples

### Inputs

```
18 27
50 20
447 501
9894 2628

```

### Outputs

```
27 = (18 * 1) + 9
18 =  (9 * 2) + 0
9

50 = (20 * 2) + 10
20 = (10 * 2) +  0
10

501 = (447 * 1) + 54
447 =  (54 * 8) + 15
 54 =  (15 * 3) +  9
 15 =   (9 * 1) +  6
  9 =   (6 * 1) +  3
  6 =   (3 * 2) +  0
3

9894 = (2628 *  3) + 2010
2628 = (2010 *  1) +  618
2010 =  (618 *  3) +  156
 618 =  (156 *  3) +  150
 156 =  (150 *  1) +    6
 150 =    (6 * 25) +    0
6

```

Note: Outputs do not have to be spaced as they are above. The spacing is only for clarity. Parentheses are required.

---

# Bonus

If your output is spaced as above, you may add a -10% bonus to your score.

# Answer
> 5 votes
# Pyth, 33 bytes

```
ASQWGs[H\=\(G\*/HG\)\+K%HG)A,KG)H

```

Try it online: Demonstration or Test Suite

### Explanation:

```
ASQWGs[H\=\(G\*/HG\)\+K%HG)A,KG)H
  Q                                read the two numbers from input
 S                                 sort them
A                                  and assign them to G and H
   WG                              while G != 0:
                      K%HG           assign H mod G to K
     s[H\=\(G\*/HG\)\+K   )          join the following list items and print:
                                        H=(G*(H/G))+K
                           A,KG      assign K, G to G, H
                               )   end while
                                H  print H

```

# Answer
> 7 votes
# CJam, ~~46~~ ~~43~~ 39 bytes

```
q~]$3*~\{N5$"=("3$:G'*3$Gmd")+"\}h]7>NG

```

Try it online in the CJam interpreter.

### How it works

```
q~]    e# Read all input, evaluate it and wrap the results in an array.
$3*    e# Sort the array and repeat it thrice.
~\     e# Dump the array and swap its last two elements.
{      e# Do:
  N    e#   Push a linefeed.
  5$   e#   Copy the sixth topmost element from the stack.
  "=(" e#   Push that string.
  3$:G e#   Copy the fourth topmost element from the stack. Save it in G.
  '*   e#   Push that character.
  3$   e#   Copy the fourth topmost element from the stack.
  Gmd  e#   Push quotient and remainder of its division by G.
  ")+" e#   Push that string.
  \    e#   Swap the string with the remainder.
}h     e#   If the remainder is positive, repeat the loop.
]7>    e# Wrap the stack in an array and discard its first seven elements.
NG     e# Push a linefeed and G.

```

# Answer
> 6 votes
## Python 2, 70

```
f=lambda a,b:b and'%d=(%d*%d)+%d\n'%(a,b,a/b,a%b)*(a>=b)+f(b,a%b)or`a`

```

A recursive function that returns a multiline string. The function creates the first line, then appends it to the recursive result with the next pair of numbers in the Euclidean algorithm. Once the second number is zero, we take the string of the other number as the base case, causing it to be printed on its own line at the end.

The formatting is done via string substitution, using integer division to get the multiplicand.

One hiccup is needing to start with the larger number being taken mod the smaller number. Conveniently, if the numbers are in the wrong order, the first step of the Euclidian algorithm flips them. To prevent this step from being displayed, only add the current line if the first number is at least the second (equality is needed for, say `f(9,9)`).

# Answer
> 5 votes
# awk, ~~78~~ 77

```
x=$1{for(x<$2?x+=$2-(y=x):y=$2;t=y;x=t)print x"=("y"*"int(x/y)")+",y=x%y}$0=x

```

Sorting the input by size takes a lot of bytes :/
It comes down to this:

```
x=$1;
if(x<$2) x+=$2-(y=x); # add $2 subtract $1 and set y to $1
else y=$2;            # set y to $2

```

### Output

```
650 1599            (input)
1599=(650*2)+ 299
650=(299*2)+ 52
299=(52*5)+ 39
52=(39*1)+ 13
39=(13*3)+ 0
13

```

Just for the fun of it I made a properly spaced version too, giving me a score of 233 * 0.9 == 209.7 bytes.

*Update* I was able to shorten this from 285 bytes and now it works for arbitrarily long numbers if calling gawk4 with the `-M` option.

```
x=$1{x<$2?x+=$2-(y=x):y=$2;a=length(x);b=length(y);for(d=length(x%y);t=y;x=t){$++i=x;$++i=y;if(c<l=length($++i=int(x/y)))c=l;$++i=y=x%y}while(j<NF)printf "%"a"d = %"b-length($(j+2))"s(%d * %"c"d) + %"d"d\n",$++j,_,$++j,$++j,$++j}$0=x

```

But I still got a feeling I ran into some mental block there somewhere...

### Output (gawk4 called with `awk -M -f code.awk`)

```
6837125332653632513763 18237983363879361  (input)
6837125332653632513763 = (18237983363879361 * 374883) + 15415252446024000
     18237983363879361 = (15415252446024000 *      1) +  2822730917855361
     15415252446024000 =  (2822730917855361 *      5) +  1301597856747195
      2822730917855361 =  (1301597856747195 *      2) +   219535204360971
      1301597856747195 =   (219535204360971 *      5) +   203921834942340
       219535204360971 =   (203921834942340 *      1) +    15613369418631
       203921834942340 =    (15613369418631 *     13) +      948032500137
        15613369418631 =      (948032500137 *     16) +      444849416439
          948032500137 =      (444849416439 *      2) +       58333667259
          444849416439 =       (58333667259 *      7) +       36513745626
           58333667259 =       (36513745626 *      1) +       21819921633
           36513745626 =       (21819921633 *      1) +       14693823993
           21819921633 =       (14693823993 *      1) +        7126097640
           14693823993 =        (7126097640 *      2) +         441628713
            7126097640 =         (441628713 *     16) +          60038232
             441628713 =          (60038232 *      7) +          21361089
              60038232 =          (21361089 *      2) +          17316054
              21361089 =          (17316054 *      1) +           4045035
              17316054 =           (4045035 *      4) +           1135914
               4045035 =           (1135914 *      3) +            637293
               1135914 =            (637293 *      1) +            498621
                637293 =            (498621 *      1) +            138672
                498621 =            (138672 *      3) +             82605
                138672 =             (82605 *      1) +             56067
                 82605 =             (56067 *      1) +             26538
                 56067 =             (26538 *      2) +              2991
                 26538 =              (2991 *      8) +              2610
                  2991 =              (2610 *      1) +               381
                  2610 =               (381 *      6) +               324
                   381 =               (324 *      1) +                57
                   324 =                (57 *      5) +                39
                    57 =                (39 *      1) +                18
                    39 =                (18 *      2) +                 3
                    18 =                 (3 *      6) +                 0
3

```

### Some newlines and tabs added

```
x=$1{
    x<$2?x+=$2-(y=x):y=$2;
    a=length(x);
    b=length(y);
    for(d=length(x%y);t=y;x=t)
    {
        $++i=x;
        $++i=y;
        if(c<l=length($++i=int(x/y)))c=l;
        $++i=y=x%y
    }
    while(j<NF)
        printf "%"a"d = %"b-length($(j+2))"s(%d * %"c"d) + %"d"d\n",
                                               $++j,_,$++j,$++j,$++j
}$0=x

```

I can save the lengths of the initial values for x, y and x%y in the beginning, because they can only get shorter each step. But for the factor I have to determine the maximum length before printing anything, because it's length can vary. I use `$i` as an array here, because it saves two characters compared to using a\[i\] every time.

# Answer
> 4 votes
# C++, GCC compiler, 171 bytes( -10%, so 154 bytes)

okay so my first try..

```
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a<b)
    swap(a,b);
    while(b>0)
    {
        c=a;
        cout<<a<<" = ("<<b<<" * "<<a/b<<") + "<<a%b<<endl;
        a=b;
        b=c%b;
    }
    cout<<a;
}

```

tips to code golf appreciated.

P.S. Is it necessary to count bytes of standard header files and int main while using c++? Excluding it reduces 50 bytes

# Answer
> 3 votes
# T-SQL (2012+), 268 bytes

Implemented as an inline table function that executes a recursive CTE. Might be worthwhile trying to put formatting in for the 10% bonus, but that will have to wait.

```
CREATE FUNCTION E(@ INT,@B INT)RETURNS TABLE RETURN WITH M AS(SELECT IIF(@<@B,@B,@)A,IIF(@>@B,@B,@)B),R AS(SELECT A,B,A/B D,A%B R FROM M UNION ALL SELECT B,R,B/R,B%R FROM R WHERE 0<>R)SELECT CONCAT(A,'=(',B,'*',D,')+',R)R FROM R UNION ALL SELECT STR(B)FROM R WHERE R=0

```

Explanation and usage:

```
--Create the function
CREATE FUNCTION E(@ INT,@B INT)RETURNS TABLE RETURN
WITH
    --Order the input correctly
    M AS (
          SELECT IIF(@<@B,@B,@)A,
                 IIF(@>@B,@B,@)B
          )
    --Recursive selection
    ,R AS (
          SELECT A,B,A/B D,A%B R FROM M -- Anchor query
          UNION ALL
          SELECT B,R,B/R,B%R FROM R     -- Recurse until R = 0
          WHERE 0<>R
          )
SELECT CONCAT(A,'=(',B,'*',D,')+',R)R   -- Concat results into output string
FROM R
UNION ALL                               -- ALL required to maintain order
SELECT STR(B)                           -- Add final number
FROM R WHERE R=0

--Function Usage
SELECT * FROM E(447,501)

R
-----------------------------------------------------
501=(447*1)+54
447=(54*8)+15
54=(15*3)+9
15=(9*1)+6
9=(6*1)+3
6=(3*2)+0
3

```

# Answer
> 2 votes
# Rev 1: Ruby, 86

Recursive algorithm, thanks to tip from Doorknob.

```
f=->i,j{j>i&&(i,j=j,i)
0<j ?(print i," = (#{j} * #{i/j}) + #{i%j}
";f[j,i%j]):puts(i)}

```

# Rev 0: Ruby, 93

This really hasn't worked out well at all. The `while` loop takes up too many characters, especially with the `end`. I can't see a way of avoiding it. Recursion would require a named function instead of a lambda, which would also eat up a lot of characters.

```
->i,j{j>i&&(i,j=j,i)
while j>0
print(i," = (#{j} * #{i/j}) + #{i%j}\n")
i,j=j,i%j
end
puts i}

```

Call it like this:

```
f=->i,j{j>i&&(i,j=j,i)
while j>0
print(i," = (#{j} * #{i/j}) + #{i%j}\n")
i,j=j,i%j
end
puts i}

I=gets.to_i
J=gets.to_i

f.call(I,J)

```

# Answer
> 2 votes
# PowerShell, 84

A recursive code block, stored in a variable. Invoke it with `& $e num1 num2`, e.g.:

```
$e={$s,$b=$args|Sort;if(!$s){$b}else{$r=$b%$s;"$b=($s*$(($b-$r)/$s))+$r";&$e $s $r}}

PS D:\> & $e 9894 2628
9894=(2628*3)+2010
2628=(2010*1)+618
2010=(618*3)+156
618=(156*3)+150
156=(150*1)+6
150=(6*25)+0
6

```

In a more readable form, it does the following (nb. for clearer code, I've put the full commandlet names, more spaces in the string, and made the pipeline output commands explicit):

```
function Euclid {
    $small, $big = $args|Sort-Object   #Sort argument list, assign to two vars.

    if (!$small) {                     #Recursion end, emit the last
        Write-Output $big              #number alone, for the last line.

    } else {                           #main recursive code

        $remainder = $big % $small
        Write-Output "$big = ( $small* $(($big-$remainder)/$small)) + $remainder"
        Euclid $small $remainder
    }
}

```

One annoyance from a codegolf point of view; PoSh has no integer division, 10/3 returns a Double, but cast the result to an integer and it doesn't always round down, it rounds N.5 to the nearest even number \- up or down. So `[int](99/2) == 50`.

That leaves two awkward choices:

```
$remainder = $x % $y
$quotient = [Math]::Floor($x/$y)

# or, worse

$remainder=$null
$quotient = [Math]::DivRem($x, $y, [ref]$remainder)

```

Which is why I have to burn some characters doing:

```
$remainder = $big % $small
($big - $remainder)/$small

```

Apart from that, it's the number of $$$$ and the lack of ternary operator which really hurts.

---

I also have an iterative version which, rather nicely, is also 84 characters:

```
{$r=1;while($r){$s,$b=$args|Sort;$r=$b%$s;"$b=($s*$(($b-$r)/$s))+$r";$args=$s,$r}$s}

```

Completely anonymous codeblock, so run it with

```
& {*codeblock*} 1599 650

```

# Answer
> 2 votes
# PHP, 118 Bytes

```
for(list(,$n,$m)=$argv,$g=max($n,$m),$l=min($n,$m);$g;$g=$l,$l=$m)
echo$g,$l?"=($l*".($g/$l^0).")+".($m=$g%$l)."
":"";

```

Try it online!

# PHP, 131 Bytes

```
for(list(,$n,$m)=$argv,$r=[max($n,$m),min($n,$m)];$r[+$i];)echo$g=$r[+$i],($l=$r[++$i])?"=($l*".($g/$l^0).")+".($r[]=$g%$l)."
":"";

```

Try it online!

-4 Bytes replace `list(,$n,$m)=$argv` with `[,$n,$m]=$argv` needs PHP\>=7.1

# Answer
> 2 votes
# JavaScript (ES6), ~~74~~ ~~50~~ ~~62~~ ~~61~~ 55 bytes

```
f=(x,y)=>y?y>x?y:x+`=(${y}*${x/y|0})+${x%=y}
`+f(y,x):x

```
* Sacrificed 12 bytes allowing the integers to be passed in any order, rather than largest first.

---

## Try It

```
f=(x,y)=>y?y>x?y:x+`=(${y}*${x/y|0})+${x%=y}
`+f(y,x):x
o.innerText=f(i.value=683712533265363251376,j.value=18237983363879361)
i.oninput=j.oninput=_=>o.innerText=f(+i.value,+j.value)
```

```
<input id=i type=number><input id=j type=number><pre id=o>
```

---

## Explanation

```
f=          :Assign the function to variable f ...
(x,y)=>     :And take the two integer inputs as arguments via parameters x and y.
y?          :If y is greater than 0 then
y>x?        :    If y is greater than x then
f(y,x)      :        Call f again, with the order of the integers reversed.
            :        (This can only happen the first time the function is called.)
:           :    Else
x           :        Start building the string, beginning with the value of x.
+`=(        :        Append "=(".
${y}        :          The value of y.
*           :          "*"
${x/y|0}    :          The floored value of x divided by y
)+          :          ")+"
${x%=y}     :          The remainder of x divided by y, which is assigned to x
            :          (x%=y is the same as x=x%y.)
\n          :          A newline (a literal newline is used in the solution).
`+f(y,x)    :        Append the value f returns when y and the new value of x
            :        are passed as arguments.
:           :Else
x           :    Return the current value of x,
            :    which will be the greatest common divisor of the original two integers.

```

# Answer
> 2 votes
# Japt, ~~43~~ ~~42~~ 41 bytes

My newfound Japt "skills" seem to be getting worse, not better!

```
?U>V?ßVU :[V'='(U'*V/U|0')'+V%=UR,ßVU]¬:V

```

Try it online

# Answer
> 1 votes
# JS, 151

```
a=prompt("g","");b=prompt("l","");c=0;l=[a,b];for(var i=0;i<=1;i++){t=c;o=c+1;r=c+2;n=l[t]%l[o];if(n!==0){l[r]=n;c=c+1;i=0;}else{p=l[o];alert(p);i=2;}}

```

# Answer
> 1 votes
# C, 83 bytes

```
g(x,y,z){y&&(printf("%u=(%u*%u)+%u\n",x,y,x/y,z=x%y),z)?g(y,z,0):printf("%u\n",y);}

```

test and results

```
int main()
{g(18,27,0);
 g(50,20,0);
 g(447,501,0);
 g(9894,2628,0);
}

18=(27*0)+18
27=(18*1)+9
18=(9*2)+0
9
50=(20*2)+10
20=(10*2)+0
10
447=(501*0)+447
501=(447*1)+54
447=(54*8)+15
54=(15*3)+9
15=(9*1)+6
9=(6*1)+3
6=(3*2)+0
3
9894=(2628*3)+2010
2628=(2010*1)+618
2010=(618*3)+156
618=(156*3)+150
156=(150*1)+6
150=(6*25)+0
6

```

# Answer
> 0 votes
# Java 133

```
public void z(int i,int j){for(int d=1;d!=0;i=j,j=d){d=i%j;System.out.println(i+"=("+j+"*"+((i-d)/j)+")+"+d);}System.out.println(i);}

```

It doesn't do the regular Euclidean algorithm. Instead, it uses modulus and then computes the 2nd number to multiply by when it's printed out. You can also make this shorter by turning it into a lambda expression, but I'm not sure how.

```
public void z(int i, int j)
{
    for(int d=1;d!=0;i=j,j=d)
    {
        d=i%j;
        System.out.println(i+"=("+j+"*"+((i-d)/j)+")+"+d);
    }
    System.out.println(i);
}

```

# Answer
> 0 votes
# C# 115

First time on this forum

```
int g(int a,int b){(a,b)=a<b?(b,a):(a,b);Console.Write($"{a}=({b}*{a/b})+{a%b}\n");return a%b==0?b:g(b,a%b);}

```

# Answer
> 0 votes
# 05AB1E, ~~32~~ 30 bytes

```
{R[D`‰«Â`"ÿ=(ÿ*ÿ)+ÿ",¤_#ιθ}1è,

```

Inputs as a pair `[i,j]`. Output is without spaces.

Try it online or verify all test cases.

The -10% bonus isn't worth it to output in the correct format, but here it is anyway:
**48.6 bytes (54 bytes \- 10% bonus)**
<sup>† Should have been -1 byte by removing the `§`, but there is a bug with `j` and integer-lists.</sup>

```
{R[D`‰«¤_#¤UDιθ})øε§Zgj}øεR`"ÿ = (ÿ * ÿ) + ÿ"}Xª»„( Â:

```

Try it online or verify all test cases.

**Explanation:**

```
{               # Sort the (implicit) input-pair from lowest to highest
 R              # Reverse it from highest to lowest
[               # Start an infinite loop:
 D              #  Duplicate the current pair
  `             #  Pop one and push both values separated to the stack
   ‰            #  Divmod: a,b → [a//b,a%b]
    «           #  Merge the pairs together: [a,b,a//b,a%b]
 Â              #  Bifurcate this quadruplet; short for Duplicate & Reverse copy
  `             #  Pop and push the reversed items separated to the stack
   "ÿ=(ÿ*ÿ)+ÿ"  #  Push this string, where the `ÿ` are one by one filled with the values
              , #  Pop and output it with trailing newline
 ¤              #  Push the last value (`a%b`), without popping
  _             #  If this is 0:
   #            #   Stop the infinite loop
                #  (else)
 ι              #   Uninterleave it into two parts: [a,b,a//b,a%b] → [[a,a//b],[b,a%b]]
  θ             #   Pop and keep the last pair (`[b,a%b]`)
}               # After the infinite loop:
 1è             # Pop the final quadruplet, and leave its second item: `b`
   ,            # Pop and output it with trailing newline as well

```

```
{R[D`‰«         # Similar as above
¤_#             #  Similar as above as well
   ¤            #  Push the last item without popping again
    U           #  Pop and store it in variable `X`
     D          #  Duplicate the quadruplet
      ιθ}       #  Similar as above as well
)               # Wrap the quadruplets of the stack into a list
 ø              # Zip/transpose; swapping rows/columns
  ε             # Map over each inner list
   §            #  Cast every integer to a string (†bug work-around for builtin `j`)
   Z            #  Push the largest integer, without popping
    g           #  Pop and push its length
     j          #  Potentially add leading spaces so all values in the list are of this length
  }ø            # After the map: zip/transpose back
 ε              # Map over each inner list:
  R`            #  Push the items in reverse order to the stack
    "ÿ = (ÿ * ÿ) + ÿ"
                #  Push this string, where the `ÿ` are one by one filled with the values
 }Xª            # After the map: append value `X`
    »           # Join this list by newlines
     „(         # Push string "( "
       Â        # Bifurcate; short for Duplicate & Reverse copy: " ("
        :       # Infinitely replace "( " to " ("
                # (after which the string is output implicitly as result)

```

---
Tags: code-golf, math
---


title: Draw a BCD Binary clock

text:
# Question
Title: Draw a BCD Binary clock
Create a BCD binary clock in ASCII. As implied, it shall display time in six columns of dots:

(source: Wikimedia Commons)

Each column is a binary-coded digit, reading hours, minutes and seconds from left to right. Hours are given in 24-hour format.

The time to display is read from the command-line or from stdin (whichever fits better). If empty, the current time should be used instead.

Output size is a little constrained here and we can only fit two lines of text. So you are required to put the dots into only two lines. The characters `.`, `:` and `'` come in handy here.

**Input**

The time to display in ISO-8601 format, i.e. `HH:MM:SS` without fractional seconds. Mandatory 24-hour format. Input can be empty in which case the current time will be used.

**Output**

Two lines with represent the BCD binary clock as in the image above. Each line is exactly six characters long and the only allowed characters are space, period, colon and apostrophe.

**Winner**

Shortest code by byte count wins. In a tie, the solution posted first wins.

**Sample input 1**

```

```

*(empty)*

**Sample output 1**

```
     .
''. ::

```

**Sample input 2**

```
17:59:20

```

**Sample output 2**

```
 ..'
.:..'

```

**Sample input 3**

```
01:08:01

```

**Sample output 3**

```
   '
 .   .

```

# Answer
## Golfscript (+ruby/date) - 46 chars

```
"#{`date`}"10>+9<" .':":S-.{4/12-S=}%n@{4%S=}%

```

You can replace ``date`` with `Time.now` if necessary (+2 chars).
> 5 votes

# Answer
## Ruby, ~~107 103 99 94~~ 90 characters

```
$><<[$/,(gets||Time.now.to_s[11,8]).tr(z=" .':","").bytes.map{|a|$><<z[a/4-12];z[a%4]}]*""

```

Note that the input shouldn't contain a linebreak, so to test the solution use something like `echo -n "01:08:01" | ruby1.9 bcd.rb`.

To test the default behavior, run it with `ruby1.9 bcd.rb` and enter `^D` (i.e. a literal EOF).
> 5 votes

# Answer
## Windows PowerShell, 81

Since I did not create an implementation when writing the task I feel myself eligible to golf it from the start, too :-)

```
-join" .':
"[(($d="$(date)$args"[-8..-1]-ne58)|%{($_-band12)/4})+,4+($d|%{$_%4})]

```

History:

* 2011-02-26 23:50 **(119)** First attempt.
* 2011-02-26 23:55 **(108)** Inlining fun.
* 2011-02-27 00:03 **(102)** Optimized selecting the first line. `[Math]::Floor` is waaaayy too long. I hate that.
* 2011-02-27 02:22 **(101)** I don't need `:` for the first line.
* 2011-02-27 02:53 **(95)** Optimized getting input or current time.
* 2011-03-04 20:36 **(88)** Only a single join remains. Indexing every character needed (including the line break) from a single string.
* 2011-03-04 20:39 **(83)** Using `58` instead of `:` which auto-casts to integer as well – no more need to enclose `$_` in quotes :-)
* 2011-03-04 20:42 **(81)** The parentheses after the `-join` are no longer necessary.
> 3 votes

# Answer
# Jelly, 21 bytes

```
o7ŒT¤fØDV€d4Zị“.': ”Y

```

Try it online!

For the empty input, you can use either an empty string or no argument at all.

## Explanation

```
o7ŒT¤fØDV€d4Zị“.': ”Y   Main monadic or niladic link
o                       Logical or (Python-like)
 7ŒT¤                     Current time in hh:mm:ss format
     f                  Filter
      ØD                  Digits
         €              Each
        V                 Evaluate
          d             Divmod
           4              4
            Z           Zip
             ị          Index into [1-indexed, auto-maps]
              “.': ”      ".': "
                    Y   Join with newlines

```
> 3 votes

# Answer
# C#

### 236 characters

```
using System;using System.Linq;class X{static void Main(){var d=Console.In.ReadToEnd().Replace(":","");for(int i=0;i<2;i++)Console.WriteLine(string.Join("",(d==""?DateTime.Now.ToString("HHmmss"):d).Select(c=>" .':"[i<1?c/4-12:c%4])));}}

```

Readable:

```
using System;
using System.Linq;
class X
{
    static void Main()
    {
        var d = Console.In.ReadToEnd().Replace(":", "");
        for (int i = 0; i < 2; i++)
            Console.WriteLine(string.Join("",
                (d == "" ? DateTime.Now.ToString("HHmmss") : d)
                .Select(c => " .':"[i < 1 ? c / 4 - 12 : c % 4])));
    }
}

```
> 2 votes

# Answer
# Ruby - 124 chars

```
t=*((i=gets)=="
"? Time.now.strftime('%H%M%S'):i).tr(':
','').bytes
puts (0..1).map{|i|t.map{|_|" .':"[i<1? _/4-12:_%4]}*''}

```
> 2 votes

# Answer
## Golfscript (+ Ruby), 63

```
."#{Time.now.strftime'%T'}"if':'-:|{4/12-" .':":@\=}%n|{4%@\=}%

```

Still a beginner with Golfscript. Don't hit me.
> 2 votes

# Answer
## Perl (84)

```
#!perl -pl
$_||=localtime;y/://d;/\d{6}/;$_=$&;y/0-9/    ....''/;$_.="\n$&";y/0-9/ .': .': ./

```
> 2 votes

# Answer
# Python 3, 136 chars

```
import time
d=input()
for i in(0,1):print(''.join([" .':"[[c>>2,c&3][i]]for c in map(int,d.replace(':','')or time.strftime('%H%M%S'))]))

```
> 2 votes

# Answer
## VimScript, 143 characters

```
if getline(1)==''
norm"=strftime("%T")^Mp
en
nm- "ax"=@a/4^MgP
nm, "ax"=@a%4^MgP
norm0YP--x--x--xP^M,,x,,x,,xP
%s/0/ /g
%s/1/./g
%s/2/'/g
%s/3/:/g

```
> 2 votes

# Answer
# APL (Dyalog Extended), ~~45~~ 42 bytes

```
' .'':'[4 4⊤{×≢⍵:⍎¨⍵~':'⋄,⍉0 10⊤3↑3↓⎕TS}⍞]

```

Try it online!

A full program submission.

-3 bytes from Bubbler.

Very barely edges out Golfscript (Thanks, Bubbler!).

## Explanation

```
' .'':'[4 4⊤⍎¨{×≢⍵:⍵~':'⋄,⍉ 0 10⊤3↑3↓⎕TS}⍞]
                                        ⍞    string input
              {×≢⍵:                          if length is nonzero:
                   ⍵~':'                     remove ':'s from it
                        ⋄            ⎕TS     otherwise get current time array
                                 3↑3↓        remove yymmdd and take hhmmss
                         ,⍉ 0 10⊤            convert to base 10 digits and transpose, then flatten
                                             (pads with a zero)
            ⍎¨                               convert each character to digit
        4 4⊤                                 encode into base 4 matrix
' .'':'[                                   ] index into string " .':"

```
> 2 votes

# Answer
# Javascript, ~~232~~ 165 characters

```
t=>(a=t.match(/\d/g).map(x=>(+x).toString(2)).flatMap(x=>x.padStart(4).match(/..?/g)).map(x=>" .':"[x%4])).filter((_,i)=>~i&1).join``+`
`+a.filter((_,i)=>i%2).join``

```

# Snippet

(modified because i dont count console.log() and the function assignment/call in the byte count)

```
f=

// 215
t=>(a=t.match(/\d/g).map(x=>(+x).toString(2)).flatMap(x=>x.padStart(4).match(/..?/g)).map(x=>" .':"[x%4])).filter((_,i)=>~i&1).join``+`
`+a.filter((_,i)=>i%2).join``

console.log(f('17:59:20'))
```
> 2 votes

# Answer
# Haskell, 192 180 174 166 bytes

-21 characters thanks to @Laikoni

```
import Data.Time
main=getCurrentTime>>=interact.(\x y->unlines[map(!!i)[mapM(pure" .':")"__"!!(fromEnum e-48)|e<-take 8$y++formatTime undefined"%T"x,e<':']|i<-[0,1]])

```

Try it online!
> 2 votes

# Answer
## Python - 201 172 characters

```
from time import*
t=raw_input()
if not t:t=strftime('%H:%M:%S')
t=t.replace(':','')
for i in(0,2):print''.join(" .':"[int(bin(int(d))[2:].rjust(4,'0')[i:i+2],2)]for d in t)

```
> 1 votes

# Answer
**Lua - 163 160 Chars**

```
s=io.read():match"(%S+)"or os.date("%X",os.time())t=" .':"w=io.write for l=1,2 do for k in s:gmatch"(%d)"do y=1+select(l,(k-k%4)/4,k%4)w(t:sub(y,y))end w"\n"end

```
> 1 votes

# Answer
# VBA (Excel), ~~150~~ ~~148~~ 132 bytes

Using Immediate Window and Cell `[A1]` as input.

```
a=Format(IIf([a1]="",Now,[a1]),"hhmmss"):b=Split(" ,.,',:",","):For c=1To Len(a):d=Mid(a,c,1):e=e &b(d\4):f=f &b(d Mod 4):Next:?e:?f

```
> 1 votes

# Answer
# K (ngn/k), 35 bytes

```
{-1_'" .':"@2/+0 2_2\.'(x^":"),"9"}

```

Try it online!
> 1 votes

# Answer
### Scala, 222:

```
object C{def main(a:Array[String]){
val t=if(a.length==0)new java.text.SimpleDateFormat("HHmmss").format(new java.util.Date)else a(0).replaceAll(":","")
t.map(c=>print(" ,'"(c/4%4)));println;t.map(c=>print(" ,':"(c%4)))}}

```
> 0 votes

# Answer
# Dash (SUSv2-compatible?), ~~202~~ ~~200~~ ~~193~~ ~~169~~ ~~138~~ 137 bytes

Usage.

* Requires input from positional argument.
* Outputs to stdout, without trailing line.

I think I should change the language for golfing off.

Notes about 138 and 137 bytes:

* May not SUSv2-compatible because it gives floating value to second argument for `substr()` in AWK.
* It ran successfully on GAWK.

```
s='for(;++i<7;){D=substr($0,i,1);printf substr(" .'\'':",(h?D%4:D/4)+1,1)}i=h++'
echo ${1-`date +%H%M%S`}|tr -d :|awk "{$s;$s}"|fold -w 6

```

Try it online!
> 0 votes

# Answer
# 05AB1E, 28 bytes

```
õQižažbžc)T‰}Sþ4‰ø" .':"sèJ»

```

Try it online or verify all test cases.

**Explanation:**

```
õQi                # If the (implicit) input is empty/absent:
   ža              #  Push the current hours
     žb            #  Push the current minutes
       žc          #  Push the current seconds
         )         #  Wrap all three into a list
          T‰       #  Divmod each by 10 to add leading 0s
  }S               # After the if-statement: convert it to a flattened list of characters
                   # (which will use the implicit input-string if necessary)
    þ              # Only keep all digits to remove potential ":"
     4‰            # Divmod each digit by 4
       ø           # Zip/transpose; swapping rows/columns
        " .':"sè   # Index each into string " .':'
                J  # Join each row of characters together
                 » # Join the lines by newlines
                   # (after which the result is output implicitly)

```
> 0 votes

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


title: Swapping heightmaps to depthmaps

text:
# Question
Title: Swapping heightmaps to depthmaps
## Description

Your task is to output a 'depthmap' - that is, a heightmap of an object but not seen from its top but from its front.

For example, consider the following object as shown on the image. The height map is shown on the left. The corresponding depth map would be (as seen from standing at the arrow):

```
010
211   <- Depthmap
322

```

If you stand at the arrow, there are 3 cubes behind each other at the bottom left-hand point, 2 behind each other on the middle left-hand point, 0 at the top left-hand point etc.

## Input

Input is a two dimensional array of any sizes (not necessarily square).

## Output

Output is another two dimensional array which represents the depthmap. As you can deduce, its sizes are `(height x width)`. In the image, it would be `(3 x 3)`. Note that if the highest tower of cubes was 5, the depthmap would be an array of `(5 x 3)`.

## Winning condition

The shortest code wins.

## Disallowed

All languages allowed, no explicit restrictions. (I don't know what you can come up with, but play fair please.)

## Examples

```
Input:     Ouput:

5321       0001
1456       1012
2105       1112
           1212
           2222
           3323

Input:     Output:

22         01
13         12
00         22

Input:     Output:    (of the sample image)

232        010
210        211
101        322

```

# Answer
### Golfscript, 42 chars

```
n%{n*~]}%zip:|[]*$),{:);n|{{)>},,}%}%-1%\;

```

results

```
$ golfscript 2657.gs < 2657-1.txt
0001
1012
1112
1212
2222
3323

$ golfscript 2657.gs < 2657-2.txt
01
12
22

$ golfscript 2657.gs < 2657-3.txt
010
211
322

```
> 12 votes

# Answer
## Ruby 1.9, 102 characters

```
f=$<.map{|g|[*g.chop.bytes]}
f.flatten.max.downto(49){|j|puts f.transpose.map{|n|n.count{|r|r>=j}}*""}

```

Passes all testcases.
> 8 votes

# Answer
## Windows PowerShell, 108 ~~111~~ ~~114~~

```
(($i=@($input))-split''|sort)[-1]..1|%{$h=$_
-join(1..$i[0].Length|%{$x=$_-1
@($i|?{"$h"-le$_[$x]}).count})}

```

Passes all test cases.
> 7 votes

# Answer
## Haskell, 118 characters

```
import List
p h=map(\c->transpose(lines h)>>=show.length.filter(>=c))['1'..maximum h]
main=interact$unlines.reverse.p

```

---

* Edit (122 → 118): avoid filtering by only iterating to maximal height
> 7 votes

# Answer
## Scala 236 characters

```
object D extends App{var(l,m,z)=(io.Source.stdin.getLines.toList,0,0);val a=Array.ofDim[Int](l.head.size,10);for(i<-l;(j,q)<-i.zipWithIndex;x<-1 to j-48){a(q)(x-1)+=1;m=List(m,j-48).max};for(i<-1 to m){for(j<-a){print(j(m-i))};println}}

```

With some formatting:

```
object Depthmap extends App
{
    var(l,m,z)=(io.Source.stdin.getLines.toList,0,0)
    val a=Array.ofDim[Int](l.head.size,10)
    for(i<-l;(j,q)<-i.zipWithIndex;x<-1 to j-48)
    {
        a(q)(x-1)+=1
        m=List(m,j-48).max
    }
    for(i<-1 to m)
    {
        for(j<-a)
        {
            print(j(m-i))
        }
        println
    }
}

```

I'm sure a better facility with for comprehensions would mean I could cut some characters from this.
> 4 votes

# Answer
## JavaScript, ~~235~~ ~~208~~ 195 bytes

```
function _(b){for(e=Math.max.apply(0,b.join().split(",")),f=[],c=i=0;i<e;i++){for(
c=[],a=0;a<b[0].length;a++)for(d=c[a]=0;d<b.length;d++)b[d][a]>i&&c[a]++;f[e-i-1]
=c.join("")}return f.join("\n")}

```

Just for the record, this is the code I made up before posting the question. (Smallened now)
> 4 votes

# Answer
Haskell Version (Now optimized)

```
import Data.List
import Text.Parsec
import Text.Parsec.String

main= readFile"in.txt">>=(\t->either print(putStrLn.intercalate"\n".map(concatMap show).(\j->map (\n->(map(length.(filter(>=n)))(transpose$reverse j))) (reverse [1..(maximum$map maximum j)])))(parse(many1$many1 digit>>=(\x->newline>>(return$map(read.return)x)))""t))

```

Ungolfed version

```
import Data.List (foldl', transpose, intercalate)
import Text.Parsec
import Text.Parsec.String

-- Source:  http://codegolf.stackexchange.com/questions/2657/swapping-heightmaps-to-depthmaps

digitArray :: Parser [[Int]]
digitArray = many1 $ do xs <- many1 digit
                        optional newline
                        return $ map (read . return) xs

maxHeight :: Ord c => [[c]] -> c
maxHeight = maximum . (map maximum)

heightToDepth :: [[Int]] -> [[Int]]
heightToDepth ins = level (maxHeight ins)
        where level 0 = []
              level n = (map (length . (filter (>=n))) xs) : level (n-1)
              xs      = transpose $ reverse ins

lookNice xs = intercalate ['\n'] $ map (concatMap show) xs

main = do inText <- readFile "in.txt"
          case parse digitArray "" inText of
              Left err -> print err
              Right xs -> putStrLn $ lookNice $ heightToDepth xs

```
> 3 votes

# Answer
## Python, 117 chars

```
import sys
a=zip(*sys.stdin)[:-1]
n=int(max(map(max,a)))
while n:print''.join(`sum(e>=`n`for e in r)`for r in a);n-=1

```

Similar to Ventero's Ruby solution.
> 1 votes

# Answer
# Uiua, 10 bytes

```
⇌⍉/+⬚0∵↯∶1

```

Try it online!

```
⇌⍉/+⬚0∵↯∶1    input: a matrix of numbers
        ∵↯∶1    replace each number with that many 1s repeated...
     ⬚0         ...filling the remaining space in the 3D array with zeros
   /+            sum layers element-wise
⇌⍉              transpose and reverse to put the result in correct orientation

```
> 1 votes

# Answer
# APL (Dyalog Extended), 14 bytes

```
{⊖⍉+⌿⍵≥⍀⍳⌈/,⍵}

```

Try it online!

```
{⊖⍉+⌿⍵≥⍀⍳⌈/,⍵}    Monadic function:
             ⍵     Start with a 2D array ⍵.
          ⌈/,      Find the overall maximum value h.
         ⍳         Make the list 1...h
       ≥⍀          Make a ≥ table between that list and ⍵.
                   Now we have a 3D matrix where position [a,b,c]
                   represents whether ⍵[a,b] is at least c.
    +⌿             We sum along the outermost (first) dimension,
                   since that corresponds to a column of ⍵.
                   Now we have a 2D matrix where position [b,c]
                   represents how many values in column b of ⍵ are at least c.
  ⍉                Transpose so the heights are rows.
 ⊖                 Flip vertically.

```
> 0 votes

# Answer
## Clojure, 102 bytes

```
#(for[h(range(apply max(flatten %))0 -1)](map(fn[w _](count(for[r % :when(>=(r w)h)]_)))(range)(% 0)))

```
> 0 votes

# Answer
# Japt, 12 bytes

```
c rÔÆÕËè>X
w

```

Try all test cases

Outputting the rows in reversed order would save 2 bytes, taking input in column-major order would save 1 byte, doing both would (naturally) save 3 bytes

Explanation:

```
c rÔ          #Find the maximum height
    Æ         #For each number X in the range [0...max_height]:
     Õ        # Get the columns of the input
      Ë       # For each column:
       è>X    #  Count how many items are greater than X

w             #Reverse the output

```
> 0 votes

# Answer
# Julia, 55 bytes

```
!a=[sum(a[:,j].>m-i) for i=1:(m=max(a...)),j=axes(a,2)]

```

Attempt This Online!
> 0 votes

---
Tags: code-golf
---


title: Transpose a multidimensional array

text:
# Question
Title: Transpose a multidimensional array
Transposition is an operation on 2-dimensional arrays that flips every element across the main diagonal:

```
[[1,2,3],    [[1,4],
 [4,5,6]] ->  [2,5],
              [3,6]]

```

If we call the above array `m`, then the `2` is the second item of the first row of `m`, or `m[0][1]`. The `2` can be thought of as having a *coordinate* of `[0, 1]` in the array because of this. When the matrix is transposed, the `2` moves to the first item of the second row, or `m[1][0]`, and its coordinate is now `[1, 0]`.

In general, tranposition can be described as taking the coordinate of every item in the array and swapping the first and second item. This can be generalised to higher dimensions by taking the coordinate rotating it left by one item - moving the first item of the coordinate to the end.

This idea of a coordinate extends fairly easily to arrays of higher dimensions. For example, with the array `z = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]`, the `6` is `z[1][0][1]`, and its coordinate is `[1, 0, 1]`.

If we apply the same idea of transposition to this coordinate, the coordinate of 6 `[1, 0, 1]` is shifted left by one item to result in `[0, 1, 1]`, meaning it is now `z[0][1][1]`. Similarly, the `2` with coordinate `[0, 0, 1]` is rotated left to result in `[0, 1, 0]`If we apply this operation to every element of the array, we get `[[[1, 5], [2, 6]], [[3, 7], [4, 8]]]`.

Your challenge is to apply this transformation to a multidimensional rectangular array of positive integers.

You may additionally take the dimensions of the array.

## Testcases

```
[[1]] -> [[1]]
[[[[1, 2]]]] -> [[[[1], [2]]]]
[[1, 2, 3], [4, 5, 6]] -> [[1, 4], [2, 5], [3, 6]]
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]] -> [[[1, 5], [2, 6]], [[3, 7], [4, 8]]]
[[[[9]], [[10]]]] -> [[[[9]]], [[[10]]]]
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]] -> [[[1, 7], [2, 8], [3, 9]], [[4, 10], [5, 11], [6, 12]]]

```

# Answer
# Python 3, 51 bytes

```
f=lambda a,b:b<2and[*a]or[f(x,b-1)for x in zip(*a)]

```

Try it online!

Takes as input the list and then the dimension.

If we look at the list of dimensions, a 2D transpose is equivalent to swapping the first two, so if we recursively do that we swap dimensions 0,1, then 1,2, and so on, so we move the first dimension to the last position.

If the output can contain have tuples in the topmost level it can be -1 by replacing `and[*a]or` with `and a or`.

# Python 3 \+ numpy, ~~37~~ 36 bytes

-1 thanks to @loopwalt

```
lambda a,b:a.transpose(range(1-b,1))

```

Try it online!

Takes a numpy array and the dimension as input.
> 9 votes

# Answer
# , 23 bytes

```
\(x,d)aperm(x,1:d%%d+1)

```

Attempt This Online!

A situation where R has a built-in that meets the requirements! A function that takes a multidimensional array and the number of dimensions as its two parameters and returns a multidimensional array with the coordinates transposed left one.

Note that in the printout R loops through dimensions that are 3 or above, printing a 2d matrix for each 2d plane. Within that matrix, rows are dimension 1 and columns are dimension 2.

Thanks to @Giuseppe for suggesting a fix that works for 1-dimensional arrays.
> 6 votes

# Answer
# Uiua, 1 byte

Try it!

(When reading the output, dashes on the left indicate the rank of the array and whitespace separates axes.)
> 5 votes

# Answer
# Nekomata, 6 bytes

```
ʷ∑→ᵉbD

```

Attempt This Online!

```
ʷ∑→ᵉbD          Take [[[1,2],[3,4]],[[5,6],[7,8]]] as an example
ʷ∑          Sum of the nested array
                [[[1,2],[3,4]],[[5,6],[7,8]]] -> 36
  →         Increment
                36 -> 37
   ᵉb       Convert the input from a list of digits in that base
                [[[1,2],[3,4]],[[5,6],[7,8]]], 37 -> [[42,80],[118,156]]
     D      Convert each number back to a list of digits in that base
                [[42,80],[118,156]], 37 -> [[[1,5],[2,6]],[[3,7],[4,8]]]

```

This works because `b` and `D` are vectorized in different ways.

`b` (`\fromBase`) is not vectorized by itself. It simply views the input as a list of digits in that base. However, when converting the list of digits to a number, the addition and multiplication are vectorized. For example `[[[1,2],[3,4]],[[5,6],[7,8]]] 37 b` is `[[1,2],[3,4]]*37+[[5,6],[7,8]]=[[42,80],[118,156]]`.

`D` (`\toBase`) is vectorized in the usual way. It converts each number in the input to a list of digits in that base. For example `[[42,80],[118,156]] 37 D` converts each number (`42`,`80`,`118`,`156`) to a list of digits in base 37, which is `[[[1,5],[2,6]],[[3,7],[4,8]]]`.
> 4 votes

# Answer
# Python 2, 33 bytes

```
f=lambda*L:L*(L<(f,))or map(f,*L)

```

Attempt This Online!

Ports @Command Masters Python 3 (non numpy). Takes splatted input. Innermost lists will be tuples.
> 3 votes

# Answer
# 05AB1E, 21 bytes

```
JΔ€`}\N<Ý®K"€"×'ø«J.V

```

Try it online or verify all test cases.

**Explanation:**

```
J         # Join each inner-most list together to a single item
 Δ€`}\N<  # Then determine the depth-2 of this multidimensional list
 Δ  }     #  Loop until it no longer changes:
  €`      #   Flatten it one level down
     \    #  After the changes-loop, discard the resulting flattened list
      N   #  Push the last 0-based index
       <  #  Decrease it by 1
Ý         # Push a list in the range [0,depth-2]
 ®K       # Remove -1 so [0,-1] becomes [0]
"€"×      # Convert each value in this list to that many "€" as string
    'ø«  '# Append an "ø" to each string
       J  # Join this list of strings together
.V        # Evaluate and execute it as 05AB1E code on the (implicit) input
          # (after which the result is output implicitly)

```

Try all test cases without the `.V` to see which maps/transpose builtins are actually being generated by `JΔ€`}\N<Ý®K"€"×'ø«J`, where  is a map (and therefore `€€` a nested map) and `ø` transposes a matrix/2D-list, swapping its rows/columns.

***Minor notes:***

1. Using `Δ€`}\NÍ` (where `Í` is -2) only seems to work for the last test case: try it online; and with `<` but without the leading `J` it works for some of the test cases, but not the last two: try it online; so using a leading `J` and `>` works for all test cases.
2. The range builtin `Ý` also accepts negative values for its \\$\[0,n\]\\$-ranged list. So for singular lists, it'll result in `[0,-1]` after both the `J` and `Δ€`}\N<`, for which the `-1` are ignored by the `×` and it basically evaluates `ø-1ø`: try it online.
3. Why use `"€"` for string  but  for string `ø`? Because `'` is also used for pushing a dictionary word, and `'€×` is apparently the dictionary word `view`: try it online; whereas `'ø«` is coincidentally none: try it online.
> 2 votes

# Answer
# Charcoal, 42 bytes

```
⊞υθＦυ«≔Ｅ⌊ιＥι§μληＷι≔⊟ικＦη⊞ικＦη¿⁺⟦⟧⌊κ⊞υκ»⭆¹θ

```

Try it online! Link is to verbose version of code. Explanation: Port of @CommandMaster's Python 3 answer.

```
⊞υθ

```

Start by processing the input array.

```
Ｆυ«

```

Loop over the arrays that need to be transposed.

```
≔Ｅ⌊ιＥι§μλη

```

Transpose the top two dimensions of the current array.

```
Ｗι≔⊟ικＦη⊞ικ

```

Replace the contents of the original array with that of the transposed array, thus transposing the array in-place.

```
Ｆη¿⁺⟦⟧⌊κ⊞υκ

```

If the elements of the transposed arrays are themselves arrays rather than lists of numbers, then push those arrays so that they get transposed in-place.

```
»⭆¹θ

```

Pretty-print the final state of the original array.

41 bytes using the newer version of Charcoal on ATO:

```
Ｗ⁺⟦⟧ΣΣθ«⊞υＬ⌊⌊θＵＭθΣκ»≔Ｅ⌊θＥθ§λκθＦ⮌υ≔⪪θιθ⭆¹θ

```

Attempt This Online! Link is to verbose version of code. Explanation:

```
Ｗ⁺⟦⟧ΣΣθ«

```

Until the input array has two dimensions, ...

```
⊞υＬ⌊⌊θ

```

... record the number of elements in the third dimension, and...

```
ＵＭθΣκ

```

... flatten the third dimension into the second dimension.

```
»≔Ｅ⌊θＥθ§λκθ

```

Transpose the array.

```
Ｆ⮌υ

```

Loop over the sizes of the dimensions.

```
≔⪪θιθ

```

Unflatten the array.

```
⭆¹θ

```

Pretty-print the final array.

32 bytes by taking the dimensions of the array as a second argument:

```
Ｆ✂η²ＵＭθΣκ≔Ｅ⌊θＥθ§λκθＦ⮌✂η²≔⪪θιθ⭆¹θ

```

Attempt This Online! Link is to verbose version of code. Explanation: As above, but using the input dimensions, ignoring the first two which aren't needed.

26 bytes by taking a list of dimensions and a flattened array as I/O:

```
Ｆ…θ¹Ｉ⟦⊞ＯΦθλιＥη§§⪪η÷Ｌηιλ÷λι

```

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

```
  θ                         Input dimensions
 …                          Truncated to length
   ¹                        Literal integer `1`
Ｆ                           Loop over dimension
         θ                  Input dimensions
        Φ                   Filtered where
          λ                 Not first dimension
      ⊞Ｏ                    Concatenated with
           ι                First dimension
             η              Input array
            Ｅ               Map over elements
                 η          Input array
                ⪪           Split into arrays of length
                    η       Input array
                   Ｌ        Length
                  ÷         Integer divided by
                     ι      First dimension
               §            Cyclically indexed by
                      λ     Current index
              §             Indexed by
                        λ   Current index
                       ÷    Integer divided by
                         ι  First dimension
     ⟦                      Separate dimensions from elements
    Ｉ                       Implicitly print

```

`Ｆ…θ¹` saves a byte over `≔§θ⁰ι` and two bytes over repeating `§θ⁰` instead of `ι`.

(Length of array could also be product of dimensions of course.)
> 2 votes

# Answer
# Wolfram Language (Mathematica), 13 bytes

```
#0/@Thread@#&

```

Try it online!

Input `[array]`. Recursively `Thread`s the first dimension through all other dimensions. `Thread` behaves more nicely than `\[Transpose]` on arrays of dimension \<2.

---

## Wolfram Language (Mathematica), 23 bytes

```
D'[[0]][,{##},Listable]

```

Try it online!

Taking a rare chance to showcase `Function`'s 3-argument form, which lets us set attributes on a pure function, even if this ends up being almost twice the length of the shortest solution.

Input `[array...]`. Append `@@#&` to take `[array]` input.

A `Listable` function that enlists its arguments. `D'[[0]]` is slightly shorter than writing out `Function`.
> 2 votes

# Answer
# Julia, 37 bytes

```
~=ndims
!x=permutedims(x,[~x;1:~x-1])

```

Attempt This Online!
> 0 votes

---
Tags: code-golf, array
---