# Question
Title: What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?
I think the question as above is clear, but just in case:

* Write a *full* program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.
* Qualifying programs will be those whose output is longer (**in bytes**) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).

I.e. the code must be shorter than the number of digits in the resulting number.
* Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.
* The winning program will be the qualifying program which prints the integer with the smallest magnitude.

### Leaderboard snippet

```
var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
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) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\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.replace(/<sup>([^\n<]*)<\/sup>/g, "^$1").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "$1 ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), 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 src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<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>
<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>
```

# Answer
> 206 votes
## Retina, score 1

```

```

The empty program counts the number of matches of the empty regex in the input (which is the empty string). That's exactly 1 match, so it prints `1`.

Try it online.

# Answer
> 76 votes
# Pyth, 10

```
T

```

First attempt at using Pyth. Having had the question clarified, it seems 10 will be the smallest number. In Pyth the letter T starts off as the number 10, so this simply prints `10` which is larger than the length of the source code. You can try it here.

# Answer
> 62 votes
# bc, 10

```
A

```

Luckily, `bc` prints the result of the last expression by default. `A` is interpreted as a hex digit, so results in `10`.

# Answer
> 50 votes
# Fishing, score ~~7,958,661,109,946,400,884,391,936~~ 1,208,925,819,614,629,174,706,176

Is this the highest non-trivial-looking score ever in a minimization challenge? (Even though it has been golfed by 84.8%)

```
v+CCCCCCCCCC
  `32`nSSSSP

```

---

Explanation

```
v              Sets the casting direction to down
 +             Increments the casting distance by 1
  CCCCCCCCCC   Casts the rod

`32`         Pushes a string "32" to the stack
    n        Converts the stack from a string to an integer
     SSSS    Repeated squaring of the stack
         P   Prints the stack

```

The number is `32^16` and has 25 digits. The code is 24 bytes long. The previous answer was `6^32`.

# Answer
> 40 votes
# MATLAB, 1,000,000,000 (109)

Also works with **Octave**

```
disp(1e9)

```

Never going to beat the esolangs, but just for fun, this is the smallest MATLAB/Octave will be able to do, so thought I would post it anyway.

# Answer
> 30 votes
# TI-84 BASIC, 120

```
5!

```

`ᴇ2` would score better if not for the silly UTF-8 requirement. (It's only two bytes in the calculator's native tokenized encoding, but it's 4 in UTF-8...)

# Answer
> 28 votes
# Hexagony, score 100100

Code:

```
d!!@

```

In a more readable form:

```
  d !
 ! @ .
  . .

```

The char value of `d` is 100. This will simply print the char value twice and terminates after.

Try it online!

# Answer
> 27 votes
## C#, score ~~10^72~~ ~~10^70~~ ~~10^64~~ 10^63

```
class A{static void Main(){System.Console.Write($"1{0:D63}");}}

```

That's 1,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000. I guess that I tried...

# Answer
> 20 votes
## JavaScript, score 100,000,000,000 (or 1\*1011)

```
alert(1e11)
```

This is if using alert. Though you can get 100 000 000 times lesser score if using console:

```
1e3

```

Score 1000 as you can see, I'm not sure it counts using the console though.

# Answer
> 19 votes
# PlatyPar, 59

```
#

```

`#` starts a numeric base-60 literal, and since no digits are found, it ends up as `59`. This started as a happy accident, but since I have already \[ab\]used this bug in another answer, I kept it.

Try it online!

Here's another approach, my take on the boring way that everyone and their grandmother used for this challenge.

# PlatyPar, 100000000 (9 digits)

```
'18Md0+;

```

Explanation

```
'1        ## push "1" (a string) to the stack
  8Md  ;  ## repeat 8 times
     0+    ## add a 0
          ## [implicitly] print the result

```

Try it online!

# Answer
> 17 votes
# C, 1000000000000000000000000000 (28 digits)

```
main(){printf("1%027d",0);}

```

Similar to my C++ answer, without the `#include <stdio.h>` (Ignore the warning about missing declaration of `printf`. Thanks @Dennis)

Newline would require an additional 2 bytes, using format `1%029d\n`

# Answer
> 16 votes
# Brainf\**k, 11111111111111111111111111111111111 (~1e34)

And another reduction:

```
+++++++[>+++++++>+<<-]>>[<.....>-]

```

Which gives 35 consecutive 1's, or approximately 1e34.

---

A bit smaller still

```
++++++++[>++++++>+<<-]>+>+[<....>-]

```

Gives 36 1's which is a number about 11% larger than 1e35.

---

Thanks to @Martin Büttner for knocking off a couple of characters reducing the total output by a factor of 100 with this code (yields 1e36):

```
++++++[>++++++++>++<<-]>+.->[<...>-]

```

---

My old code (yields 1+e38):

```
++++++++[>++++++>++<<-]>+.->+++[<..>-]

```

I've been experimenting with esolangs out of boredom. This is the best I could do in BF. I wonder if it is possible to make it smaller?

You can try it online here.

# Answer
> 14 votes
## Japt, score 10

```
A

```

As shows the score, prints 10.

# Answer
> 13 votes
## Python 2, 101010101010

```
print'10'*6

```

# Answer
> 10 votes
## PHP, score 10,000,000

```
<?=1e7;

```

This prints 10000000 as can be seen there.

# Answer
> 10 votes
# Brainfuck, 3333333333333333333333333 (25 threes)

This is written "from scratch" so I think it's okay to post a separate answer:

```
-[>+>+<<-----]>-[-->.<]

```

23 bytes long.

# Answer
> 9 votes
## Labyrinth, score 10,000,000

```
1!!!!>@

```

It might be possible to bring this down by one order of magnitude, but I can't find anything right now.

The first `1!!!!` prints `1000`. Then `>` shifts the source code to

```
@1!!!!>

```

which avoids early termination. Then the IP hits a dead end and turns around. Now `!!!!` prints four more zeroes and `@` terminates the program.

Try it online.

# Answer
> 9 votes
# DC, 10000

4 chars program:

```
I4^f

```

5 digits output:

```
$ dc<<<'I4^f'
10000

```

# Answer
> 9 votes
# Samau, 42

```
A

```

`A` pushes the Answer to the Ultimate Question of Life, The Universe, and Everything onto the stack. Then the top of the stack is automatically printed.

# Answer
> 8 votes
# Vitsy, 7! = 5040

```
7FN
```

Outputs 5040.

Try it online!

# Answer
> 8 votes
# C, 11111111111111111111111111111111111 (35 ones)

```
main(c){while(c++<36)putchar(49);}

```

Maybe there's a shorter way. The lack of a simple way to print big numbers in C makes it tricky.

# Answer
> 7 votes
## Python 2, 107918163081

```
print 69**6

```

# Answer
> 7 votes
# CJam, score 10

```
A

```

Try it online!

# Answer
> 7 votes
# Java, 111111111111111111111111111111111111111111111111111111111111111111111111111111111 (81 ones)

```
interface A{static void main(String[]a){for(A i:new A[81])System.out.print(1);}}
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

```

I've underlined the part that is actually "variable" here; everything else is absolutely necessary for a working Java program.

Presumably this is shorter than mucking around with Java's `BigInteger`.

# Answer
> 7 votes
# Cubix, 100100

```
@'dOu

```

Cubix is a 2-dimensional, stack-based esolang. Cubix is different from other 2D langs in that the source code is wrapped around the outside of a cube.

Test it online!

## Explanation

The first thing the interpreter does is figure out the smallest cube that the code will fit onto. In this case, the edge-length is 1. Then the code is padded with no-ops `.` until all six sides are filled. Whitespace is removed before processing, so this code is identical to the above:

```
  @
' d O u
  .

```

Now the code is run. The IP (instruction pointer) starts out on the far left face, pointing east.

The first char the IP encounters is `'`, which pushes the next byte onto the stack; this byte is `d`, or `100`. Next is `O`, which outputs the top item (100) as an integer.

Then the IP hits `u`, which turns it to the right, moves it forward, then turns it again. It switches to the bottom face pointing north, then rotates to the east. This wraps it to the `O` again, outputting 100, then up to `@` which terminates the program.

# Answer
> 6 votes
# Jelly, score 120

```
5!

```

Calculates the factorial of 5. Try it online!

# Answer
> 6 votes
# MATL, 1000

```
1e3

```

*Note: latest GitHub commit of the compiler works on Octave as well as on Matlab.*

This interprets the number in scientific notation, and implicitly prints it, thus producing the output

> 1000

# Answer
> 6 votes
# Perl, 1000000000

```
print 1e9

```

Straightforward.

# Answer
> 6 votes
## C++, 1e46

```
#include <stdio.h>
main(){printf("1%046d",0);}

```

Newline would require an additional 2 bytes, using format "1%048d\n"

# Answer
> 5 votes
# O, 10

```
A

```

Apparently the score is the number we print!

# Answer
> 5 votes
# 05AB1E, score 10

Code

```
T

```

Explanation:

```
T         # Puts 10 onto the stack
          # Implicit, print the last item of the stack

```

# Answer
> 5 votes
## Mathematica, score 87,178,291,200

```
Print[14!]

```

This solution is not helped by the fact that it takes 6 characters to print anything.

# Answer
> 5 votes
## Brian & Chuck, 11,111,111,111,111 (≈ 1.1e13)

```
?1<SO>{?
#{>.>-?

```

Here, `<SO>` stands for the "shift out" control character with character code 0x0E.

Try it online.

That's all my language covered then. :)

### Explanation

The `1` in Brian's code (first line) is used for printing. Then `<SO>` is used as a counter variable. The rest is just a simple loop setup which prints that `1` while decrementing the `<SO>` down to zero.

# Answer
> 5 votes
# Marbelous, 100000000000000000000000 (24 digits)

Previously ~~28~~, ~~26~~ digits

```
@1
-- 10 '0
=0 @1
!! \\ /\ '1

```

All the spaces are superfluous. Outputs 1 then 0 repeatedly while counting down in parallel. Layout and counter tweaked to produce the desired amount of output for a 23-byte program.

# Answer
> 5 votes
# TeaScript, 10 points

```
e

```

The `e` variable is preinitialized to 10

Try it online

# Answer
> 5 votes
# Ruby, 1679616

```
p 6**8

```

Computes 68.

# Answer
> 5 votes
## QBasic, 15625

```
?5^6

```

`?` auto-magically gets converted to `PRINT`, 5 to the power of 6 yields the most convenient number of more than 4 bytes.

# Answer
> 5 votes
# Java, 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 (~1082)

Curent version:

```
interface N{static void main(String[]a){for(int i=0;i<46;)System.out.print(++i);}}

```

Previous version \[score floor(1084/9)=111111111111111111111111111111111111111111111111111111111111111111111111111111111111\]:

```
interface N{static void main(String[]a){for(int i=0;i<84;i++)System.out.print(1);}}

```

Original version (score 1093):

```
interface N{static void main(String[]a){System.out.print(java.math.BigInteger.TEN.pow(93));}}

```

# Answer
> 5 votes
## \>\<\>, 10560

```
'*n`

```

Try it online!

```
'*n`'         Push chars to stack, giving [42 110 96]
     *        Multiply, giving [42 10560]
      n       Output 10560 as number
       `      Unrecognised char, so the program outputs with an error

```

Unfortunately, out of all chars smaller than ``` which give a 5-digit output, none of `[\]^_` work since they are valid instructions which don't cause the termination we require.

# Answer
> 5 votes
## Labyrinth, 1001101

```
>1!:
@

```

As Martin predicted, one order of magnitude lower is possible! Try it online!

I'm not going to go into full details as to how Labyrinth works, but this trace should give a rough idea as to what's going on anyway:

```
Inst   Detail                                    Stack            Output
---------------------------------------------------------------------------------
>      Rotate row 0 right                        []

[Board update]
:>1!
@

1      * 10 + 1                                  [1]
!      Output                                    []               1
1      * 10 + 1                                  [1]
>      Rotate row 1 right                        []

[Board update]
:>1!
 @

:      Dup                                       [0 0]
>      Rotate row 0 right                        [0]

[Board update]
!:>1
 @

1      * 10 + 1                                  [1]
>      Rotate row 1 right                        []

[Board update]
!:>1
  @

:      Dup                                       [0 0]
!      Output                                    [0]              0
:      Dup                                       [0 0]
>      Rotate row 0 right                        [0]

[Board update]
1!:>
  @

:      Dup                                       [0 0]
!      Output                                    [0]              0
1      * 10 + 1                                  [1]
!      Output                                    []               1
:      Dup                                       [0 0]
>      Rotate row 0 right                        [0]

[Board update]
>1!:
  @

1      * 10 + 1                                  [1]
!      Output                                    []               1
:      Dup                                       [0 0]
!      Output                                    [0]              0
1      * 10 + 1                                  [1]
>      Rotate row 1 right                        []

[Board update]
>1!:
   @

1      * 10 + 1                                  [1]
!      Output                                    []               1
:      Dup                                       [0 0]
@      Halt

```

# Answer
> 5 votes
# Come Here, floor(10<sup>42</sup>/9)

```
0CALL42cCOME FROM SGNcCALLc-1c1TELL49NEXT

```

Ungolfed:

```
0 NOTE It is illegal to "COME FROM" a nonexistant label.
CALL 42 c NOTE c=42
COME FROM SGN c NOTE If c>0, come back here after next reaching label 1
CALL c-1 c NOTE decrement c
1 TELL 49 NEXT NOTE I really don't understand why the parser requires NEXT here, but it does

```

# Answer
> 5 votes
# NTFJ, 111111111111111111111111111111 (30 ones)

Code:

```
#(#~~~#@::::::)$::::*****(~#^

```

## Explanation

One the first run through we push six 49s (ASCII value for one) to set up for the loop this only runs the first time because `#` is used to enter the loop. On all subsequent runs the `#` is skipped and thus the loop is skipped as well.

After that as well as with all future runs we pop a value `$` which for the first run is a 49 but for all subsequent runs is the zero used to skip the loop. We then duplicate the TOS four times and output five times decreasing the total by one. If the TOS is zero (i.e. not 49) we end the program otherwise we jump back to the first instruction immediately skipping to back to four duplications.

This outputs 30 ones and has a length of 29.

## Additional solution

I thought since Conor O'Brien forgot about the `:` operator I'd do a solution without it to be fair to him.

```
#(##################~)~##~~~#@*~~##~~~~@*~~##~~~~@*$(~#^

```

This prints

```
100100100100100100100100100100100100100100100100100100100

```

I was going to make an explanation for this but I forgot how it works.

# Answer
> 4 votes
# GolfScript, 3125

```
5.?

```

Computes 5<sup>5</sup>.

# Answer
> 4 votes
# Python 2, 1,000,000,000

Even lower than my other answer (but includes a trailing zero, which I did not count towards the score). Similar to the Matlab/Octave solution.

```
print 1e9

```

# Answer
> 4 votes
### Windows PowerShell, 1000

```
1e3

```

Another methods to achieve something similar, though not as small, may be

```
1KB   # 1024

```

# Answer
> 4 votes
# Excel & LibreOffice Calc – 10000

```
=1e4

```

Save as `challenge.csv`, then open in Excel or Calc. Usually just double-clicking will do.

# Answer
> 4 votes
# C, 327228837632722883924195568 (28 digits)

```
main(){printf("%u%u%u");}

```

Undefined behavior is awesome!!! This solution probably doesn't count due to UB, but I just wanted to put the idea out there.

Using Coliru, I get that output every time.

# Answer
> 4 votes
# Vim, 11111

```
5i1␛

```

Works by inserting the character `1` five times. Try it online!

# Answer
> 4 votes
# Flurry, score 1

```

```

The empty program returns the identity function `λa. a` = `λab. a b`, which is the Church numeral representation of 1. The interpreter recognizes and prints it as such:

```
$ ./Flurry -nin -c ''
1

```

It takes the interpreter \\$O(n)\\$ time to convert from integer to decimal in order to print it, so any other answer would probably need to use character IO if it wanted to execute in reasonable time.

# Answer
> 4 votes
# GNU sed, 100010001000100010001000 (~1e23)

Without any basic math support, just text manipulation, the easiest solution I found was to duplicate some starting number, 1000 in this case. Printing is implicit at the end of the script, 22 bytes in length.

```
s:$:1000:
s:.*:&&&&&&:

```

Try it online!

I believe this is the first sed answer to this question. It's also my first after a long break from code golf :)

# Answer
> 3 votes
# Befunge 98 - 10000000000:

```
a8k:8k*.@

```

or:

```
a8k:8k*.q

```

The number printed has twelve didgits and the program is eleven bytes long.

# Answer
> 3 votes
# Microscript/Microscript II, 100

```
2E

```

# Answer
> 3 votes
# Haskell, 1001129150390625

```
main=print$75^8

```

Probably minimal. I can't think of a shorter way to make a large integer and print it than exponentiation (`^`); you need at least `main=print$`. Of all choices for base and exponent, `75^8` was the lowest number longer than the code.

EDIT: Thanks, Neil!

# Answer
> 3 votes
# C++, 111111111111111111111111111111111111111111111111111111111111 (60 ones)

```
#include<cstdio>
int main(int c){while(c++<61)putchar(49);}

```

Translation of my C answer.

# Answer
> 3 votes
## Java, 10^72

```
interface A{static void main(String[]a){System.out.printf("1%072d",0);}}

```

# Answer
> 3 votes
# Befunge (quirkster implementation), 123648

```
"**.@

```

Pushes the string `**.@` onto the stack, wraps around, exits string mode, and executes it, multiplying the ASCII values of the last three characters and outputting the result as an integer.

Edit: Only works if the playfield width is considered to be implicitly set to the maximum line width, not right-padded to a default size. Thanks to James Holderness for the catch.

# Answer
> 3 votes
# R - 134217728

```
cat(8^9)

```

I doubt it can be make any shorter having to use `cat` function. Pretty boring, though.

Edit: Improved thanks to Christian Sievers

# Answer
> 3 votes
# Charcoal, 11111111

```
Ｆ⁸1

```

Try it online!

`for(8)Print('1')`.

Charcoal could have done better (1111 score) if source was measured in Charcoal bytes.

# Answer
> 3 votes
# Lost, score 111111111111111111111111111111111111 (~~39~~ 36 ones)

```
/<<<<<%<@<<<?<<</
?+-*66<:<+1$<*77/

```

-111100000000000000000000000000000000000 score (-4 ones) thanks to *@JoKing*.

Try it online or verify that it's deterministic.

### Explanation:

**Explanation of the language in general:**

Lost is a 2D path-walking language. Most 2D path-walking languages start at the top-left position and travel towards the right by default. Lost is unique however, in that ***both the start position AND starting direction it travels in is completely random***. So making the program deterministic, meaning it will have the same output regardless of where it starts or travels, can be quite tricky.

A Lost program of 2 rows and 5 characters per row can have 40 possible program flows. It can start on any one of the 10 characters in the program, and it can start traveling up/north, down/south, left/west, or right/east.

In Lost you therefore want to lead everything to a starting position, so it'll follow the designed path you want it to. In addition, you'll usually have to clean the stack when it starts somewhere in the middle.

**Explanation of the program:**

`?` will pop the top item of the stack, and will skip the next character if it is NOT a 0. Because of this, the stack will be emptied completely due to the leading characters of both lines while traveling downwards. So the `?` pops values, and we'll ignore the `/`, until the stack is empty. At this point, an implicitly pushed 0 is used for the `?`, and the `/` is no longer skipped.

Another important fact is that in a Lost program, an `@` will terminate the program, but only when the safety is 'off'. When the program starts, the safety is always 'on' by default, otherwise a program flow starting at the exit character `@` would immediately terminate without doing anything. The `%` will turn this safety 'off', so when we now encounter an `@` the program will terminate (if the safety is still 'on', the `@` will be a no-op instead).

As for the program flow: all arrows and `/` reflects will lead the path towards the `<` between the `%` and `@`.

From there, the program flow will:

* `<`: Travel left/west
* `%`: Turn the safety 'off' (so if we would now encounter the `@`, the program will stop)
* `<<<<<`: Continue traveling left/west
* `/`: Reflect to a downwards/south direction
* `?`: Pop the top value of the stack, and if it's NOT 0, skip the next operand. As mentioned earlier, this `?/` will clean the entire stack in case we started somewhere in between, after which an implicit pushed `0` will allow us to go to the next step:
* `/` (first row; first column): Reflect to a left/west direction
* `/` (first row; last column): Reflect to a downwards/south direction
* `/` (second row; last column): Reflect to a left/west direction
    + `77*`: Push 49 (push 7; push 7; pop and multiply the top two values)
    + `<`: Continue traveling left/west
    + `$`: Swap the top two values. If the stack only contains a single value, it will implicitly use a `0` to swap.
    + `1+`: Add one to this counter-value
    + `<`: Continue traveling left/west
    + `:`: Duplicate the top of the stack
    + `<`: And once again, continue traveling left/west
    + `66*`: Push 36 (push 6; push 6; pop and multiply the top two values)
    + `-+`: Subtract it from the duplicated counter-value
    + `?`: Pop, and if this is NOT 0, skip the next operand. The first iteration this will be `-36`, thus NOT 0, so it will skip the `/` when it wraps around to the other side and do the same again starting at `77*`. This will continue until the counter-value has become `0`, after which the mirror `/` is not skipped.
* `/` (second row; last column): In that case, it will reflect downwards/south
* `/` (first row; last column): Reflect to a left/west direction again
* `<<<`: Continue traveling left/west
* `?`: Pop the top value on the stack (the duplicated counter-value)
* `<<<`: Continue traveling left/west
* `@`: Terminate the program if the safety is 'off' (which it is at this point). After which all the values on the stack will be output implicitly. Using the `-A` program argument flag, these code-points (the `49`s) will be output as a string of characters (`'1'`s) instead without delimiter. Without this flag, it would output the `49`s as numbers with space delimiters; so due to those implicit space delimiters, we can't simply push `1`s and remove the `-A` flag.

# Answer
> 3 votes
# Pip, 1 byte

```
t

```

Outputs `10`.

Try It Online!

# Answer
> 2 votes
# AppleScript, 10^3

```
1e3
```

Implicit output? :o

# Answer
> 2 votes
# gs2, 10

A single byte of CP437. Prints `10`. Try it here!

# Answer
> 2 votes
# Mouse-2002, 10101010

`k` is 10, but `!` printing costs a byte, so this is the only way.

```
kkkk(!)

```

Exits with an error, if run interactively.

# Answer
> 2 votes
# Befunge-93, 101010101010

```
6<_@#:-1.+4

```

I can't immediately think of anything shorter, but I think this is pretty good.

**EDIT**: got it from 161616161616 to 101010101010.

# Answer
> 2 votes
# Commodore Basic, 1000000

```
1?1E6

```

# Answer
> 2 votes
## Mathematica, score 120

```
5!

```

Contrary to the assertion in this answer, you don't need `Print` to print something in Mathematica. Mathematical operations like exponentiation and factorials are supported by default.

# Answer
> 2 votes
# F#, 10000000000000000000

Here's a pretty clever trick:

```
printf"%o"(1L<<<57)

```

# Answer
> 2 votes
## Pure bash, 1125899906842624 (2<sup>50</sup>, 16 digits).

```
echo $((1<<50))

```

This is the best *pure* bash I've come up with, not depending on any special conditions or using external commands.

**Bash + POSIX, 100000000: (10<sup>8</sup>, 9 digits)**

```
bc<<<A^8   # bc with a here-string script that evaluates 10^8

```

Thanks to Digital Trauma's answer for bringing up `bc` and the fact that it accepts hex digits even with the default ibase=10. Glenn beat me to actually posting the `bc`-based answer, but I'll leave it in my answer as well for completeness.

---

I'm an infrequent golfer, so IDK if there are standard assumptions that rule this out, to avoid needing overly pedantic rules in every question:

## Bash + rule-bending: 10737418240 (5 * 2<sup>31</sup>, 11 digits)

The question doesn't appear to rule out the the long number being be part of a longer string (e.g. part of an error message):

```
$((5<<31))          # prints "bash: 10737418240: command not found"

```

---

### Bash assuming a 5-digit PID: a 10-digit number (PID repeated twice)

```
echo $$$$       # depends on the shell's current PID being a 5-digit number

```

Or repeating 3 times to still work with a 4-digit PID: a 12 or 15 digit number. (e.g. 573057305730: The shell's PID repeated 3 times).

```
echo $$$$$$     # depends on the shell's current PID being a 4-digit number

```

---

### test framework for the number-generating expression:

```
e='$((5<<31))'; eval decimal=$e;  echo "$decimal: srclen=${#e}  digits=${#decimal}"

```

test framework for whole commands (works with methods other than the error-message hack.)

```
e='bc<<<A^8'; eval decimal=\"\$\($e\)\";  echo "$decimal: srclen=${#e}  digits=${#decimal}"

```

up-arrow and edit `e` to try different numbers.

---

Ideas that didn't work: (for readability, not fully golfed and in a `(subshell)` to avoid breaking your interactive shell when testing.)

```
(set {1..9}; IFS=; echo "$*" )   # $* in double quotes joins with no separator if IFS is null.  Too much setup overhead

```

You could play silly tricks to get `$0` to contain a long number, but then you'd have to count the whole `bash -c 'echo $0' $((10**7))` as part of the program.

# Answer
> 2 votes
## Self-modifying Brainf\***, 111,000,000,000,000 (1.11e14)

`_` represents a null byte `\x00`. Prints each digit 3 times. I'm also fairly certain this is minimal. Interleaving digits with code is longer. There are several shorter solutions where the number is of *equal* length, but not longer.

```
<[...<]_00001

```

# Answer
> 2 votes
# PowerShell, 111111

```
"1"*6

```

If the newline counts, then `"1"*5` prints `11111\n`.

# Answer
> 2 votes
# \>\<\> (fish), 1000010000

```
a:*:*:nn;

```

explaination:

duplicates and multiplies 10 to get to two 10000's then prints both, being ten total characters long, one more than the program character length

# Answer
> 2 votes
# marioLANG, 700666666005555550044444400333333002222220011111100 (51 digits for 49 bytes)

still no marioLANG anwser? well here's one,

**Try it online**

```
+
+
+
+
+
+!::::::<
+#======"
:>)::(-[!
="======#

```

# Answer
> 2 votes
# Google Sheets, 15625

```
=5^6

```

equals 15625

# Answer
> 2 votes
## Python 2, 1000000000

A simple program in a simple language. I have two answers depending on wether the python shell is permitted or not.

If it isn't, then:

```
print 1e9

```

Which is 9 bytes and outputs `1000000000`, 10 bytes.

If it is, then:

```
1e3

```

Which is 3 bytes and outputs `1000`, 4 bytes.

These ignore the `.0` printed on the end of these numbers since the method returns a float and the question asks for an int.

# Answer
> 2 votes
# C, 1844674407370955161518446744073709551615 (40 digits)

```
main(){printf("%lu%1$lu",-1ul);}

```

Certainly not winning, but it's a fun challenge and this is a fun answer.

How it works:

* The `printf` format specifier `%lu` prints a `long unsigned` integer.
* The `printf` format specifier `%1$lu` prints the first `long unsigned` integer in `printf`'s argument list.
* `-1ul` in `printf`'s argument list is `-1` cast to an `unsigned long`. Since the value is negative and the integer is unsigned, it turns into the maximum value an `unsigned long` can hold.

# Answer
> 2 votes
## Whitespace, 11111111111111111111111111111111111111 (38 ones)

Visible representation:

```
SSTTSSTTSNNSSNSSSTNSNSTNSTTSSSSNSNTTN

```

What it does:

```
     push -38
loop:
     push 1
      dup
       pnum
      add
     dup
      jn loop

```

Surprisingly short for a whitespace program. Other considered approaches were pushing a big integer followed by a sequence of duplicate-multiply but this proved to be less efficient.

# Answer
> 2 votes
# Cubically, score ~~836,308,545~~ ~~328,426,785~~ ~~45,454,545~~ 1,818

<sup>Knocked the score down by utilizing existing face values instead of wasting space messing with the notepad. Too bad I golfed it before the revision history kicked in :(</sup>

```
%22

```

Try it online! Explanation:

* Functions are called strangely in Cubically. When the interpreter hits a function, it sets the internal "default function" to that function. Then, when it hits any integer, it calls the internal default function with that integer. So `R1` will call `R` with `1`, `R11` will call `R` with `1` twice, etc.
* `%22` prints the value of the front face (`18`) two times.

*Outdated:*

Fun fact! Due to how functions are called in Cubically, for each extra byte (`6` at the end) we add, we can multiply the output length. Example:

```
:5*6666%66

```

Prints `836308545836308545`. `:5*6666%666` prints `836308545836308545836308545`. Etc.

# Answer
> 2 votes
# Z80Golf, 123334567 (8 bytes)

```
00000000: 3cf6 30fe 3820 0176                      <.0.8 .v

```

Try it online!

Disassembly:

```
  inc a
  or '0'
  cmp '8'
  jr nz, ok
  halt
ok:

```

Runs as follows:

* A is incremented, then `or`'d by `'0'`, giving `'1'`.
* This is not `'8'`, so we jump past the `halt`.
* Code runs through many NOPs into putchar (`$8000`). **We print '1'.** Then we effectively `ret`urn: The PC is set to `(SP)` which is `$f63c`, the first word in memory (i.e. the first word of our code) – *we never pushed anything, so we're stack-underflowing into our own code, interpreting it as 16-bit addresses*. SP is incremented by 2, now `$0002`.
* PC runs through NOPs from `$f63c` to `$0000`, the start of our code. A is incremented to `'2'`.
* We jump past the `halt` again and run into `$8000`. **We print '2',** then jump to `$fe30` and SP is now `$0004`. We run from there into `$0000`, the start of our code again.
* We similarly **print '3'**, but the next return address we pop is `$2038`, which means the PC reaches `$8000` again before it reaches our code; so we **print '3'** again, then returning to `$7601` and thus **printing '3'** a third time; before finally returning to `$0000` where execution continues as normal. Now SP is `$000a`.
* Nothing is weird past here: the return address will always be `$0000` since `SP` is now pointing *after* our code. We count up **printing '4', '5', '6', '7'** until finally A = '8' and we `halt`.

# Answer
> 2 votes
# Z80Golf, ~~111111111 (8 bytes)~~ 11111111 (7 bytes)

```
00000000: 3676 6636 3b3e 31                        6vf6;>1

```

Try it online!

### Disassembly

```
start:
  ld (hl), $76 ; 36 76 ; overwrite the 1st byte of program to `halt`
  ld h, (hl)   ; 66    ; h = $76; hl = $7600
  ld (hl), $3b ; 36 3b ; write `dec sp` to memory $7600
  ld a, $31    ; 3e 31 ; a = '1'

```

The main point is what happens after the program runs through the code. Every time before reaching `putchar`, the PC hits `dec sp` at `$7600`. This means each run of `putchar` increases SP by 1 instead of 2. So the return addresses become the following:

```
$7600 -> $7676 -> $3666 -> $3b36 -> $3e3b -> $313e -> $0031 -> $0000

```

Note that, when the return address is `$7676`, `dec sp` is skipped. So the ASCII 1 is printed 8 times in total.

---

## Previous solution, 111111111 (8 bytes)

```
00000000: 3e31 0609 ff10 fd76                      >1.....v

```

Try it online!

### Disassembly

```
start:
  ld a,$31  ; 3e 31 ; a = '1'
  ld b,9    ; 06 09 ; b = 9
loop:
  rst $38   ; ff    ; equivalent to "call $8000" or "call putchar"
  djnz loop ; 10 fd ; b -= 1; if (b) goto loop
  halt      ; 76

```

Arguably less clever than Lynn's solution but still an improvement. This uses the instruction `djnz` which is similar to `dec b` then `jr nz, label`, but one byte shorter. If `b` is not touched before the loop, `b` starts with zero and the loop runs exactly 256 times.

# Answer
> 2 votes
# Alchemist, 11109876543210

```
a->Out_a!12a

```

Try it online!

Down from ~1e18 to ~1e14 thanks to @Jo King

# Answer
> 2 votes
# Vyxal, 1 byte

Try it Online!

literal 10.

# Answer
> 2 votes
# BitCycle (-u), 3.134e144

```
1v>v>v>v>v>v>v>v>v
AB~>~>~>~>~>~>~>~ v~
  >^>^>^>^>^>^>^>v>+
^                ~^!1BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB@

```

Try it online!
See it online!
*The TiO has been truncated so that you can spend more time with your grandkids*
This program multiplies the amount of bits entering by 256, then converts them to `1`'s and adds it to the output. Each time this happens, a bit moves 1 space through the line of `B`'s. Once the bit reaches the `@`, the program terminates. The output can be expressed as: \\$\sum\_{n=1}^{60}256^n\\$

# BitCycle, 1.111~~e29~~ e26

```
~~ v
 ^~
AB~
~0<~BBB@
!

```

Try it online!
See it online!
This is a similar concept to the first one, but it outputs in binary. Specifically, 27 `1`'s

# BitCycle, 2.417e24

```
~~ v
 ^~
AB~
~0<~BBBB@
!

```

Try it online!
See it online!
The best of both worlds! This outputs a binary string of 81 `1`'s, which, in decimal, is \\${{2}^{81}}-{1}\\$

# Answer
> 2 votes
# Shakespeare Programming Language, ~~8.16e153~~ 1.25e146

7 digits removed thanks to Robin Ryder.

```
,.Ajax,.Puck,.Act I:.Scene I:.[Exeunt][Enter Ajax and Puck]Puck:If notyou cat.Open
heart.You be twice you.Be twice you nicer I?If solet usact I.

```

Try it online!

Output:

```
124816326412825651210242048409681921638432768655361310722621445242881048576209715241943048388608167772163355443267108864134217728268435456536870912

```

Doubles the integer in a loop until it overflows the 32 bit signed integer type.

# Answer
> 2 votes
# Pascal, \\$1 \\! \cdot \\! 10^{43}\\$ or 1

See also Free Pascal. This is a *complete* `program` according to ISO standard 10206 “Extended Pascal”, though. `Write(1E43:1:0)` prints (or ought to print) the value `10000000000000000000000000000000000000000000`. The `:1` specifies the *minimum* width the output shall occupy. The `:0` disables scientific notation and prints exactly `0` digits after the decimal point. Since it doesn’t make sense to print the decimal point `.` if no digits follow, it also omits the `.` itself. This behavior is an Extended Pascal extension (in ISO standard 7185 only *positive* `integer` values are accepted as format specifiers).

```
program p(output);begin write(1E43:1:0)end.

```

Note the characteristics of the built-in data type `real` are **implementation-defined**. `Write` in conjunction with `real` (such as `1E43`) always produces *rounded* output with respect to the last printed digit(s). For instance, using *an* implementation of Pascal that internally uses IEEE 754 floating point numbers (depending on the precision) you may observe rounding errors. This, however, is a circumstance *outside* of the realm of the programming language. Sample:

```
9999999999999999999740000000000000000000000

```

*Mathematically* speaking the smallest positive integer value we can print in Pascal which has a longer printed length than the corresponding source code is \\$1\\$ (**positive one**).

```
program p(output);begin write(1.0:42)end.

```

This will print (the casing of the letter `E` may vary):

```
 1.00000000000000000000000000000000000E+00

```

This is *a* representation of the value 1. The value 1 is in the domain of ℤ, the set of integers.

# Answer
> 1 votes
# Candy, 10

```
N

```

push the number 10 onto the stack. 10 is useful since it's ascii for \n

Candy dumps the stack on exit.

# Answer
> 1 votes
## Bash, 100000000 (9 digits)

```
bc<<<A^8

```

Solution by @Digital Trauma ported to bash.

# Answer
> 1 votes
## ResPlicate, score 111111111

```
2 9 0 49

```

I was thinking of all kinds of complicated ways to do this, but it turns out the solution is very simple. After one step, you get:

```
0 49 0 49 0 49 0 49 0 49 0 49 0 49 0 49 0 49

```

which is just 9 commands to print ASCII number 49, so "111111111" is output.

# Answer
> 1 votes
## C, score ~10^26 (100000000000000004764729344)

```
main(){printf("%f",1E26);}

```

Apparently float failes there a little. Tested there.

# Answer
> 1 votes
# beeswax, ~~909090~~ 823543

The new solution just computes `7^7`, which is `85547` smaller than the old solution.

```
_7FB{

```

Explanation:

```
_       [0,0,0]•       create bee
 7      [0,0,7]•       push 7 on lstack
  F     [7,7,7]•       set all stack values to 1st value
   B    [7,7,823573]•  1st=1st^2nd
    {                  output lstack 1st to STDOUT

```

# Answer
> 1 votes
# BotEngine, floor(10<sup>65</sup>/9)

```
v
e1
ldddddd<
ldddddd<
ldddddd<
ldddddd<
ldddddd<
>ddddP

```

This is probably the largest number of `d` instructions I've ever used in a single BotEngine program.

# Answer
> 1 votes
# x86 MS-DOS .COM file, score 111,111,111,111

Hex dump of the 11 byte .COM file (to reverse the hex dump, pass it into `xxd -r -seek -256`):

```
0100: b4 02 b2 31 b1 0c cd 21 e2 fc c3                   ...1...!...

```

Unassembled using `debug`:

```
0100 B402     MOV AH,02         ; prepare to print character to stdout
0102 B231     MOV DL,31         ; ASCII '1' to be printed
0104 B10C     MOV CL.0C         ; counter=12
0106 CD21     INT 21            ; print
0108 E2FC     LOOP 0106         ; repeat until counter is 0
010A C3       RET               ; end

```

# Answer
> 1 votes
# Binary-Encoded Golfical, floor(10<sup>14</sup>/9)

Hexdump of binary encoding:

```
00 90 01 00 31 18 18 18 18 18 18 18 1D

```

Original image:

Magnified 80x, with color labels:

Explanation: Stores 49 (the code point of the digit `1`), prints it as a character 7 times, then turns around and prints it seven more times before terminating.

# Answer
> 1 votes
# ForceLang, 10<sup>13</sup>

```
io.write 1e13

```

# Answer
> 1 votes
# Reng v.3.3, score 104976

Try it here!

```
I²²n~

```

Prints

```
104976

```

This squares `I` (18) twice, yielding 104976. `n` prints this, and `~` terminates.

# Reng v.2.2, score 101010101010

<pre><code>{An}``````~
</code></pre>

## Previously, score 96549157373046880

```
Z{ZZ**}#xxxxxxn~

```

Prints `96549157373046880`.

# Answer
> 1 votes
# Cy, score 134217728

```
8 9 ^ :<

```

`8 9` pushes a 9 and an 8 to the stack (duh), `^` computes `8 ^ 9` (exponent, not xor), `:<` prints it.

This was not intended to be a golfing language, but this answer ended up pretty short compared to "real" languages. I didn't even need exponential notation!

# Answer
> 1 votes
## AWK, 1e21

I didn't see an `AWK` answer, so here's mine.

Since a 'full program' was requested, this is the best I could come up with (full program is a bit fuzzy in `AWK`).

```
awk '{$0=1e21}1'<<<1

```

If we don't consider how the program is called as part of the program, then the score could be dropped to about 1e13 using:

```
 '{$0=1e13}1'

```

# Answer
> 1 votes
# Python 3, 100000000000

One digit shorter than the current python 3

```
print(1e11)

```

prints 1\*(10^11)

# Answer
> 1 votes
# Jelly, score 100

```
³

```

Prints `100` when counting as 2 bytes in UTF-8.

Try it Online!

# Answer
> 1 votes
# Carrot, 11111

```
1^*4

1     //"1" is pushed into the stack
 ^    //The stack is finished
  *   //Multiply or duplicate string operator (in this case it is the latter)
   4  //Duplicate the string 5 times (4+1)

```

`"1"` is pushed into the stack. Then the `*` operator duplicates the string `5` times, not `4` times because the `*` operator on strings always duplicates the strings `1` time more than what is stated, because duplicating it once is meaningless and hence it is removed. So the program outputs `11111`.

# Answer
> 1 votes
## PHP, 9223372036854775807

I know they're not the shortest for PHP but..

### 9223372036854775807

```
<?=PHP_INT_MAX;

```

### 10000000000000000000

```
<?=str_pad(1,20,0);

```

# Answer
> 1 votes
# , 16031, language postdates challenge

```
1603

```

Try it online!

It's unclear what "must be encoded in ASCII or UTF-8" means in 7. The most obvious meaning is that I have to write each command as a single character, and encode its name in ASCII (this is particularly suitable here, because that's an input encoding that the 7 interpreter understands). In this case, the best I can do is 16031 (the first character here is a literal that's never executed, thus could be any octal digit; `0603` outputs 06031, but leading zeroes are disallowed, so the best digit we can use here is 1).

## Explanation

A 7 program is basically a sequence of literals that are pushed to the stack, unescaping them in the process; thus the "initial run" of the program is always fairly boring and just puts things on the stack. Then the rightmost stack element is executed (while leaving it on the stack), repeatedly until the program exits.

Although all the commands that can occur in literals have names, some of the commands that can appear as the result of unescaping don't. The usual convention I use for this on PPCG is to bold "active" commands (which do something interesting when executed), and leave "passive" commands (which just push an active command) unboldened. The four active commands that don't have names are then given the same name as the corresponding passive command, and thus I rely on the font to distinguish. 7's "stack" is a little strange, relying on separators `|` between elements (which are manipulated as though they were a character in the language).

```
||           1**6**03    Initial stack and program; **6** is active, 103 are passive
|1**03**                 Result after the program's initial run
|1**03**         1**03**     (implicit) Top stack element is copied to the program
|1**031**        **03**      1 appends **1** to the stack
**7**1**6**031       **3**       **0** escapes the top stack element and removes the | before it
                     **3** prints output, and exits if the stack is low

```

The output in this case is `**7**1**6**031`. The first step in producing output is to check to see if it needs escaping (the algorithm for this is fairly complex, but typically boils down to making active commands passive, and enclosing passive sections in **`7`****`6`**). In most of my 7 programs, it does (due to containing anonymous commands), but all the commands seen there have names (unsurprisingly, because we escaped it manually on the previous line), so no escaping is necessary. Next, the first character output in the entire program (here, **`7`**) specifies the output format (7 means "the same as the input", so the output will be printed as a sequence of octal digits in ASCII). Finally, the remaining characters, `16031`, will be printed directly (shown here without the bold because one they're printed, they aren't commands any more, just characters).

Interestingly, the victory condition is different from a , and that actually mattered. It's possible to write a smaller program that produces numerical output longer than itself: `1**6**3` outputs `71631` (basically because it doesn't escape explicitly, and implicit escaping by the **`3`** command always prepends a 7 to the output). However, in this case, although the program is shorter, the output is larger, so using a longer program gave a smaller score.

# Answer
> 1 votes
# Common Lisp (GCL), 1586013445029888

```
(princ(exp 35))

```

# Answer
> 1 votes
# Brachylog (2), 11111, language postdates challenge

```
1j₅w

```

Try it online!

Just makes five copies of `1` and prints them.

# Answer
> 1 votes
## Check, score 1000010000

```
>10000pp

```

# Answer
> 1 votes
# Pyke, 1 byte

```
T

```

Try it here!

In Pyke, as well as in Pyth, `T` is a constant pre-initialised to `10`.

# Answer
> 1 votes
# Brain-Flak, 106735757048926755512911448358783973263883108352

48 digits, 46 bytes.

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

```

Try it online! (but not really because it will error with a segment fault).

This uses the common triangular method, `({{}[()]})`, but applies it recursively on the previous result. It starts with 6 as both the counter and the total and starts the loop, first decrementing the counter, then replacing the total with `2*triangle(total)`. Repeat a few times and it gets exponential, with each repetition roughly doubling the amount of digits.

Python code used to calculate the total:

```
def tri(t):
    return (t)*(t-1)/2

def f(n,t):
    for _ in range(n):
        t = tri(t)*2
    return t

print(len(str(int(f(6,6)))))

```

Try it online!

# Answer
> 1 votes
# PHP, 10000000

10 million (8 digits) printed in 7 bytes:

```
<?=1e7;

```

Almost 2.5 years and I am the first to think of that? Amazing.

# Answer
> 1 votes
# Perl 6, 10000000

```
1e7.say

```

Try it online!

I can't see any Perl6 solutions, so for completeness...

# Answer
> 1 votes
# Attache, 8 bytes

```
8^9|Echo

```

Try it online!

Outputs `134217728`.

# Answer
> 1 votes
## Keg `-hr`, 10

```

```

Try it online!

## Explanation

```
\n  # Push the newline character onto the stack (Ord code 10)

-hr # Print the item raw (i.e. as a number)

```

## Keg, 100

```
d.

```

Pushes d and prints as integer. Fortunately 100 is a letter in the Keg code page.

Output is `100`.

Other solution just for fun and has a larger amplitude(also 2 bytes):

```
ā

```

Output is `257` TIO

# Answer
> 1 votes
# Shakespeare Programming Language, ~1.23e186

Prints `1234…95969798`, the concatenation of all integers from 1 to 98.

```
,.Ajax,.Page,.Act I:.Scene I:.[Exeunt][Enter Ajax and Page]Page:You is the sum ofyou a cat.Open heart.Is you worse twice the square ofthe sum ofa big big big cat a pig?If soLet usAct I.

```

Try it online!

After many iterations, here is a version without any spare characters. The code is 186 characters, and the output is 187 characters.

# Answer
> 1 votes
# Intcode, 100000000000000000000000000000000

```
2,7,7,7,4,7,99,10000000000000000

```

This is almost certainly sub-optimal, given all it does is square the number given at the end.

# Answer
> 1 votes
# naz, ~~100,000,000~~ 11,111

```
1a5o

```

**Explanation**

```
1a5o # Output "1" five times

```

I slightly misunderstood the question at first — here's my original 8-byte solution:

```
1a1o1s8o

```

# Answer
> 1 votes
# Burlesque, 1000 or 1111111

```
1e3
1cy7.+

```

Try it online!

First the boring method just printing 1000, or making an infinite number of 1s and clipping it to the length of the code+1.

# Answer
> 1 votes
# Python - 52^7, 12 bytes

```
print(52**7)

```

Edit 1: (Rip 11-ception)

After (embarrassingly) miscounting bytes, I'm back with the smaller version that turned out to be necessary. 52^7 is 1,028,071,702,528, which (at my count) is 13 bytes, and 13\>12. Of course, if you could write things straight to STDOUT, you could get away with 5\**6 or 15,625.

# Answer
> 1 votes
# Pxem, 1000010000.

* Filename: `10000.e.p` (9 bytes)
* Content: empty (0 bytes)
    + Total: 9 bytes

Try it online!

# Answer
> 1 votes
# Bitcoin Cash Script (BitAuth IDE), 18 bytes

```
// Golfed
0x0340420f76769595
// The number 1000000000000000000 will be on top of stack

// Ungolfed
OP_DROP // clean up
<1000000> OP_DUP OP_DUP OP_MUL OP_MUL
// The number 1000000000000000000 will be on top of stack

```

Opcodes reference

Try it online!

# Answer
> 1 votes
# Knight (v2), score 117649

```
O^7 6

```

Outputs \\${7}^{6}=117649\\$

Try it online!

# Answer
> 1 votes
# Go, 111111111111111111111111111111111111111111111111111111, 53 bytes

```
package main
func main(){for i:=1;i<55;i++{print(1)}}

```

Attempt This Online!

Prints to STDERR.

# Answer
> 1 votes
# GolfScript, 1010

```
10.

```

Try it online!

Same length as Lynn's but gives a smaller number by pushing two copies of 10 and (implicitly) printing them side-by-side.

Some fun alternatives include `n).` and `n(.`, which extract the charcode of newline from the string `"\n"` to get 10 (leaving an empty string at the bottom)

# Answer
> 1 votes
# C (gcc), \>1E25, 25 bytes

```
main(){printf("1%025u");}

```

Try it online!

Not determined, not sure if any env make it const result

# Answer
> 1 votes
# Pyt, 100

```
2ᴇ
2             (push 2 onto the stack)
 ᴇ            (raise 10 to the 2nd power)
              (implicitly print)

```

Try it online!

# Answer
> 1 votes
# Itr, score 120

`5P`

online interpreter

computes 5 factorial (120)

---

# ~~Itr, score 0~~

The empty program in Itr prints `0` which has a length longer than the source code but is not positive.

# Answer
> 1 votes
# Nibbles, score 1

```
/

```

Attempt This Online!

The Nibbles program "`/`" is 1 nibble or 0.5 bytes long, and outputs the value `1`.

```
/       # full program
/$$     # with implicit args added
/       # divide
 $      # the input (which is assigned with
        # a value of 100 if no input given)
  $     # by the input (also assigned to 100)

```

# Answer
> 1 votes
# Uiua, score 1073741824 100000

*-1073641824 points from noodle man*

```
&p1e5

```

Try it online!

### Explanation

```
&p1e5
  1e5   # Push 1e5 to the stack
&p      # Print with newline

```

# Answer
> 1 votes
# Awk, 1000000

```
$0=1e6

```

Must be fed a newline.

# Answer
> 0 votes
# Python 3, 1028071702528

```
print(52**7)

```

One byte longer than Python 2, but the same approach.

EDIT: turns out my search wasn't exhaustive enough -- thanks, Neil.

# Answer
> 0 votes
# Mumps, score 100000

```
W 1e5

```

Writes 10^5, or 100000. Had the newline not been optional, that would have added 2 more characters to the program:

```
W 1e7,!  ; this would output 10000000

```

Now that I mention it... it would be interesting to see how much would change on some of the winning answers if an explicit newline was required - especially the 0 or 1 byte answers. :-)

# Answer
> 0 votes
# Python 2, 111,111,111,111

Lower than the other python answers

```
print'1'*12

```

# Answer
> 0 votes
## MSM, 10101010

```
.;.;.01

```

7 byes for an 8 byte output. Repeatedly duplicates and concatenenates starting with `10`.

# Answer
> 0 votes
# Visual Basic .NET, 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111 (86 ones)

```
Module A
Sub Main
System.Console.Write(New System.String("1"C,86))
End Sub
End Module

```

Oh dear. (This is shorter than using a loop, unless there's some fast way to do that that I don't know about.)

# Answer
> 0 votes
## k4, 10000

```
$ cat a.k; echo
_1e4
$ wc -c a.k
4 a.k
$ q a.k </dev/null
10000
$

```

The input file is missing its trailing newline, but that doesn't matter to the interpreter. The language's default behavior on reading code files is to print the output of any statement which is not explicitly suppressed, so all I have to do is create the number. Exponential notation creates floats though, so I have to floor it to create an integer, otherwise the output would be `10000f` (the default representation of a float that has no fractional part).

# Answer
> 0 votes
## dc, 117649

```
$ cat a.dc; echo
7 6^p
$ wc -c a.dc
5 a.dc
$ dc -f a.dc
117649
$

```

Inspired by WGroleau's comment on the question.

# Answer
> 0 votes
## Fortran 77, 36 ones

```
^Iwrite(*,'(36i1)'),(1,i=1,36)
^Iend

(where ^I represents the TAB character.  This is the first Fortran
program I've written or have even seen that uses TABs)

```

## FORTRAN IV, 54 ones

```
      PRINT1,(1,I=1,54)
    1 FORMAT(54I1)
      END

```

Both solutions write a newline after the number. Note that if you're using a line printer to look at the output, the first "1" will be interpreted as a page-feed and the numbers in the programs will need to be increased by 1, to 37 for Fortran 77 and to 55 for Fortran IV.

# Answer
> 0 votes
# Insomnia, 129

```
i

```

Apart from `i` (105), `r` (115) or `}` (125) outputs the same result, since the position of the bit pointer doesn't matter when it's the last state-changing operation.

# Answer
> 0 votes
## C, 1407260946921681491238744 (25 digits)

24 characters:

```
main(){printf("%lu%u");}

```

The output is nondeterministic (which may disqualify this submission). After a few million runs, I've only gotten 25 digit output. Some day I should figure out what GCC is (setting up a.out to be) sprinkling past the end of the stack for `printf()` to use here.

# Answer
> 0 votes
## Ceylon, 111111111111111111111111111111111111111111 (42 digits)

This was my second try:

```
shared void run(){print("1".repeat(42));}

```

A program with length 41, prints a string of 42 ones.

---

My first, more complicated try printed 112589990684262411529215046068469761152921504606846976 (54 digits):

<pre><code>shared void run(){print("``2^50````2^60````2^60``");}
</code></pre>

This program has a length of 53 bytes.

Ceylon integers go just up to right under 2^63, which gives us only 19 digits. Due to the boilerplate here we need to concatenate three of them, which is done by the use of string templates (the contents of ``` ... ``` inside a string literal are evaluated as an expression and then converted into a string). Then it was simply a point of looking up the powers of two with (relatively) smallest first digits (2^50 starts with 1125, 2^60 with 1152), such that the length of them sums to 54. I guess combining other powers might make the program slightly shorter, but this still will not beat the simple one above.

# Answer
> 0 votes
# PHP, score 10,000,000,000

```
echo 1e10;

```

Assuming the opening/closing tags don't count, otherwise it's

```
<?=echo 1e13;

```

And if we allow non-PHP, we have `<?=1e7` and `1e3` as options. Taking the first answer as the "most correct" of the four.

# Answer
> 0 votes
# Pylons, 10

```
B

```

How it works:

```
B # Push B to the stack. (pre-initialized to 10)
  # The stack is implicitly printed at the end of the program.

```

# Answer
> 0 votes
# PHP, 100 ones, 23 chars

```
<?=str_repeat("1",1E2);

```

# Answer
> 0 votes
# Mathcad, 3 "bytes", 4 digits, 5040

Updated version. See text of Original version for suppression of decimal places discussion. As the original version, used one integer raised to power of another, I've also included what I think is the smallest number that meets the criterion.

---

**Original (and wrong!) Version ...**

*Here's two Mathcad expressions (you may regard the "3" version as even more cheaty than the 8 version, hence my providing the two versions ...)*

Mathcad doesn't have a "text" file as such. It operates more as a 2D whiteboard, where you can either type characters and operators onto a "worksheet", or enter them via a single-click toolbar. Mathcad stores the worksheet as an xml file. From a user perspective, however, typing "cat" counts as 3 distinct characters, which I'm taking to be the equivalent of "bytes" for the purposes of golfing; pi is single character as well. An operator, such as "=" (evaluate), "+" (add) or ":=" (define), also counts as a "byte".

There are also a number of settings, such as the number of decimal places shown displaying a real number, which are available from a dialog box. If, for example, setting the number of decimals to zero counts as a 0 "byte" operation, then π= is the shortest one I can think of. If this is regarded as cheating from a golfing perspective, then the exponent version should meet the spirit of the competition.

# Answer
> 0 votes
# Oracle SQL 11.2, 30903154382632612361920641803529

```
SELECT''||POWER(9,33)FROM DUAL;

```

# Answer
> 0 votes
# Desmos, 6561

```
9^4

```

equals 6561

### previous answer, 1048576

```
2^{20}

```

equals 1048576

# Answer
> 0 votes
# Forth, 1073741824 (2^30)

```
1 30 << .

```

**Try it online**

If the result could be left on the stack:

### 100663296

```
96 20 <<

```

# Answer
> 0 votes
# Turtlèd, 100000000000

```
11:[*'0l]'1

```

`11`\- set register to 11

`:` move right by amount in register

`[*'0l]` loop: `[* ]`\- while current cell is not `*`, `'0`\- write zero to cell, `l` -move left

`'1`\- write one

# Answer
> 0 votes
# ///, score 111111111111

```
/./111/....

```

Try it online!

`/./111/` removes itself and replaces every `.` with `111`, so `....` becomes `111111111111`.

# Answer
> 0 votes
# DUP, 100100

```
'd$..

```

Put character d on stack, duplicate it, print its value twice.

Online DUP interpreter.

My Julia implementation on GitHub, with comprehensive language description.

# Answer
> 0 votes
# tcl, 10000000000000000

```
puts [expr 1e16]

```

Outputs:

```
10000000000000000.0

```

The integer part is 1 and 16 zeros.

http://rextester.com/RWNL80143

# Answer
> 0 votes
# SmileBASIC, ~~16713480~~ ~~1111111~~ 10000

```
?1E4

```

Boring.

Previous Answers: `?-#CYAN`, `?"1"*7`

# Answer
> 0 votes
## Underload, score 100000100000

```
(100000):*S

```

# Answer
> 0 votes
# Syms, ~~999980001~~ 1111111 (noncompeting)

```
1:7;*>

```

Try it online!

# Answer
> 0 votes
## Alice, 3628800 (10!)

```
a/P
o@

```

Try it online!

### Explanation

```
a   Push 10.
/   Reflect to SE. Switch to Ordinal.
    Reflect off bottom right corner, move back NW.
/   Reflect to W. Switch to Cardinal.
a   Push 10.
    Wrap around to the end of the first line.
P   Compute 10! = 3628800.
/   Reflect to NW. Switch to Ordinal.
    Immediately reflect off top boundary, move SW.
o   Implicitly convert the result to a string and print it.
    Reflect off bottom left corner, move back NE.
/   Reflect to S. Switch to Cardinal.
@   Terminate the program.

```

# Answer
> 0 votes
# Braingolf, 20

Oh hey look I can golf it now thanks to niladic stuff

```
+

```

Niladic `+` (ie run when the stack is empty) pushes 20 to the stack, implicit output.

# Braingolf, 100

Just throwing in my 2 cents (or 2 bytes, as it were)

```
#d

```

Pushes the charcode of the character 'd' to the stack, which is 100. Braingolf will automatically print the last element of the stack when the code terminates if there is no semicolon present in the code.

### Note:

As with every Braingolf submission thus-far on PPCG, this is non-competing, as the language was created on 3rd May 2017.

# Answer
> 0 votes
# S.I.L.O.S, 28 byte, 111111111111111111111111111111 (29 ones)

```
x=29
lbla
print 1
x-1
if x a

```

Ugh! Looping is expensive!

Try it online!

# Answer
> 0 votes
# Yabasic/QBasic/VBA, 10000 4 bytes

Takes no input and outputs `10000`to the console.

```
?1E4

```

Try it online!

# Answer
> 0 votes
# Java, 1e66

Shortest *full program* I could make:

```
interface A{static void main(String[]a){System.out.print(1e66);}}

```

With 65 bytes, this program outputs:

```
1e66

```

Try it online!

# Answer
> 0 votes
# Röda, score 10,000,000,000,000 (10<sup>13</sup>)

```
main{[10^13]}

```

Try it online!

# Röda statement, score 1,000,000 (10<sup>6</sup>)

```
[10^6]

```

The program is executed using this command (the flags are required to execute the program, so they are free):

```
röda -e "[10^6]" -n

```

# Answer
> 0 votes
# Prolog(SWI), 1e+15

```
?-write(1e15).

```

Outputs (surprise surprise) `1.0e+15`

Try it online!

# Answer
> 0 votes
# Implicit, score 65

```
A

```

Pushes the ASCII value for `A` (65). Implicit output.

# Answer
> 0 votes
# Commodore 64/VIC 20 BASIC, 5 PETSCII characters (excluding the carriage return)

```
 0?1E5

```

Some caveats here; firstly, Commodore BASIC adds in a white space before printing any number or numeric variable; secondly, there is no concept of true integer types in Commodore BASIC (I think that applies to all variants through to BASIC 7 on the Commodore 128); and finally `LIST`ing the program will show its un-obfuscate form, and add in a white space after each line number, so the above symbolic listing becomes:

```
0 PRINT1E5

```

So, on that basis, it could be that this is automatically disqualified if these caveats are taken into account. Does my initial *golfed* version count as a valid entry?

# Answer
> 0 votes
# Momema, score 10000000001000000000

```
01000000000-8*0-8*0

```

## Explanation:

```
0  1000000000  #  [0] = 1000000000
-8 *0          #  print num [0]
-8 *0          #  print num [0]

```

# Answer
> 0 votes
# Canvas, 10

Try it here!

pushes 10 to the stack, then Canvas inplicitly prints the item at the top of the stack.

# Answer
> 0 votes
# Pascal (FPC), ~~10^52~~ 1111111111111111111111111111111111111111111111 (~1.1e46)

```
var i:word;begin for i:=1to 46do write(1)end.

```

Try it online!

Obvious one, I missed it somehow at first, thinking it would be bigger number.

---

Previous approach - 10^52 (10000000000000000000000000000000000000000000000000000)

```
uses sysutils;begin write(1,Format('%.52D',[0]))end.

```

Try it online!

`Format` is a function in `sysutils` which gives a string from specified formatting string and array of arguments. Formatting string works pretty much like in C: `%` starts the part which will be replaced, `D` means integer in decimal format, `.52` for `D` means the number will be written with at least 52 digits; since `0` has less than 52 digits, it is left-padded with zeroes. `1` is written before it to make a valid integer.

# Answer
> 0 votes
# Rust, 10²⁸ 10000000000000000000000000000 (28 bytes)

```
fn main(){print!("{}",1e28)}

```

Try it online!

# Answer
> 0 votes
# Runic Enchantments, 1000

```
aC@

```

Try it online!

Huh, another classic I apparently never answered.

Because the number must be strictly *longer* than the program (so a 3 byte program requires a 4 digit number), this is as small as we can go (but there are two ways to do it).

# Answer
> 0 votes
# Wren, 1e+24

Verbosity killed the wren. Calulates 10^24.

```
System.write(10.pow(24))

```

Try it online!

# Answer
> 0 votes
# T-SQL, 100,000,000,000

```
SELECT 1e11

```

Note that the shorter `PRINT 1e10` doesn't seem to work in this case; in the SQL versions I tested (2012 to 2017) it keeps the output in the exponential format (`1e+010`), which I assume isn't allowed.

# Answer
> 0 votes
## , 100

```
2^

```

Explanation

```
 ^ % 10 to the power of ...
2  % ... 2

```

# Answer
> 0 votes
# Python 2, 137438953472 (2^37)

```
print 2**37

```

Code is 11 bytes long, output is 12 bytes long.

# Answer
> 0 votes
# x86-16, IBM PC DOS, 111,111,111

```
B8 0A31     MOV  AX, 0A31H  ; AH = 0AH (write chars * CL), AL = '1'
B1 09       MOV  CL, 9      ; display 9 times
CD 10       INT  10H        ; call BIOS
C3          RET             ; return to DOS

```

This is based on @krubo's answer above, but 3 bytes shorter. This uses the PC BIOS's `INT 10`,`0AH` function for output since it will repeat the same char `CL` number of times, saving the need for a `LOOP` (-2 bytes). Also, `AL` and `AH` can be initialized at the same time (-1 byte).

# Answer
> 0 votes
# Fortran (GFortran), 24 ones

```
print*,("1",i=1,23)
end

```

Try it online!

Better Fortran score by avoiding formats entirely.

# Answer
> 0 votes
# cQuents, ~~362880~~ ~~161280~~ 100100

```
#2;J4

```

Try it online!

J4 defults to base 2, and evaluates to 100 as a string. '100'+'100' = '100100'.

# Answer
> 0 votes
# MAWP 1.0, 76543210

```
8[1A!:].

```

As suggested by Jo King.

Try it!

# MAWP 1.0, 152587890625

```
5!W!W!W!W:.

```

Try it!

# Answer
> 0 votes
# RGBDS macros, 11,111,111,111,111,111,111,111

```
REPT 23
 PRINTI 1
ENDR

```

# Answer
> 0 votes
# BitCycle, ~~100000000100000000~~ 100000000000000

```
A\10v
~000~!

```

Try it online!

This program is 12 bytes long and outputs a 15 byte number. It starts with 5 bits, discarding one and printing a copy of the bits each iteration.

BitCycle actually outputs in bits (ones and zeroes), which can be interpreted as a decimal number as above. It is normally interpreted in unary with the `-u` flag.

# BitCycle `-u`, 60328467484514692442875165185

```
AB/00v  ~DDDDD@
~111 ~CD^
!

```

Try it online!

Honestly, not that much longer, but this takes a huge amount of time to execute. The code at 27 bytes, with the number at 29 digits long, which was the shortest of this format that I could find. Essentially, this repeatedly does the sum of 1 to n (as in the triangular numbers) on the same value, starting at `5`, which increases exponentially. Then it outputs the sum of all these numbers

# Answer
> 0 votes
# Rec, 111111111111

~~The space before `49` is required, otherwise the character will not display properly.~~ Well, it seems like it's a Python formatting issue.

```
12[0:^\49p]

```

Try it online!

# Answer
> 0 votes
# ForWhile, score 1111111

`7[49#)`

prints `1` 7 times

online interpeter

# ForWhile, score 76543210

`8(47+#)`

online interpreter

For loop printing decreasing characters for `8+47` (ascii `'7'`) downwards to `1+47` (ascii \`'0')

# Answer
> 0 votes
# Kotlin, score 123456789101112131415161718192021222324

```
fun main()=(1..24).forEach{print(it)}

```

probably could be improved but not sure how

# Answer
> 0 votes
# Perl 5, 10000000

```
say 1e7

```

Try it online!

# Answer
> 0 votes
## HP‑41C series, 1

This submissions presumes there are no other programs in program memory. We merely need to increase the number of displayed digits *before* placing the number on top of the stack. The default setting is to display and round to (up to) 4 places after the radix mark (`FIX 4`).

```
01♦LBL⸆T           5 Bytes    global label requires 4 + (length of string) Bytes
02 FIX 9           2 Bytes    display 9 digits after radix point
   NULL            1 Byte     invisible Null byte before numbers
02 1               1 Byte     push 1 on top of the stack (X ≔ 1)

```

shows, if flag 29 is set (the default),

```
 1.000000000

```

or, if flag 29 is cleared,

```
 1,000000000

```

If you want to *print* the number with an HP 82143A Printer, append a `VIEW X` command (2 Bytes) or shift the printer’s mode switch to the `TRACE` position (which will, however, print all the other commands, too).

---
Tags: number, code-challenge, optimization, self-referential
---


title: Sugar Free Syntax

text:
# Question
Title: Sugar Free Syntax
In Haskell the list notation:

```
[a,b,c]

```

Is just syntactic sugar for:

```
a:b:c:[]

```

And the string notation:

```
"abc"

```

Is just syntactic sugar for:

```
['a','b','c']

```

This means that the string:

```
"abc"

```

Is the same as:

```
'a':'b':'c':[]

```

# Task

Given a string you should output what the de-syntaxed version would look like in Haskell.

# Rules

* You will receive a string by any valid input method, you should output a string ending with `:[]` with every character from the input surrounded by `'` and separated by `:`. The empty string should output `[]`.
* You can assume that you will not receive any characters that require escaping (e.g. `'`, newlines, tabs ...) and that input will be in the printable ascii range
* This is you should aim to minimize the byte count of your answer

## Test Cases

```
"" -> []
"a" -> 'a':[]
"Hello, World" -> 'H':'e':'l':'l':'o':',':' ':'W':'o':'r':'l':'d':[]

```

# Answer
> 89 votes
# Haskell, 26 bytes

```
(++"[]").((++":").show=<<)

```

Try it online!

**Explanation:**

In non-pointfree notation and using `concatMap` instead of `=<<`, this becomes

```
f s = concatMap(\c-> show c ++ ":")s ++ "[]"

```

Given a string `s`, we map each char `c` to a string `"'c':"` using the `show` function which returns a string representation of most Haskell types. Those strings are concatenated and a final `[]` is appended.

Although not requested by the challenge, this answer even works with proper escaping, because `show` takes care of it: `f "'"` yields `"'\\'':[]"`.

# Answer
> 46 votes
## Haskell, ~~33~~ ~~28~~ 26 bytes

```
foldr((.(':':)).shows)"[]"

```

Try it online!

`fold` the given pointfree function from the right into the input string starting with `[]`. The function is: show char as a Haskell char, i.e. surrounded with `'` and concatenate with the result so far after putting a `:` in front of it.

Edit: @Ørjan Johansen saved two bytes. Thanks!

# Answer
> 20 votes
# Python 3, 32 bytes

```
lambda s:"%r:"*len(s)%(*s,)+"[]"

```

Try it online!

# Answer
> 19 votes
## JavaScript ES6, ~~42~~ ~~40~~ 31 bytes

```
s=>s.replace(/./g,"'$&':")+"[]"

```

Replaces each char with `'<char>':`, then adds `[]` to the end

Try it online!

# Answer
> 17 votes
# Common Lisp, ~~50~~ 42 bytes

```
(format t"~{'~a':~}[]"(coerce(read)'list))

```

Try it online!

Reduced thanks to the comment of @coredump, by using `read` instead of defining a function.

# Answer
> 12 votes
# , 11 bytes

```
Í./'&':
A[]

```

Try it online!

Uses a regex to surround every input character with `'':` and then `A`ppends `[]` to the end.

# Answer
> 11 votes
# C, ~~55~~ ~~54~~ 53 bytes

```
s(char*h){while(*h)printf("'%c':",*h++);puts("[]");}

```

# Answer
> 9 votes
# 05AB1E, ~~15 12 11~~ 10 bytes

-3 bytes thanks to carusocomputing
-1 byte thanks to Adnan
-1 byte thanks to Erik the Outgolfer's genius idea

```
ʒ"'ÿ':"?},

```

Try it online!

```
ʒ          # Filter out every character that the following code doesn't return 1 for
 "'ÿ':"?   #   Print the string 'ÿ': with ÿ replaced by this character
        }  # End for
         , # No character returned 1 so an empty array is left on the stack. Print that

```

# Answer
> 9 votes
# Pyth, ~~14~~ ~~10~~ 8 bytes

```
j\:a`MQY

```

Try this!

*-2 bytes thanks to @isaacg*

Finally, pyth is good at something.

### explanation

```
j\:a`MQY
    `MQ        # map the representation over the input string: ["'a'","'b'",...]
   a   Y       # append the empty list
j\:            # join on :

```

# Answer
> 9 votes
# Python 3, ~~41~~ ~~38~~ 36 bytes

<sup>-2 bytes thanks to ovs</sup>

```
print(*map(repr,input()),[],sep=':')

```

Try it online!

# Answer
> 9 votes
# R, 51 bytes

```
f<-function(x)(paste0(gsub("(.)","'\\1':",x),'[]'))

```

# Answer
> 8 votes
# Retina, 12

* 3 bytes saved thanks to @FryAmTheEggman

```
.
'$&':
$
[]

```

2 stages:

* for each remaining character put `'` `':` around it
* add `[]` to the end

Try it online.

# Answer
> 7 votes
# Python 2, ~~48~~ ~~46~~ ~~44~~ 37 bytes

*-2 bytes thanks to Rod. -7 bytes thanks to Wheat Wizard.*

```
lambda s:':'.join(map(repr,s)+['[]'])

```

Try it online!

# Answer
> 7 votes
# Perl 6, 19 bytes

```
{S:g|.|'$/':|~'[]'}

```

# Answer
> 7 votes
# Jelly,  ~~11 10~~  8 bytes

-1 byte thanks to Christian (remove concatenation `;` and utilise implicit printing instead)

+0 bytes (fixed for edge case of an empty string - previously the full program: `ŒṘ€j”:“:[]`)

-2 thanks to Erik the Outgolfer (use `p` in place of `;€` since `”:` is effectively length 1; use `Ø[` since it has become shorthand for `⁾[]`)

```
ŒṘ€p”:Ø[

```

**Try it online!**

A full program printing the result (as a link it returns a list of lists of characters).

...but is there a way to save using STDIN?

### How?

```
ŒṘ€p”:Ø[ - Main link: list of characters, s  e.g. "Hey"
ŒṘ€      - Python representation for €ach    [["'",'H',"'"],["'",'e',"'"],["'",'y',"'"]]
    ”:   - literal character = ':'
   p     - Cartesian product                 [["'",'H',"'",':'],["'",'e',"'",':'],["'",'y',"'",':']]
         - implicit print (no newline): 'H':'e':'y':
      Ø[ - literal list of characters        ['[',']']
         - implicit print (no newline): []

```

# Answer
> 7 votes
# JavaScript (ES6), 36 bytes

```
s=>s?`'${[...s].join`':'`}':[]`:"[]"

```

---

## Try it

```
f=
s=>s?`'${[...s].join`':'`}':[]`:"[]"
oninput=_=>o.innerText=f(i.value);o.innerText=f(i.value="abc")
```

```
<input id=i><pre id=o>
```

# Answer
> 7 votes
# Befunge, ~~29~~ 27 bytes

```
<,,,,\_v#`0:~"'':"
@,,"[]"<

```

Try it online!

# Answer
> 5 votes
# Perl 5, 22 bytes

19 bytes of code + `-p` flag.

```
s/./'$&':/g;$\="[]"

```

Or, for the same bytecount, `s/./'$&':/g;s/$/[]/`.

Quite straight forward: `s/./'$&':/g` surrounds each characters with quotes and add a `:` after. `$\` is implicitly printed after each print, so setting it to `[]` outputs the final `[]`.

Try it online!

# Answer
> 4 votes
# PHP, 41 bytes

```
<?=preg_filter("#.#","'$0':",$argn)."[]";

```

Try it online!

# Answer
> 4 votes
# brainfuck, 68 bytes

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

```

Try it online!

# Answer
> 4 votes
# Java (OpenJDK 8), ~~86~~ ~~83~~ 76 bytes

*-3 bytes thanks to @KevinCruijssen*
*-7 bytes thanks to @FlorianSchaetz*

```
s->{String b="";for(char c:s.toCharArray()){b+="'"+c+"':";};return b+"[]";};

```

Try it online!

# Answer
> 3 votes
# Brain-Flak, ~~135~~, 131 bytes

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

```

Try it online!

`+1` byte for the `-c` flag.

Thanks to WheatWizard for removing very obvious NOOPs that I had for no reason XD.

# Answer
> 3 votes
# Cubix, ~~31~~ 29 bytes

```
uo@[)o'U);!A?ro;o;o;os:'/u:''

```

`A` can also be substituted for `i`; ~~trying to figure out if there's a good way to squeeze another byte or two out of this.~~ -2 bytes thanks to MickyT! Also outgolfed by MickyT!

Fits on a 3x3x3 cube:

```
      u o @
      [ ) o
      ' U )
; ! A ? r o ; o ; o ; o
s : ' / u : ' ' . . . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .

```

Watch it online!

Try it online!

# Answer
> 3 votes
# Standard ML, ~~52~~ 50 bytes

Saved 2 bytes thanks to @Laikoni!

```
fn s=>String.translate(fn c=>"'"^str c^"':")s^"[]"

```

Try it online!

`String.translate` is an unfortunately long name, but was 5 bytes shorter than using `concat`, `map`, and `explode`.

# Answer
> 2 votes
# Python 2, 47 bytes

```
lambda a:`list(a)+[[]]`.replace(', ',':')[1:-1]

```

Try it online!

# Answer
> 2 votes
# APL (Dyalog), ~~21~~ 19 bytes

```
'[]',⍨'.'⎕R'''&'':'

```

Try it online!

`'[]',⍨` the brackets appended to

`'.'` every character

`⎕R` PCRE **R**eplaced with

`'''&'':'` a quote, the match, a quote and a colon

# Answer
> 2 votes
# Japt, ~~14~~ 13 bytes

A port of Downgoat's JS solution.

```
ç"'$&':" +"[]

```

Try it

# Answer
> 2 votes
# sed, ~~19~~ 18 bytes

-1 byte thanks to Jordan

```
s/./'&':/g;s/$/[]/

```

Try it online!

# Answer
> 2 votes
# , ~~75~~ 50 bytes

```
function(x)cat(gsub("(.)","'\\1':",x),"[]",sep="")

```

Try it online!

Or for a non-regex approach:

# , 63 bytes

```
function(x)cat(sprintf("'%s':",el(strsplit(x,''))),'[]',sep='')

```

Try it online!

It turns out that `sprintf` will recycle the format string to match the length of its input, which is a nice golf from the previous answer (which you can see in the edit history).

# Answer
> 2 votes
# JavaScript 23 40 bytes

```
f=s=>!s?"[]":"'"+[...s].join("':'")+"':[]"

```

```
f=s=>!s?"[]":"'"+[...s].join("':'")+"':[]"
console.log(f() + "\n") // `"[]"`
console.log(f("") + "\n") // `"[]"`
console.log(f("abc") + "\n") // "'a':'b':'c':[]"
```

Using spread element to convert string to array, `Array.prototype.join()` to concatenate `":"` characters

# Answer
> 2 votes
# PHP, 39 bytes

```
<?while(~$c=$argn[$i++])echo"'$c':"?>[]

```

Run as pipe with `-F`.

# Answer
> 2 votes
# Convex, 10 bytes

```
{`':`}%"[]

```

Try it online!

# Answer
> 2 votes
# Cubix, 27 bytes

```
uosW?U.iv":'"^soso;os@o[]'/

```

Try it online!

```
      u o s
      W ? U
      . i v
" : ' " ^ s o s o ; o s
@ o [ ] ' / . . . . . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .

```

Watch it run

A slightly different variation from Guiseppe's answer. This puts the colon and quote on the stack. Then it loops through the input, swapping and outputting the stack. Only the input is scrapped and the colon and quote are retained.

Once the end of the input is reached the IP wonders around the cube a bit, adding and outputting the brackets. There are a couple of redundant commands in the mix.

# Answer
> 2 votes
# Ruby, 43 bytes

```
->a{a==''?'[]':"'#{a.chars.join"':'"}':[]"}

```

# Answer
> 2 votes
# Excel, 68 bytes

```
=IFERROR(CONCAT("'"&MID(A1,ROW(OFFSET(A1,,,LEN(A1))),1)&"':"),)&"[]"

```

Takes input from A1, outputs to whatever cell this formula is placed in. It's an array formula, so Ctrl-Shift-Enter instead of Enter to enter it.

11 of the bytes here are just for handling the empty string correctly, since Excel doesn't have a concept of arrays with zero elements.

The answer's pretty straightforward, but I did learn a couple things: IFERROR's second argument is taken to be `""` when left blank, and `&` will operate in an array-aware manner if and only if the construction is inside a function that will take an array (replacing `CONCAT(...)` with just `(...)` feels like it should work but it doesn't).

# Answer
> 2 votes
# MATL, 16 bytes

```
g39*Gyt19+v'[]'h

```

Try it online!

A bit surprised not to see a MATL submission already.

### Explanation:

```
	% implicit input, 'abc'
g	% convert to logical
	% STACK: {[1 1 1]}
39*	% multiply by 39, ASCII for ', elementwise.
	% STACK: {[39 39 39]}
G	% push input
	% STACK: {[39 39 39]; 'abc'}
yt	% copy from below and dup
	% STACK: {[39 39 39]; 'abc'; [39 39 39]; [39 39 39]}
19+	% add 19, elementwise, to get 58, ASCII for :
	% STACK: {[39 39 39]; 'abc'; [39 39 39]; [58 58 58]}
v	% vertically concatenate stack contents, implicitly converting to strings.
	% STACK: {'''
	%	  abc
	%	  '''
	%	  :::}
'[]'h	% push '[]' and horizontally concatenate, linearizing as needed
	% STACK: 'a':'b':'c':[]
	% implicit output

```

# Answer
> 2 votes
# Vyxal `o`, 12 bytes

```
ƛ\'p‛':+₴;k[

```

Try it Online!

```
ƛ        ;   # Map...
 \'p         # Prepend a '
    ‛':+     # Append a ':
        ₴    # Output without newline
          k[ # Push `[]`
             # Which is implicitly output

```

# Answer
> 2 votes
# Julia 1.0, 26 bytes

```
!x=join("'".*x.*"':")*"[]"

```

Try it online!

input is a list of characters

# Answer
> 1 votes
# SOGL, 12 bytes

```
,{ļ'pō':}ō[]

```

Explanation:

```
,{      }     iterate over the chars of string input
  ļ'          output "'"
    p         output the current char
     ō':      output "':"
         ō[]  output "[]"

```

In theory 10 byte `ļ'pō':}ō[]` could work, but, alas, it doesn't.

# Answer
> 1 votes
# Ruby, ~~43~~ 28 + 1 = ~~44~~ 29 bytes

*A whopping -15 bytes thanks to Value Ink.*

+1 byte for the `-p` flag.

```
$_=gsub(/(.)/,"'\\1':")+"[]"

```

Try it online!

# Answer
> 1 votes
# Aceto, 26 bytes

```
:Lpp&p
'p|L
\'!d["
'M@,]"p

```

# Answer
> 1 votes
## PowerShell, 43 bytes

It's a `join(map(repr, input))` shape problem? That's simply 177 bytes of:

```
[linq.enumerable]::Aggregate([Linq.Enumerable]::Select(
[Object[]][Char[]]"$args", [Func[Object,String]]{"'$args'"})+(,'[]'),
[func[object,object,object]]{param($a,$b) $a+':'+$b})

```

Edit: can golf that down to a mere 171:

```
$e='[Linq.Enumerable]::';$o='Object';
"${e}Aggregate(${e}Select([$o[]][Char[]]""$args"",[Func[$o,$O]]{""'`$args'""})+(,'[]'),[func[$o,$o,$o]]{`$args[0]+':'+`$args[1]})"|iex

```

Oh all right, 43 bytes of:

```
(([char[]]"$args"|%{"'$_'"})+,'[]')-join':'

```

# Answer
> 1 votes
## Swift, ~~49~~ bytes

```
{$0.characters.reduce("",{$0+"'\($1)':"})+"[]"}

```

This is a lambda (closure in Swift). Because converting a `Character` Array to a string is `a.joined(seperator:"")` I've used `.reduce("",+)` as a golf. Kind of unreadable so broken down:

```
{
  $0.characters.reduce("", {
    $0 + "'\($1)':"
  }) + "[]"
}

```

because a map + converting to a string is too long, `reduce` will convert to a string for us as we go

# Answer
> 1 votes
# \>\<\>, 27 bytes

```
i:0(?vd3*:o$oo':'o
o'[]'/;o

```

Try it online!

# Answer
> 1 votes
# Noether, 37 bytes

```
{I~sL0>}{sL("'"Psi/P"':"Pi1+~i)}"[]"P

```

**Try it here!**

Takes input between quotation marks.

# Answer
> 1 votes
# Excel VBA, 51 bytes

Anonymous VBE immedate function that takes input as string from cell `[A1]`, iterates across the input string, splitting it by character and then outputs to the VBE immediate window

```
For i=1To[Len(A1)]:?"'"Mid([A1],i,1)"':";:Next:?"[]

```

### Previous, Longer Versions

```
1:  a=Split(StrConv([A1],64),Chr(0)):For i=0To[Len(A1)-1]:?"'"a(i)"':";:Next:?"[]"

2:  ?"'"Mid(Join(Split(StrConv([A1],64),Chr(0)),"':'"),1,4*Len([A1])-1)"[]"

3:  ?"'"Left(Join(Split(StrConv([A1],64),Chr(0)),"':'"),4*Len([A1])-1)"[]"

4:  ?"'"Replace(Left(Strconv([A1],64),2*Len([A1])-1),Chr(0),"':'")":[]"

5:  ?Replace(Left("'"&StrConv([A1],64),2*Len([A1])),Chr(0),"':'")"':[]"

6:  ?"'"Left(Replace(StrConv([A1],64),Chr(0),"':'"),4*Len([A1])-1)"[]"

7:  ?"'"Replace(Replace(StrConv([A1],64),Chr(0),"':'")&" ","' ","[]")

8:  For i=1To Len([A1]):?"'"&Mid([A1],i,1);"':";:Next:?"[]"

9:  For i=1To[Len(A1)]:?"'"&Mid([A1],i,1);"':";:Next:?"[]"

10: For i=1To[Len(A1)]:?"'"Mid([A1],i,1)"':";:Next:?"[]"

```

# Answer
> 1 votes
# Mathematica, 34 bytes

```
"'"<>#<>"':"&/@Characters@#<>"[]"&

```

Anonymous function. Takes a string as input and returns a string as output. Just separates the input's characters, inserts `'...':` around each, and adds `[]` to the end.

# Answer
> 1 votes
# Charcoal, 11 bytes

```
ＦＳ⁺⁺'ι':¦[]

```

Try it online! Explanation provided as AST.

# Answer
> 1 votes
## Rust, 69 bytes

```
|s:&str|s.chars().map(|s|format!("'{}':",s)).collect::<String>()+"[]"

```

Couldn't find anything shorter than the trivial solution.

# Answer
> 1 votes
# Java, 60 bytes

```
String f(String s){return s.replaceAll(".","['$0']:")+"[]";}

```

# Answer
> 1 votes
# brainfuck, 48 bytes

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

```

Try it online!

# Answer
> 1 votes
# Stax, 10 bytes

```
╩8┼Φv╚▀╛┴►

```

Run and debug it

# Answer
> 1 votes
# Kotlin, 34 bytes

```
{it.fold(""){a,v->a+"'$v':"}+"[]"}

```

Try it online!

# Answer
> 1 votes
# Ahead, 25 bytes

```
v>"]["W@
>jri''r
^W"':"W<

```

Try it online!

# Answer
> 1 votes
## Burlesque - 21 bytes

```
m{bx"'~':"jf~}"[]"_+Q

```

Longer versions:

```
XX{bx"'~':"jf~}\m"[]"_+Q

```

Burlesque shows characters with a single `'` i.e. `'x` instead of `'x'` which is why we have to surround characters manually with two `'`s.

# Answer
> 1 votes
# Forth (gforth), 47 bytes

```
: f bounds ?do ." '"i 1 type ." ':"loop ." []";

```

Try it online!

### Code Explanation

```
: f          \ start a new word definition
  bounds     \ get the starting and ending addresses of the string
  ?do        \ loop from start to end (skip if start=end)
    ." '"    \ output '
    i 1 type \ print the character at the current address
    ." ':"   \ output ':
  loop       \ end loop
  ." []"     \ output []
;            \ end word definition

```

# Answer
> 1 votes
# Rust macro, 185 bytes

```
macro_rules!f{([])=>{['[',']']};([$c:expr]$($o:tt)*)=>{[$($o,)*'\'',$c,'\'',':','[',']']};([$c:expr$(,$r:tt)*]$($o:tt)*)=>{f!([$($r),*]$($o)*'\''$c'\''':')};($($r:tt)*)=>{f!([$($r)*])}}

```

Defines a macro that takes a comma-seperated sequence of character tokens and expands to an array of characters.

try it online

## Explanation

```
macro_rules! f {
    // the macro is a tt muncher where the inputs are in brackets with the
    // accumulator after that.

    // the base case for an empty array
    ([]) => {
        // expand to the brackets
        ['[', ']']
    };
    // the base case for a single element
    ([$c:expr] $($o:tt)*) => {
        [$($o,)* '\'', $c, '\'', ':', '[', ']']
    };
    // the recursive case
    // extract a characters from the input token stream
    ([$c:expr $(,$r:tt)*] $($o:tt)*) => {
        f!([$($r),*] $($o)* '\'' $c '\'' ':')
    };

    // entry point
    ($($r:tt)*) => {
        // call the recursive part by wrapping the arguments in brackets
        f!([$($r)*])
    }
}

```

# Answer
> 1 votes
# naz, 82 bytes

```
2a2x1v2m9m3a2x2v9a9a1a2x3v1x1f1r3x1v2e2x4v2v1o4v1o2v1o3v1o1f0x1x2f9m5m1a1o2a1o0x1f

```

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
2m9m3a2x2v                         # Set variable 2 equal to 39 ("'")
9a9a1a2x3v                         # Set variable 3 equal to 58 (":")
1x1f                               # Function 1
    1r                             # Read a byte of input
      3x1v2e                       # Jump to function 2 if it equals variable 1
            2x4v                   # Otherwise, store the byte in variable 4
                2v1o4v1o2v1o3v1o   # Output it, using variables 2 and 3 to format it as required
                                1f # Jump back to the start of function 1
1x2f                               # Function 2
    9m5m1a1o2a1o                   # Output "[]"
1f                                 # Call function 1

```

# Answer
> 1 votes
# Keg, 16 bytes

```
÷⑷\&⑨ⁿ:"\:⅍⅀⑸`[]

```

Try it online!

This is what you call "the result of me not implementing things properly".

# Answer
> 1 votes
# Erlang (escript), 52 bytes

Pretty simple solution.

```
f(X)->lists:join(":",[["'"|[I|"'"]]||I<-X]++["[]"]).

```

Try it online!

# Answer
> 1 votes
# Rockstar, ~~94~~ 69 bytes

```
listen to S
cut S
O's ""
while S
let O be+"'"+roll S+"':"

say O+"[]"

```

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

# Answer
> 1 votes
# Lua, 36 bytes

```
print((...):gsub(".","'%1':").."[]")

```

Try it online!

# Answer
> 1 votes
# Swift 5.9, 45 bytes

```
let f={($0+"").map{"'\($0)':"}.joined()+"[]"}

```

# Answer
> 0 votes
# Jelly, 13 bytes

```
”';Ð€;€⁾':⁾[]

```

Try it online!

Explanation:

```
”';Ð€;€⁾':⁾[]

”';Ð€            Concatenate ' to the beginning of each element
     ;€⁾':       Concatenate ': to the end of each element
          ⁾[]    Implicit concatenation of literal "[]"

```

# Answer
> 0 votes
## CJam, ~~13~~ 12 bytes

```
q{`':`}%"[]"

```

Explanation:

```
q    e# Input: "test"
{    e# For each character: ['t 'e 's 't]
  `  e#   Get the string representation: ["'t" "'e" "'s" "'t"]
  ': e#   Push the character ':': ["'t" ': "'e" ': "'s" ': "'t" ':]
  `  e#   Get the string representation: ["'t" "':" "'e" "':" "'s" "':" "'t" ':]
}%   e# End
"[]" e# Push the string "[]"
e# Implicit print: 't':'e':'s':'t':[]

```

# Answer
> 0 votes
# braingasm, 18 bytes

```
,[39.."':".,]"[]".

```

Just a simple loop, reading one byte at a time and printing the necessary stuff before and after the input, then the final square brackets.

Test run:

```
$ echo -n Hello | braingasm haskell_strings.bg
'H':'e':'l':'l':'o':[]

```

# Answer
> 0 votes
# QBIC, 35 bytes

```
[_l;||X=X+@'`+_sA,a,1|+B+@:`]?X+@[]

```

## Explanation

```
[    |         FOR a = 1 TO
 _l |           the length of
   ;              input string
X=X+@'`        Add to Z$ a literal '
   +_sA,a,1|   and a 1-char substring at index a of the input A$
   +B          and another quote (defining it as literal created B$)
   +@:`        and a literal :
]              NEXT
?X+@[]         PRINT Z$ and a literal [] (no closing backtick because EOF)

```

# Answer
> 0 votes
# Octave, 37 bytes

```
@(s)(s&&printf("'%c':",s))+puts("[]")

```

Try it online!

# Answer
> 0 votes
# Braingolf, 29 bytes

```
VRl1-M[R>#'<"':">>>>v]R"[]"&@

```

Try it online!

Currently a bug in Braingolf foreach loops that breaks them when handling 2 adjacent duplicates (such as the `l`s in `Hello`), so I have to use this method that costs me an extra 13 bytes

If foreach loops worked properly, it would've been this, which is only 16 bytes:

```
{>#'<"':"}"[]"&@

```

## Explanation

```
VRl1-M[R>#'<"':">>>>v]R"[]"&@  Implicit input from commandline args
VRl1-M                         Create stack2, push length of stack1 - 1 to stack2
      [..............]         Do-While loop, will run for each item on stack1
       R>                      Return to stack2, move ToS to bottom
         #'<                   Push single quote and move BoS back to top
            "':"               Push single quote and colon
                >>>>           Rotate stack to next item from input
                    v          Switch to stack2 for loop counting
                      R"[]"&@  Switch to stack1, push [] and print entire stack

```

# Answer
> 0 votes
# Groovy, 37 bytes

```
{it.replaceAll(~/./,{"'$it':"})+"[]"}

```

(It's an anonymous closure, which can be called thus `{...}("hello")` or via a name thus `f = {...};f("hello")`.)

# Answer
> 0 votes
# Python 3, 36 bytes

```
lambda s:':'.join(map(repr,[*s,[]]))

```

A variation of Rod's one.

Try it online!

# Answer
> 0 votes
# setlx, 36 bytes

```
s|->join(["'"+x+"':":x in s],"")+"[]";

```

### Explanation:

```
s |->                               // a function taking an argument s
    join(                           // join:
        [ "'" + x + "':" : x in s], // a list from each char wrapped in quotes
        ""                          // with the empty string
    )
    + []                            // add an empty list to the string, this will convert it to the string "[]"
;

```

# Answer
> 0 votes
# Clojure, 42 bytes

```
#(str(apply str(for[c %](str"'"c"':")))[])

```

# Answer
> 0 votes
## Javascript 33 bytes

```
f=s=>s.replace(/(.)/g,"'$1':")+'[]'

```

# Answer
> 0 votes
## \>\<\>, 25 bytes

```
i:0(?v":''"o{ooo
o"[]"<;o

```

Try it online!

# Answer
> 0 votes
# Actually, 9 bytes

```
♂è[]@q':j

```

Try it online!

Explanation:

```
♂è[]@q':j
           implicit input ("abc")
♂è         push a list containing the string representation of each character (['a', 'b', 'c'])
  []@q     add an empty list to the end of that list (['a', 'b', 'c', [])
      ':j  join with colons ("'a':'b':'c':[]")
           implicit print ('a':'b':'c':[])

```

# Answer
> 0 votes
# Pari/GP, 52 bytes

```
s->c=concat;c(c([Str("'",x,"':")|x<-Vec(s)],["[]"]))

```

Try it online!

# Answer
> 0 votes
# SNOBOL4 (CSNOBOL4), 81 bytes

```
	N =INPUT
S	N LEN(1) . X REM . N	:F(O)
	O =O "'" X "':"	:(S)
O	OUTPUT =O "[]"
END

```

Try it online!

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

```
D,f,@*,39@39 58
L^~,€{f}"[]"BF

```

Try it online!

## How it works

```
D,f,@*,		; Create a function, 'f', that
		; that takes one argument, and returns the full stack
		; Example argument:	['a']
	39@	; Prepend 39;	STACK = [39 'a']
	39 58	; Push 39, 58;	STACK = [39 'a' 39 58]
		; Return the full stack
		; 39 is the ordinal of ' and 58 of :

L^~,		; Create a lambda function
		; The ^ converts all integers to characters, then concatenates, when returning
		; The ~ unpacks the argument beforehand
		; Example argument:		['a' 'b' 'c']
	€{f}	; Run 'f' over each;	STACK = [[39 'a' 39 58] [39 'b' 39 58] [39 'c' 39 58]]
	"[]"	; Push '[]';		STACK = [[39 'a' 39 58] [39 'b' 39 58] [39 'c' 39 58] '[]']
	BF	; Flatten;		STACK = [39 'a' 39 58 39 'b' 39 58 39 'c' 39 58 '[]']
		; The ^ flag converts integers to characters:
		;			STACK = ["'" 'a' "'" ':' "'" 'b' "'" ':' "'" 'c' "'" ':' '[]']
		; Then concatenates them into a single string:
		;			STACK = ["'a':'b':'c':[]"]
		; And returns the top value:
		;			Return "'a':'b':'c':[]"

```

# Answer
> 0 votes
# SmileBASIC 3, 53 48 bytes

-5 with the `WHILE` trick, thanks 12Me21!

```
LINPUT S$WHILE""<S$?"'"+SHIFT(S$)+"':";
WEND?"[]

```

Explainer:

```
LINPUT S$              'Read line from console
WHILE ""<S$            'WHILE S$ is not empty
 ?"'"+SHIFT(S$)+"':";  'Print 'x': where x is popped off the front of S$
WEND                   'End WHILE
?"[]"                  'Print []

```

# Answer
> 0 votes
# Husk, 9 bytes

```
J':`:søms

```

Try it online!

### Explanation

```
J':`:søms  Implicit input                                 "abc"
       ms  String representation of each character        ["'a'","'b'","'c'"]
   `:sø    Append the string of an empty list to the end  ["'a'","'b'","'c'","[]"]
J':        Join with a colon character                    "'a':'b':'c':[]"

```

# Answer
> 0 votes
# F#, 55 bytes

My first F#, which means it probably isn't very good. <sub>My SmileBASIC answer is beating it, even...</sub>

```
fun s->List.reduce(+)[for c in s->sprintf"'%c':"c]+"[]"

```

Try it online. Golfing tips are appreciated

# Answer
> 0 votes
# Pip, 15 bytes

```
aJ':JW''AL":[]"

```

Try it online!

## Explanation

```
aJ':JW''AL":[]" a → input                     Example → "Hi"
aJ':            join characters with ':'              → 'H:i"
    JW''        join and wrap that with single quotes → "'H':'i'"
        AL":[]" Append list ":[]"                     → "'H':'i':[]"
                Concatenation has high precedence, so AL is used.

```

# Answer
> 0 votes
# Vyxal `P`, 75 bits<sup>v1</sup>, 9.375 bytes

```
\'vø.¾SJ\:j

```

Try it Online!

I'm not going to sugarcoat it - you can press `c` to golf your answers

## Explained

```
\'vø.¾SJ\:j
\'vø.       # Surround each character with "'"
     ¾SJ    # append the string "[]" to that (the global array is initially empty, and the P flag stringify lists as square brackets instead of angle brackets)
        \:j # join on ":" and output

```

# Answer
> 0 votes
# Thunno 2, 13 bytes

```
ʋ':'j''ṛʋ:[]+

```

Attempt This Online!

#### Explanation

```
ʋ':'j''ṛʋ:[]+  # Implicit input
ʋ':'j          # Join the input by the string "':'"
     ''ṛ       # Surround this string by "'"
        ʋ:[]+  # Append the string ":[]"
               # Implicit output

```

---
Tags: code-golf, string, syntax, haskell
---