title: Largest number in ten bytes of code

text:
# Question
Title: Largest number in ten bytes of code
Your goal is to print (to the standard output) the largest number possible, using just ten characters of code.

* You may use any features of your language, except built-in exponentiation functions.
    + Similarly, you may not use scientific notation to enter a number. (Thus, no `9e+99`.)
* The program must print the number without any input from the user. Similarly, no reading from other files, or from the Web, and so on.
* Your program must calculate a single number and print it. You can not print a string, nor can you print the same digit thousands of times.
* You may exclude from the 10-character limit any code necessary to print anything. For example, in Python 2 which uses the `print x` syntax, you can use up to 16 characters for your program.
* The program must actually succeed in the output. If it takes longer than an hour to run on the fastest computer in the world, it's invalid.
* The output may be in any format (so you can print `999`, `5e+100`, etc.)
* Infinity is an abstract concept, not a number. So it's not a valid output.

# Answer
> 26 votes
**Wolfram Language**

```
ack(9!,9!)

```

Try it online!

$$\text{ack}(9!,9!) = 2 \uparrow^{362878} 362883 - 3$$

Output is in Arrow Notation.

# Answer
> 126 votes
# Perl, \>1.96835797883262e+18

```
time*time

```

Might not be the largest answer... today! But wait enough millennia and it will be!

---

**Edit:**

To address some of the comments, by "enough millenia," I do in fact mean n100s of years.

To be fair, if the big freeze/heat death of the universe is how the universe will end (estimated to occur ~10100 years), the "final" value would be ~10214, which is certainly much less than some of the other responses (though, "random quantum fluctuations or quantum tunneling can produce another Big Bang in 101056 years"). If we take a more optimistic approach (e.g. a cyclic or multiverse model), then time will go on infinitely, and so some day in some universe, on some high-bit architecture, the answer would exceed some of the others.

On the other hand, as pointed out, `time` is indeed limited by the size of integer/long, so in reality something like `~0` would always produce a larger number than `time` (i.e. the max `time` supported by the architecture).

This wasn't the most serious answer, but I hope you guys enjoyed it!

# Answer
> 66 votes
# Wolfram ≅ 2.003529930 × 1019728

Yes, it's a language! It drives the back-end of the popular Wolfram Alpha site. It's the only language I found where the Ackermann function is built-in **and** abbreviated to less than 6 characters.

In eight characters:

```
$ ack(4,2)

200352993...719156733

```

Or ≅ 2.003529930 × 1019728

`ack(4,3)`, `ack(5,2)` etc. are much larger, but too large. `ack(4,2)` is probably the largest Ackermann number than can be completely calculated in under an hour.

Larger numbers are rendered in symbolic form, e.g.:

```
$ ack(4,3)

2↑²6 - 3 // using Knuth's up-arrow notation

```

The rules say any output format is allowed, so this might be valid. This is greater than 101019727, which is larger than any of the other entries here except for the repeated factorial.

However,

```
$ ack(9,9)

2↑⁷12 - 3

```

is larger than the repeated factorial. The largest number I can get in ten characters is:

```
$ ack(99,99)

2↑⁹⁷102 - 3

```

This is insanely huge, the Universe isn't big enough to represent a significant portion of its digits, even if you took repeated logs of the number.

# Answer
> 30 votes
# Python2 shell, 3,010,301 digits

```
9<<9999999

```

Calculating the length: Python will append a "L" to these long numbers, so it reports 1 character more than the result has digits.

```
>>> len(repr( 9<<9999999 ))
3010302

```

First and last 20 digits:

```
40724177878623601356... ...96980669011241992192

```

# Answer
> 29 votes
# CJam, 2 × 10268,435,457

```
A28{_*}*K*

```

This computes *b*, defined as follows:

* a0 = 10
* an = an - 12
* b = 20 × a28

```
$ time cjam <(echo 'A28{_*}*K*') | wc -c
Real    2573.28
User    2638.07
Sys     9.46
268435458

```

### Background

This follows the same idea as Claudiu's answer, but it isn't based on it. I had a similar idea which I posted just a few minutes after he posted his, but I discarded it since it didn't come anywhere near the time limit.

However, aditsu's suggestion to upgrade to Java 8 and my idea of using powers of 10 allowed CJam to calculate numbers beyond the reach of GolfScript, which seems to be due to some bugs/limitations of Ruby's Bignum.

### How it works

```
A    " Push 10.                                                          ";
28{  " Do the following 28 times:                                        ";
  _* " Duplicate the integer on the stack and multiply it with its copy. ";
}*   "                                                                   ";
K*   " Multiply the result by 20.                                        ";

```

---

# CJam, ≈ 8.1 × 101,826,751

```
KK,{)*_*}/

```

Takes less than five minutes on my machine, so there's still room for improvement.

This computes a20, defined as follows:

* a0 = 20
* an = (n × an - 1)2

### How it works

```
KK,   " Push 20 [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ]. ";
{     " For each integer in the array:                                 ";
  )*  " Increment it and compute the its product with the accumulator. ";
  _*  " Multiply the result with itself.                               ";
}/

```

# Answer
> 21 votes
# Any language with short enough constant names, 18 digits approx.

```
99/sin(PI)

```

I would post this as a PHP answer but sadly `M_PI` makes this just a little too long! But PHP yields 8.0839634798317E+17 for this. Basically, it abuses the lack of absolute precision in PI :p

# Answer
> 21 votes
# Python 3, 9\*2^(7\*2^33) \> 10^18,100,795,813

# 9\*2^(2^35) \> 10^10,343,311,894

Edit: My new answer is:

```
9<<(7<<33)

```

Old answer, for posterity:

```
9<<(1<<35)

```

Ten characters exactly.

I am printing the number in hex, and

> You may exclude from the 10-character limit any code necessary to print anything. For example, in Python 2 which uses the print x syntax, you can use up to 16 characters for your program.

Therefore, my actual code is:

```
print(hex(9<<(7<<33)))

```

Proof that it runs in the specified time and generates a number of the specified size:

```
time python bignum.py > bignumoutput.py

real    10m6.606s
user    1m19.183s
sys    0m59.171s
wc -c bignumoutput.py
15032385541 bignumoutput.py

```

My number \> 10^(15032385538\*log(16)) \> 10^18100795813

3 less hex digits than the above wc printout because of the initial `0x9`.

Python 3 is necessary because in python 2, `7<<33` would be a long, and `<<` doesn't take longs as inputs.

I can't use 9\<\<(1\<\<36) instead because:

```
Traceback (most recent call last):
  File "bignum.py", line 1, in <module>
    print(hex(9<<(1<<36)))
MemoryError

```

Thus, this is the largest possible number of the form `a<<(b<<cd)` printable on my computer.

In all likelihood, the fastest machine in the world has more memory than I do, so my alternate answer is:

```
9<<(9<<99)

```

9\*2^(9\*2^99) \> 10^(1.7172038461\*10^30)

However, my current answer is the largest anyone has submitted, so it's probably good enough. Also, this is all assuming bit-shifting is allowable. It appears to be, from the other answers using it.

# Answer
> 19 votes
# **HTML, 9999999999**

```
9999999999

```

.. nailed it.

# Answer
> 17 votes
# Haskell

Without any tricks:

```
main = print -- Necessary to print anything
    $9999*9999 -- 999890001

```

Arguably without calculating anything:

```
main = print
    $floor$1/0 -- 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216

```

Adapting Niet's answer:

```
main = print
    $99/sin pi -- 8.083963479831708e17

```

# Answer
> 16 votes
## Powershell - 1.12947668480335E+42

```
99PB*9E9PB

```

Multiplies 99 Pebibytes times 9,000,000,000 Pebibytes.

# Answer
> 14 votes
# J (`((((((((9)!)!)!)!)!)!)!)!`)

Yeah, that's a lot. `10^(10^(10^(10^(10^(10^(10^(10^6.269498812196425)))))))` to be not very exact.

```
!!!!!!!!9x

```

# Answer
> 14 votes
# K/Kona: ~~8.977649e261~~ 1.774896e308

```
*/1.6+!170

```
* `!170` creates a vector of numbers from 0 to 169
* `1.6+` adds one to each element of the vector & converts to reals (range is 1.6 to 170.6)
* `*/` multiplies each element of the array together

If Kona supported quad precision, I could do `*/9.+!999` and get around 1e2584. Sadly, it doesn't and I'm capped to double precision.

---

old method

```
*/9.*9+!99

```
* `!99` creates a vector of numbers from 0 to 98
* `9+` adds 9 to each element of the vector (now ranges 9 to 107)
* `9.*` multiplies each element by 9.0 (implicitly converting to reals, so 81.0 through 963.0)
* `*/` multiplies each element of the vector together

# Answer
> 11 votes
# Python - Varies, up to 13916486568675240 (so far)

Not entirely serious but I thought it would be kinda fun.

```
print id(len)*99

```

Out of all the things I tried, `len` was most consistently getting me large ids.

Yielded 13916486568675240 (17 digits) on my computer and 13842722750490216 (also 17 digits) on this site. I suppose it's possible for this to give you as low as 0, but it could also go higher.

# Answer
> 10 votes
# Golfscript, 1e+33,554,432

```
10{.*}25*

```

Computes `10 ^ (2 ^ 25)`, without using exponents, runs in 96 seconds:

```
$ time echo "10{.*}25*" | ruby golfscript.rb  > BIG10

real    1m36.733s
user    1m28.101s
sys     0m6.632s
$ wc -c BIG10
 33554434 BIG10
$ head -c 80 BIG10
10000000000000000000000000000000000000000000000000000000000000000000000000000000
$ tail -c 80 BIG10
0000000000000000000000000000000000000000000000000000000000000000000000000000000

```

It can compute up to `9 ^ (2 ^ 9999)`, if only given enough time, but incrementing the inner exponent by one makes it take ~triple the time, so the one hour limit will be reached pretty soon.

**Explanation**:

Using a previous version with the same idea:

```
8{.*}25*

```

Breaking it down:

```
8         # push 8 to the stack
{...}25*  # run the given block 25 times

```

The stack at the start of each block consists of one number, the current number. This starts off as `8`. Then:

```
.         # duplicate the top of the stack, stack is now | 8 | 8 |
*         # multiply top two numbers, stack is now       | 64 |

```

So the stack, step by step, looks like this:

```
8
8 8
64
64 64
4096
4096 4096
16777216
16777216 16777216

```

... etc. Written in math notation the progression is:

```
n=0, 8                     = 8^1  = 8^(2^0)
n=1, 8*8                   = 8^2  = 8^(2^1)
n=2, (8^2)*(8^2) = (8^2)^2 = 8^4  = 8^(2^2)
n=3,               (8^4)^2 = 8^8  = 8^(2^3)
n=4,               (8^8)^2 = 8^16 = 8^(2^4)

```

# Answer
> 7 votes
# wxMaxima ~3x1049,948 (or 108,565,705,514 )

```
999*13511!

```

Output is

```
269146071053904674084357808139[49888 digits]000000000000000000000000000000

```

---

Not sure if it quite fits specs (particularly the output format one), but I can hit even larger:

```
bfloat(99999999!)

```

Output is

```
9.9046265792229937372808210723818b8565705513

```

That's roughly 108,565,705,514 which is *significantly* larger than most of the top answers and was computed in about 2 seconds. The `bfloat` function gives arbitrary precision.

# Answer
> 6 votes
# Haskell, 4950

Aww man, that's not a lot! 10 characters start after the dollar sign.

```
main=putStr.show$sum[1..99]

```

# Answer
> 6 votes
## Mathematica, 2.174188391646043\*10^20686623745

```
$MaxNumber

```

Ten characters exactly.

# Answer
> 6 votes
# APL (Dyalog), 1.79769e308 (float64) or 9.99999e6144 (decimal128), 3 bytes

This is the minimum reduction of an empty list:

```
⌊/⍬

```

minimum

`/` reduction

empty list

When reducing an empty list, APL will return the identity element of the function used (if known). For minimum reduction of a system without infinities (e.g. ISO APL, to which Dyalog APL adheres), the identity element for minimum is the largest representable number:

Try it online! (IEEE 754 64-bit floating-point)

Try it online! (IEEE 754-2008 128-bit decimal floating-point)

# Answer
> 6 votes
# Casio fx-350 ES PLUS, approx. 9.999882753E99

Do calculators count?

At `70!` the calculator throws error because apparently it has a number range limit `-1E100 ~ 1E100`

# Answer
> 6 votes
# Binary Lambda Calculus, \\$ f\_{\omega+2} (2)\\$, 9.75 bytes

This program outputs a number larger than Graham's Number while using 78 bits, which is 9.75 bytes, within the 10-byte budget given to me:

```
010101000001110011101000000101011000000101101101011010000110100000011100111010

```

If you prefer an ASCII display of the binary number, here it is:

```
T��mhh:

```

(Inspired, but not copied, by the entry mentioned here)

## How it works:

This Binary Lambda Calculus expression encodes the following expression below:

```
(\f x.f (f x))(\f n.n (\g m.m g m) f n)(\x.x x)(\f x.f (f x))

```

This Lambda Calculus expression uses Church Numerals. Church Numerals are generally considered to be the standard representation of natural numbers. What makes Church Numerals powerful is that they are defined using recursion:

`[n] f m = f (f (f (...(f m)...)))` with n f's.

What this means is that if we have a function \\$f\\$ and a natural number \\$n\\$, we can simply concatenate them into \\$n f\\$ to make a much faster function. You can read the article I linked above if you want to see how Church Numerals can be encoded in Lambda Calculus.

### Exponentiation

What is more, Church Numerals can even act on themselves! `n m` represents \\$m^n\\$ using exponentiation!

Example: \\$2^3\\$
(Here, we will apply that to the function f n, to show the true power of recursion)

* `3 2 f n`
* `2 (2 (2 f)) n`
* `(2 (2 f)) ((2 (2 f)) n)`
* `(2 f) ((2 f) ((2 f) ((2 f) n)))`
* `f (f (f (f (f (f (f (f n)))))))`
* `= 8 f n`

We can create a function that captures the true power of exponentiation!

```
\x.x x

```

When applied to a Church Numeral \\$n\\$, it returns \\$n^n\\$. Viola! Let's call our exponential combinator \\$E\\$, such that:

```
E = (\x.x x)

```

### Recursion

In order to get beyond exponentiation, we must recurse our \\$E\\$ combinator. Remember how popping a number before a function recurses it? Well, we can do this with the E combinator, provided that it is a unary function. Define the \\$R\\$ combinator as followed:

```
R = (\g. \m.m g m)

```

Here, how it works is that for a function \\$f\\$ applied to an number \\$n\\$, \\$Rfn\\$ reduces down to \\$nfn\\$. This is awesome, because Church numerals naturally recurse functions, meaning \\$nfn\\$ reduces down to \\$f (f (f ...(f n)...))\\$.

What if we let our function be our exponential combinator \\$E\\$? \\$REn\\$ grows tetrationally. But there is no reason to stop here. We can merge \\$R\\$ and \\$E\\$ into a single combinator, \\$(RE)\\$, and recurse that to have \\$R(RE)n\\$. This grows pentationally.

We can have \\$R(R(RE))n\\$, \\$R(R(R(RE)))n\\$, and so on. But notice how the \\$R\\$ combinator is being recursed over \\$E\\$. Well, this is where Church Numeral Recursion comes back into play.

### Super-Recursion

Define a new combinator, \\$S\\$, as the following:

```
S = (\f n.n R f n) = (\f n.n (\g m.m g m) f n)

```

Cool, now one thing that makes this powerful is that while the \\$R\\$ combinator recurses over a function \\$f\\$, the \\$S\\$ combinator repeatedly applies the \\$R\\$ combinator to a function \\$f\\$. Consider this:

$$SE3$$

The first thing that \\$S\\$ combinator is going to do is to reduce to \\$nR\\$ where n is the number after the \\$E\\$. So our reduction will look like this:

$$3RE3$$

The Church Numeral recursion applies on \\$R\\$ over \\$E\\$, thus nesting \\$R\\$ three times, thus giving us this:

$$R(R(RE))3$$

As we seen above, each \\$R\\$ increases the size of the number considerably, and now the \\$S\\$ combinator recurses over the \\$R\\$ combinator! The combinator (SE) grows at \\$f\_{\omega}\\$ in the Fast Growing Hierarchy, about the limit of the Ackermann Function. We can take this a step forward.

* \\$R(SE)\\$ recurses over the (SE) combinator, growth rate similar to Graham's Number
* \\$R(R(SE))\\$ has \\$f\_{\omega+2}\\$ growth in the fast growing hierarchy
* \\$S(SE)\\$ has \\$f\_{\omega2}\\$ growth in the fast growing hierarchy
* \\$S(S(SE))\\$ has \\$f\_{\omega3}\\$ growth in the fast growing hierarchy

Similar to how inserting a church numeral before \\$R\\$ can recurse the recursion function over \\$E\\$, inserting a church numeral before \\$S\\$ recurse the super-recursion function over \\$E\\$. For example, \\$2SE\\$ = \\$S(SE)\\$.

## The Number:

The number is \\$2SE2\\$ using Church Numerals and the combinators defined above. This translates to about \\$f\_{\omega+2} (2)\\$ in the Fast Growing Hierarchy, which is greater than Graham's Number. Graham's Number is far greater than even \\$Ack(9!,9!)\\$ in Wolfram-Alpha. Expanding \\$2SE2\\$ will yield:

```
(\f x.f (f x))(\f n.n (\g m.m g m) f n)(\x.x x)(\f x.f (f x))

```

The lambda expression for \\$2\\$ is `(\f x.f (f x))`, as you can see it is a Church Numeral. By decoding this Lambda Calculus Expression in Binary Lambda Calculus, one could expect a 9.75-byte expression:

```
010101000001110011101000000101011000000101101101011010000110100000011100111010

```

We proved that we can beat Graham's Number in 10 bytes! Ridiculous?

# Answer
> 5 votes
# Python shell, 649539 999890001

Beats Haskell, not really a serious answer.

```
99999*9999

```

# Answer
> 5 votes
I'd rather post this as a comment above, but apparently I can't since I'm a noob.

Python:

`9<<(2<<29)`

I'd go with a larger bit shift, but Python seems to want the right operand of a shift to be a non-long integer. I think this gets closer to the theoretical max:

`9<<(7<<27)`

The only problem with these is that they might not satisfy rule 5.

# Answer
> 4 votes
## Befunge-93 (1,853,020,188,851,841)

Glad nobody has done Befunge yet (it's my niche), but dammit I can't find any clever trick to increase the number.

```
9:*:*:*:*.

```

So it's 9^16.

```
:*

```

Basically multiplies the value at the top of the stack with itself. So, value at the top of the stack goes:

```
9
81
6561
43046721
1853020188851841

```

and

```
.

```

Outputs the final value. I would be interested to see if anybody has any better ideas.

# Answer
> 4 votes
## At least Python 3.5.0 (64-bit), more than 10^242944768872896860

```
print("{:x}".format( 9<<(7<<60) ))

```

In an ideal world, this would be `9<<(1<<63)-1`, but there aren't enough bytes for that. This number is so big that it requires almost 1 EiB of memory to hold it, which is a little bit more than I have on my computer. Luckily, you only need to use around 0.2% of the world's storage space as swap to hold it. The value in binary is `1001` followed by 8070450532247928832 zeros.

If Python comes out for 128-bit machines, the maximum would be `9<<(9<<99)`, which requires less than 1 MiYiB of memory. This is good, because you'd have enough addressable space left to store the Python interpreter and the operating system.

# Answer
> 3 votes
# Matlab (1.7977e+308)

Matlab stores the value of the largest (double-precision) floating-point number in a variable called `realmax`. Invoking it in the command window (or at the command line) prints its value:

```
>> realmax

ans =

  1.7977e+308

```

# Answer
> 3 votes
# Python, ca. 1.26e1388

```
9<<(9<<9L)

```

Gives:

> 126026689735396303510997749074166929355794746000200933374690887068497279540873057344588851620847941756785436041299246554387020554314993586209922882758661017328592694996553929727854519472712351667110666886882465827559219102188617052626543482184096111723688960246772278895906137468458526847698371976335253039032584064081316325315024075215490091797774136739726784527496550151562519394683964055278594282441271759517280448036277054137000457520739972045586784011500204742714066662771580606558510783929300569401828194357569630085253502717648498118383356859371345327180116960300442655802073660515692068448059163472438726337412639721611668963365329274524683795898803515844109273846119396045513151325096835254352967440214290024900894106148249792936857620252669314267990625341054382109413982209048217613474462366099211988610838771890047771108303025697073942786800963584597671865634957073868371020540520001351340594968828107972114104065730887195267530118107925564666923847891177478488560095588773415349153603883278280369727904581288187557648454461776700257309873313090202541988023337650601111667962042284633452143391122583377206859791047448706336804001357517229485133041918063698840034398827807588137953763403631303885997729562636716061913967514574759718572657335136386433456038688663246414030999145140712475929114601257259572549175515657577056590262761777844800736563321827756835035190363747258466304L

# Answer
> 3 votes
## \>\<\>

**2020 update:**

`'*:*l1=?n!`

Try it online!

A nice, big number.

6607775919524790651439701166707789489378797865523309469653600804966653717124420234900643695716633983263105744751733811265946551350757473520290996592227365993351117075631863250858664418726460620430636874466736708735091515674858617262672061392356105274688381926671523379031815127376998794734801639561117309008230181917173237247958670364395979998445068443549603086925428413456037483510188036968643022754136876546302694036337733250775972540791054488317803988268522700511802405629821189614545680714572177873101991977461377780062066275613653646526353437038254323542049537486740164431723433218814788820554530926749282165106713414138827765731299184793201063834591836604608194080942136186867241173559749340134123556348756219648917627921044482452298279885527390296021299809895208344965720017693561708427752229404713795765501476321809083160697802384075712539404128882728723305116462257211512254983151160419880169748505483542215949682009001146040637299350914438311533945478015790682139849329365319957805121129755402607972548916020445921204515251014341335241310585757251648664383763145215969276240907124147926204015695626240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

---

## ~~3147440830160257032480100000000~~ 319626579315078487616775634918212890625

**Edit:**

Seems like I am allowed to exclude the characters needed for printing, the `n` in this case, so here is an updated version:

```
':*:*:*:*nÿ

```

**Original answer:**

```
'*:*:*:*n;

```

Here, `'` activates stringmode, and pushes all the following characters to the stack, before wrapping and exiting stringmode. Then it does a multiply-and-copy chain, printing the number, and exits. Of interest here is the ascii value of `n` 110, and `;` 59.

However, if we allow it to terminate with an error, we can abuse the fact that the official interpreter supports Unicode. The title of the question says bytes, but the text says characters, so the following program is just for the fun of it.

```
'*:*:*:*n

```

Outputting 1867215243681462552708446358738678532523702556144100000000

Alternatively, to stick to bytes, `ÿ` at the end gives us 383233022803952503175039062500000000, and that is still nice.

(New "for fun" program `':*:*:*:*n` prints 7587624076546380447593767884781979512738274729546264306618287972087303430335365121)

# Answer
> 3 votes
# Perl, non competing

I'm using this to highlight a little know corner of perl.

Perl can't really compete on this one because it doesn't have builtin bignums (of course you could load a bignum library).

But what everybody knows isn't completely true. One core function actually can handle big numbers.

The `pack` format `w` can actually convert any size natural number between base `10` and base `128`. The base 128 integer is however represented as string bytes. The bitstring `xxxxxxxyyyyyyyzzzzzzz` become the bytes: `1xxxxxxx 1yyyyyyy 0zzzzzzz` (every byte starts with 1 except the last one). And you can convert such a string to base 10 with unpack. So you can write code like:

```
unpack w,~A x 4**4 .A

```

which gives:

```
17440148077784539048602210552864286760481312243331966651657423831944908597692986131110771184688683631223604950868378426010091037391551287028966465246275171764867964902846884403624214574779667949236313638077978794791039372380746518407204456880869394123452212674801443116750853569815557532270825838757922217314748231826241930826238846175896997055564919425918463307658663171965135057749089077388054942032051553760309927468850847772989423963904144861205988704398838295854027686335454023567793114837657233481456867922127891951274737700618284015425

```

You can replace the `4**4` by larger values until you feel it takes too long or uses too much memory.

Unfortunately this is way too long for the limit of this challenge, and you can argue that the base 10 result is converted to a string before it becomes the result so the expression doesn't really produce a number. But internally perl really does the needed arithmetic to convert the input to base 10 which I always considered rather neat.

# Answer
> 3 votes
# TI-36 (not 84, 36), 10 bytes, approx. 9.999985426E99

Older calculators can be programmed to an extent as well ;)
`69!58.4376`
This is very close to the maximum range a TI calculator can display: `-1E100<x<1E100`

# Answer
> 3 votes
# ARM Thumb, multiword integer, ~~~1.157921e+77~~ ~4.973232e+86

Machine code:

```
2306 1fd9 000a b407 b407

```

Assembly

```
        .globl main
        .thumb
        .thumb_func
main:
        push    {r4, lr}
        // start number generation code
        movs    r3, #6             // 2
        subs    r1, r3, #7         // 4
        movs    r2, r1             // 6
        push    {r1, r2, r3}       // 8
        push    {r1, r2, r3}       // 10
        // end number generation code
        // now printf everything
        adr     r0, .Lprintf_str
        bl      printf
        pop     {r1, r2, r3}
        pop     {r1, r2, r3, r4, pc}
        // print 32 bits at a time
.Lprintf_str:
        .asciz "%#08x%08x%08x%08x%08x%08x%08x%08x%08x\n"

```

Try it online! (sorta)

Assembles a 288-bit big endian unsigned integer (with little endian words) with the high 96 bits in `r1-r3` and the low 192 bits on the stack.

The number is, in hex, `0xffffffffffffffff00000006ffffffffffffffff00000006ffffffffffffffff00000006`, or in base 10, `497323236409786642128422301523609912453495901056838330362914156057471888398396751347718`.

# Explanation

You may be wondering why I chose `6` and `7`. The reason is because of the limitations of narrow instructions.

`movs Rd, #imm` can only encode an 8-bit immediate from `0-255`. No negatives allowed, which would make this almost *too* easy.

`subs Rd, Rn, #imm` can only encode a 3-bit immediate from `0-7`. I can only subtract `0-255` if I use the same destination register, which isn't very helpful.

So therefore, since `r1` will be more significant, we put `6` in `r3`, then subtract `7` to get `-1`, or `0xFFFFFFFF`, in `r1`.

```
        movs    r3, #6             // 2
        subs    r1, r3, #7         // 4

```

Now, time for things to get super dumb.

First, we duplicate `0xFFFFFFFF` to `r2` using `movs`.

```
        movs    r2, r1             // 6

```

Then, we (ab)use ARM's `push` instruction. ARM's `push` instruction (as well as its sibling `stm`) can push multiple registers at once to the stack, effectively doing a block copy.

We abuse this to copy `r1`, `r2`, and `r3` to the stack twice, tripling the width of the integer.

You could say this is some form of exponentiation, but all I'm doing is pushing to the stack. Nothing suspicious here.

```
        push    {r1, r2, r3}       // 8
        push    {r1, r2, r3}       // 10

```

Now, it looks like this:

```
   r1: 0xFFFFFFFF    r2: 0xFFFFFFFF
   r3: 0x00000006
 sp+0: 0xFFFFFFFF  sp+4: 0xFFFFFFFF
 sp+8: 0x00000006 sp+12: 0xFFFFFFFF
sp+16: 0xFFFFFFFF sp+20: 0x00000006

```

# ARM Thumb-2, softfloat, 1.797693e+308

Machine code:

```
f248 0310 041b 17da 43db

```

Assembly:

```
        .thumb
        .globl main
        .thumb_func
main:
        push    {r4, lr}
        // Begin number generation code
        movw    r3, #0x8010     // 4
        lsls    r3, r3, #16     // 6
        asrs    r2, r3, #31     // 8
        mvns    r3, r3          // 10
        // End number generation code
        adr     r0, .printf_str
        bl      printf
        pop     {r4, pc}

        .align 4
.printf_str:
        .asciz "%f\n"

```

Try it online! (sorta)

Creates the 64-bit constant `0x7fefffffffffffff`, which is `DBL_MAX`, in `r2-r3` (since the AAPCS aligns 64-bit integers to even registers)

Specifically, `179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000`

We do this by first putting `~(*(long long*)&DBL_MAX) >> 48` in `r3`, shifting left by 16, doing an arithmetic shift right into `r2` to make it `0xFFFFFFFF`, then do a one's complement to get `r3` to `0x7fefffff`.

# ARM Thumb-2, (non-competing), softfloat + printf merging, 2.148532e+319

Machine code:

```
f248 0110 0409 43ca 0013

```

Assembly:

```
        .thumb
        .globl main
        .thumb_func
main:
        push    {r4, lr}
        // Begin number generation code
        movw    r1, #0x8010     // 4
        lsls    r1, r1, #16     // 6
        mvns    r2, r1          // 8
        movs    r3, r2          // 10
        // End number generation code
        adr     r0, .printf_str
        bl      printf
        pop     {r4, pc}

        // Combine 0x80100000u (2148532224) with the same double we had before.
.printf_str:
        .asciz "%u%f\n"

```

Try it online! (sorta)

This is obviously cheating, as it is actually generating an unsigned integer and a double and printing them together, but decided to add it for the lulz.

It basically does this:

```
uint32_t r1 = (~0x7fef) & 0xffff;
// 0x80100000
r1 <<= 16;
uint32_t r2 = ~r1;
uint32_t r3 = r2;
// 0x7fefffff7fefffff
uint64_t r2r3 = r2 | ((uint64_t)r3 << 32);
double d = *(double*)&r2r3;
printf("%u%f\n", r1, d);

```

# Answer
> 2 votes
## Scala, 263-1

Poor, poor Scala. Takes at least 8 characters to get a `BigInt` value, which doesn't leave enough room to actually make it big.

But with only 7 characters of (counted) code, we can print the largest possible positive `Long`:

```
print(-1L>>>1)

```

# Answer
> 2 votes
# Brainf\**k 256 - 2147483647

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

```

If you ignore the fact that most compilers & interpreters output data as it's ascii equivalent (be leanient, it is what it is ;) ), this will return the maximum value of the interpreter/compiler's datatype.

On some systems this is just 256, although on some (mine for example), this is the max value of a 32 bit integer, ie 2 147 483 647.

Edit:

```
-.

```

Will print the same thing in many fewer characters

# Answer
> 2 votes
# Braingolf, I don't even know \[non-competing\]

```
#~U&^^^^^^

```

Doesn't work on TIO as I need to get Dennis to pull, but as you can see here, `U` in Braingolf calculates a range from 1 to the last item on the stack, in this case `~` or 126

Then reduces the entire stack with exponentiation, meaning the stack now contains 1 value which is equal to `126^125^124...^2^1`

We'll call this value `n` from now on.

Then I had some bytes left, so I filled them with some monadic `^` operators.

This means the final output is `(((((n^n)^n)^n)^n)^n)`

For reference, `126^125` is `3.518180682714907e+262` and `(126^125)^124` is ~35000 digits long

# Answer
> 2 votes
# Aceto

```
kτ\p******u

```

Prints out

~~1 * 10846~~ (2017)

~~1.1 * 10846~~ (2018)

~~1.3 * 10846~~ (2019)

6.89 * 1013537 (2019)

### Explanation

```
k - makes the stack 'sticky' so that values when popped are only copied,
 not removed
τ - pushes the date on the stack (the year is on the top, 2017 right now...)
\ - escapes the next character (print)
p - (ignored on first go-around)
*
 *
  *
   *        Multiplies top element by second, but stack has one element so it does it by itself
    *
     *
      *
       *
u - reverses instruction pointer direction
       *
      *
     *
    *
   *
  *
 *
*
p - prints
\ - escapes the date
k - makes stack sticky

```

Try it online!

# Answer
> 2 votes
# Runic

This answer is only works, if the following things are true:

1. I implement the Ackermann function using a non stack overflowing implementation.
    * Which I did briefly last night, but removed as there is no useful reason to keep it
    * It did successfully calculate `Ack(4,3)` over the course of 20-30 seconds, a number with `19729` digits.
2. If there are no arbitrary execution limits (e.g. TIO's 60 second timeout)
3. The executing computer has an arbitrary amount of memory to store exceedingly large stacks of BigIntegers

But if given those, then this program...

```
'ÿY:A:A:A@

```

...prints a number so large simply calculating how many *digits* it has is impossible, due to the explosive nature of the Ackermann sequence. Heck the inputs to the first call are both 255000!

The output (and thus input to the next call) is (in Knuth up-arrow notation): 2 ↑254998255003 \- 3
(that's 254 BILLION arrows!)

## Explanation

```
>                Implicit entry
 'ÿ              Pushes the character ÿ onto the stack (which will be implicitly converted to an `int`
                    whenever a math operator is called on it).
   Y             Multiply by 1000 (the 'biggest' thing we can apply to a single stack value in 1 byte)
    :            Duplicate top item on the stack
     A           Pop x and y, call Ack(x,y)
      :          Duplicate top item on the stack
       A         Pop x and y, call Ack(x,y)
        :        Duplicate top item on the stack
         A       Pop x and y, call Ack(x,y)
          @      Print the entire stack, top to bottom (there's only 1 value) and terminate

```

### Larger still?

```
`AAAAAAAA@

```

Push the character sequence `A,A,A,A,A,A,A,A,@` onto the stack (9 items) as the instruction pointer begins a character sequence on \` and loops around until it sees \` again. Each `A` then invokes `Ack(x,y)` (where `x` is the top of the stack) until the stack contains 1 entry, printing it. Not sure if this is actually larger or not.

## However...

The closest we can get by abiding by the limitations is this:

```
':pba,*@

```

(Note the non-printing character 0x8F in position 2)

Try it online!

Which prints `1.79657789596691E+308` (143143 * 1.1). The multiplier of 1.1 is the largest that can be applied without rolling over to infinity due to the limits on a double: even multiplying by `a9,` (1.11) is sufficient to trigger the infinity bit.

# Answer
> 2 votes
# Perl 6, 456,574 digits

```
[*] 1..ↈ

```

No TIO because it takes 2 minutes to run.

# Answer
> 2 votes
# Keg, 260144641↑260144641

```
*:*(:|:*

```

Surprised I was able to get it this high, probably can be improved

Edit: Improved by A\__

# How it works

```
   Pushes 127 to the stack twice, I used 127 since it is the highest number that can be pushed in 1 byte (Note there is two characters there, they're just unprintables)
*    Multiplies them
:*   Squares that
(    Begin a for loop
:|   That will run 260144641 times (since that is the top element of the stack)
:*   That squares the top element of the stack
At the end it will automatically get printed

```

# Answer
> 2 votes
# \>\<\>, ~\\$4.24 \times 10^{1177545600} \\$

```
'****l(?;n

```

Try it online!

Outputs the ordinal value of `*` (42) around 4088700 times. Every loop it only terminates if the length of the stack is higher than multiplying the ordinal values of `l(?;n` = 108\*40\*63\*59\*110 = 1766318400, but since it only pushes 3 elements to the stack each time, this takes a *long* while.

# Answer
> 1 votes
# Perl, 1.84467422290351e+26 (On a 64-bit machine)

```
perl -le "print ~0*9999999"

```

# Answer
> 1 votes
# Python 2.7 - 8794643931199480236 15616093818140822

```
print hash('zz')

```

# Answer
> 1 votes
# JavaScript, more than 13 003 624 633 896 (but it reads a clock)

```
9*new Date

```

Reading from a clock is effectively taking an input. Feels like cheating. However, the technique seems to be well-received in the answers here.

### If clocks are not allowed, then:

## JavaScript, 186 025 771 008

```
99*(7<<28)

```

Trigonometry takes too many bytes (`Math.sin`, `Math.PI`).

Bit-shift goes near the integer maximum, then multiplication yields a floating point.

# Answer
> 1 votes
## C++ prints 18446744073709551615

# #

ULLONG\_MAX is 10 characters.

```
#include <iostream>
#include <limits.h>
using namespace std;
int main()
{
cout<<ULLONG_MAX<<endl;
return 0;
}

```

# Answer
> 1 votes
## TXR:

```
$ txr -p '(mask 999)'
535754303593133660474212524530000905280702405852766803721875194185175525562468061246
599189407847929063797336458776573412593572642846157810728751889829846429852761096554
990320661140395677219337642394922319490470301292036210344653556258987007434741839952
7286296858625998634149561158533358569939198279680

```

# Answer
> 1 votes
**Bash / shell**

> You may exclude from the 10-character limit any code necessary to print anything.
>
> ... you can use up to 16 characters for your program.

**(6 chars for code + 7 chars for printing = 26 digits) = 6888888 digits**

```
$ seq -s9 999999

```

---

This number is bigger, but people may argue that it's in the wrong format.

> The output may be in any format (so you can print 999, 5e+100, etc.).

**(8 chars for code + 8 chars for printing = 26 digits) = more than 1183888008 digits**

```
$ seq -s9 99999999

```

It usually takes around a minute to print the number and it contains the scientific representation of it.

---

Some funny example:

**(10 chars = 26 digits)**

```
echo $$$$$$$$$$
2760127601276012760127601

```

See: What does $$ mean in the shell?

# Answer
> 1 votes
Perl: 6.27710173538668e+57 on cygwin with a Perl 32 bit

```
perl -e 'print ~0*~0*~0, "\n"'

```

# Answer
> 1 votes
# Ozone, 9e+90000

```
(1)n1n1s2

```

Though it depends on dialect.

# Answer
> 1 votes
## Befunge-93, ~2.49e+40

```
"**:*:*:*.

```

This works by pushing the ASCII values of the program onto the stack and doing a bunch of multiplication.

Unfortunately, this doesn't work in TIO, but it does in this interpreter.

Here is a worse version that actually works in TIO:

```
"$$**:*:*.

```

And prints `1152921504606846976`. TIO ended up pushing a lot of spaces and 2 zeroes at the end, so I had to get rid of those.

Note that both of these programs print the number forever, because the end command (`@`) would have taken up a precious byte.

# Answer
> 1 votes
# Brain-Flak, 100 (non-competing)

```
(()@lt99)

```

Note that this code must be run with the `-d` flag which adds 3 bytes.

Try it online!

This uses the `@lt` debug flag in the ruby interpreter. This flag simply adds the following number to the value which is then pushed by the enclosing parentheses.

The enclosing parentheses do not modify the number and are required for it to be printed so they are not counted towards then 10 bytes.

The `()` adds one to the value and causes the interpreter to recognize the enclosing parentheses as pushing a value (parentheses will only push a value if they enclose non-debug flag Brain-Flak code.

# Answer
> 1 votes
# Tcl, number in the Demo Output because it is very extense (has 30104 digits)

```
namespace path tcl::mathop
puts [<< 9 99999]

```

The relevant part is

```
<< 9 99999

```

, the rest is boilerplate.

Try it online!

# Answer
> 1 votes
# Acc!!, 999999

```
19*3
Write _
Write _
Write _
Write _
Write _
Write _

```

As any code necessary to output anything is excluded, all 'Write ' statements are excluded.

Try it online!

# Answer
> 1 votes
# PHP, 9 bytes, MAX INT (9223372036854775807)

```
echo ~0^1<<63;

```

or

```
echo -1^1<<63;

```

Set an int of all bits on (-1) then XOR it with an int of only the first bit on to flip the sign bit.

# Answer
> 1 votes
# Pyt, (only 6 bytes)

```
9!ḞɳƖ*

```

Try it online!

Link to number

I don't really see any point in getting any bigger than this. Anything else exceeds the runtime limit on TIO

```
9  pushes 9
!  factorial of 9 (362880)
Ḟ  push xth Fibonacci Number (really big)
ɳ  push 0123456789
₫  reverse ("987654321")
Ɩ  cast to int ("987654321")
*  multiplies

```

# Answer
> 1 votes
# Perl 6, 730 quadrillion digits

```
9+<now*now

```

This builds the Perl 5 solution (`time*time`) and the Javascript (bit shifting). Time is currently around 1.56 billion, so we square it (~2.44 quintillion), and then bitshift 9 (because \> 1 ha) a fairly insane number of digits to the right. Perl 6 uses arbitrary precision integers, and that applies to bitshifting as well. Bit shifting in and of itself doesn't take hardly any time at all, it's just a question of memory restraint and the largest super computers ought to have sufficient, but I don't on my puny laptop.

Given 210x ≈ 103x, we can surmise that there should be around some 730 quadrillion digits if I did my math right. Times out on TIO for `9+<$x` where $x \> 1000000, but handles 100000 in sub 1 secs ao no TIO link. Answer of course will continue to grow exponentially

(if that's considered out of bounds, though, can just make it `9+<now` which should still fetch a fairly high number, or any other technique to generate the largest in-bounds number at in 7 digits)

# Answer
> 1 votes
## Keg, 1.85302E+15

It is definitely the worst answer here...

```
9:*:*:*:*.

```

# Answer
> 1 votes
## BBC BASIC 2

7 bytes

```
P.2^127

```

Result

```
1.70141181E38

```

As commented the previous answer may violate the exponation rule, so here's something using the EXP (exponent) function instead.

```
P.EXP(88)

```

which returns

```
1.65163622E38

```

# Answer
> 1 votes
# Deadfish~, ~~2↑4000

`{{{iss}}}o`

Crashes TIO, but in theory works.

This means:

Repeat 1000 times: add one, than square twice.

First iteration: 0 =\> 1 =\> 1 =\> 1 Second iteration: 1 =\> 2 =\> 4 =\> 16 Third iteration: 16 =\> 17 =\> 289 =\> 83521 And after this it grows without bound.

# Answer
> 1 votes
# CSASM v2.3, 9222471316929301708

```
func main:
push 1.9
bits
asl
print
ret
end

```

### Explanation

The minimum code needed to print something in CSASM is as follows:

```
func main:
push <something>
print
ret
end

```

Thus, I took the liberty of having the 10-byte limit be on the `<something>` rather than the entire program, as is mentioned in the challenge:

> You may exclude from the 10-character limit any code necessary to print anything.

Otherwise, this language wouldn't be able to even have a submission for this challenge.
(The boilerplate for an empty `main` function is **16** bytes.)

So, that leaves me with figuring out how to best use those 10 bytes. Hence, I abused one of the instructions in the language: **`bits`**

According to the `syntax.txt` file:

> Pops A (an `<f32>` or `<f64>`), then pushes an `<i32>` or `<i64>` set to the bit representation of A

... where **A** stands for "the top value on the stack".

In short, a single- or double-precision floating-point value is popped from the stack. The value's bit representation (sign, exponent, mantissa) is then stored into a 32- or 64-bit integer value and that integer value is pushed to the stack.

### Why use 1.9?

The bit representation of `1.9` is: $$ 00111111 11111110 01100110 01100110 01100110 01100110 01100110 01100110 $$ This value interpreted as an `i64` (or `long`) would be `4611235658464650854`. However, this can be better. Using the last 3 available bytes, we can perform an **A**rithmetic **S**hift **L**eft (`asl`) instruction, to get the following bit representation instead: $$ 01111111 11111100 11001100 11001100 11001100 11001100 11001100 11001100 $$ ... which ends up being `9222471316929301708` instead.

If I were to use any value larger than `1.9` within the limits of the 3 bytes for the number (say, `2.0`), the **exponent** part of the bit representation would be `10000000000` or some larger number.

The MSB in the exponent would get shifted left into the **sign** bit, resulting in a negative end result. Not good.

Furthermore, if I were to not use the `asl` instruction and instead opted to use `1.9999`, the value would still be smaller than using `1.9` and the `asl` instruction.

# Answer
> 1 votes
# TI-Basic (TI-83), 9.999999314e99

```
68!4032.2

```

very close to the soft limit of the calculator (`-1e100<x<1e100`). It can be overcome and get closer to the hard limit (`1e128`) but not in less than 10 characters.

`69!58.4376` is a good contender too but not as close

# TI-Basic (TI-89), 9.99999681785e999

```
449!259.61

```

Again, quite close to the limit (`1e1000` gets automatically replaced with )

# Answer
> 1 votes
# KonamiCode, 1,000,000

`v(^>>>>>>)<<<` (Note: This excludes `<<<` because it is used for output.)

# Answer
> 0 votes
# CJam - 40.4 million digits

```
1X27m<m<

```

Assuming bit shift is ok, this calculates 1\<\<(1\<\<27). It takes about 15 minutes on my laptop, using java 8 to run the interpreter.

# Answer
> 0 votes
## `units` interactive shell, 3.085369e+68

You read that right, I know it's not much but it's definitely different.

```
9999Ypc
ym

```

I'm assuming newline counts as a character and the invocation of `units` counts as code essential to print. `Ypc` is yotta parsec, `ym` is yocto meter.

```
You have: 9999Ypc
You want: ym
    * 3.085369e+68
    / 3.2411034e-69

```

# Answer
> 0 votes
## C#: 1.8E+19

Unfortunately we can't bit-shift doubles.

```
using System;
namespace BigNum10Bytes
{
    class Program
    {
        static void Main()
        {
            // Playing with ulongs
            Console.WriteLine(ulong.MaxValue);
            Console.WriteLine(~(1UL<<64)); // 10 chars, 18446744073709551614
            Console.WriteLine(8191UL<<51); // 10 chars, 18444492273895866368

            Console.ReadLine();
        }
    }
}

```

# Answer
> 0 votes
# Cjam - alot

alot:

```
99999999m!

```

even more:

```
9999999,m!

```

Unfortunately i cant calculate the result. But refering to wikipedia `14842907m!`  would be 2.788662975×10 ^ 100 000 000

# Answer
> 0 votes
# SmileBASIC, ~~8,589,934,592~~ 274,877,906,944

```
?#RED*#RED

```

`#RED` is a constant for the color red (`&HFFF80000`)

The expression only takes up 9 characters, so I can print it in 10 characters without decreasing the number.

# Answer
> 0 votes
Wolfram

```
999999999!

```

Result:

```
9.90462657922299373728082110506570432171722139002... × 10^8565705513

```

Eight and a half billion digits!

This is the biggest I could find without using a named function such as "ack()".

# Answer
> 0 votes
# Stacked, 10 bytes ~ 2 × 10273964

```
17932!:*:*

```

Try it online! Snippet outputs the length, then the number itself.

This calculates (17932!)4 (without exponentiation) using scientific precision, so only a constant width is perpetuated. The number looks like:

```
204449781735459736090000000000000000...00000000000000000

```

This Wolfram|Alpha link shows what the precise calculation would look like.

# Answer
> 0 votes
# x86\_64 machine language (Linux) ~2.808896e+307

```
0:       f2 0f 10 05 fa ff ff    movsd  -0x6(%rip),%xmm0        # 2
7:       ff
8:       c3                      retq
9:       7f

```

This moves the IEEE-754 double precision float `7f c3 ff ff ff fa 05 10` to `%xmm0` and returns.

Try it online!

# Answer
> 0 votes
# Javascript (ES6), 4E+30103

```
9n<<99999n

```

Uses big integers so actually goes way past what normal integers could reach.

# Answer
> 0 votes
# C (gcc), 9 * 10^4202512

`printf("9%.*u","");` or `printf("9%0*u","");`

Try it online!

The shortest way to print anything in C (afaik) is `puts("");` which is 9 bytes
19 - 9 = 10

`.*` specifies precision which isn't exponentiation

> .number
>
> For integer specifiers (d, i, o, u, x, X) − precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0. For e, E and f specifiers − this is the number of digits to be printed after the decimal point. For g and G specifiers − This is the maximum number of significant digits to be printed. For s − this is the maximum number of characters to be printed. By default all characters are printed until the ending null character is encountered. For c type − it has no effect. When no precision is specified, the default is 1. If the period is specified without an explicit value for precision, 0 is assumed.

https://www.tutorialspoint.com/c\_standard\_library/c\_function\_printf

So you'll get 9 followed by `""` digits,(4202512)
the very last ones read from memory as the number to print is not specified,
adding `,0` would prevent memory reading but push it over the 10 byte limit

# Answer
> 0 votes
# 33, 7,762,279,691,451,941,920

```
999999axxao

```

I'm trying to get the language on TIO

About 7.76227969 x 1018

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

```
-1. ud.

```

Try it online!

Produces: **340282366920938463463374607431768211455**

# Answer
> 0 votes
# MathGolf, \\$\approx 1.609 \times 10^{1859933}\\$

```
9!!

```

Try it online!

With MathGolf being a language written in Python, the main issue will be calculating the number in a timely fashion. This program produces its output in about a minute. It might be possible to to \\$(10!)!\\$, which would be significantly bigger. However, the approach and the byte-count is still the same.

# Answer
> 0 votes
# 1+, score 256

```
11+"*"*"*:

```

Begin with 2, square three times, and we get 256. I believe this is optimal.

# Answer
> 0 votes
# C++ (gcc) (x86/x86\_64), 1.18973e+4932

Improvement on an answer from an inactive user.

```
#include <iostream>
#include <cfloat>
int main()
{
    std::cout << LDBL_MAX+0 << std::endl;
}

```

Try it online!

Equivalent C version using `printf` which shows all digits.

Depends on the implementation, but x86 chips on Linux use an 80 bit extended double for `long double`. This results in `LDBL_MAX` being 1.18973e+4932, much larger than `ULLONG_MAX`.

# Answer
> 0 votes
# 05AB1E, \\$\Large\>1.0111110111×10^{146,337}\\$

```
žmbbbbbbbb

```

Try it online! This is the only competing one, the alternative breaks rule 5.

```
žmbbbbbbbb  # full program
         b  # convert...
žm          # 9876543210...
  b         # in binary...
   b        # in binary...
    b       # in binary...
     b      # in binary...
      b     # in binary...
       b    # in binary...
        b   # in binary...
         b  # to binary
            # implicit output

```

# Alternative

This program scores: $$\large(r\_{((x+1)^7-1)}=…(r\_2=(r\_1=x^x)^{r\_1})^{r\_2}…)^{r\_{((x+1)^7-1)}}\\\Huge x=9{,}876{,}543{,}210$$Note: here, \\$\large r\_2\\$ means the second result. So \\$\large r\_{((x+1)^7-1)}\\$ means the \\${\large{((x+1)^7-1)}}^\text{th}\\$ result.

```
žmEEEEEEEm

```

---

```
žmEEEEEEEm  # full program
  E         # for N in [0, 1, ...,
žm          # ..., 9876543210...
  E         # ]...
   E        # for N in [0, 1, ...,
žm          # ..., 9876543210...
   E        # ]...
    E       # for N in [0, 1, ...,
žm          # ..., 9876543210...
    E       # ]...
     E      # for N in [0, 1, ...,
žm          # ..., 9876543210...
     E      # ]...
      E     # for N in [0, 1, ...,
žm          # ..., 9876543210...
      E     # ]...
       E    # for N in [0, 1, ...,
žm          # ..., 9876543210...
       E    # ]...
        E   # for N in [0, 1, ...,
žm          # ..., 9876543210...
        E   # ]...
         m  # push...
žm          # 9876543210...
            # (implicit) or top of stack if not first iteration...
         m  # to the power of...
žm          # 9876543210...
            # (implicit) or top of stack if not first iteration
            # implicit output

```

---
Tags: code-challenge, number, busy-beaver
---


# Question
Title: Shortest way to convert a float to an int
> I'm not really sure if this is the right place to ask this.

Now, I know I can convert a float to an int with `int`, but is there some shorter way?

# Answer
This doesn't actually convert it to an `int` class, but:

Depending on the situation, you may be able to use `x//1`; however, that will actually give a float, so `1.5 // 1` will give `1.0`, not `1`.

Also, this doesn't always work, since `int(-1.5)` is `-1` but `-1.5 // 1` is `-2.0`.

Do with that what you will.

If you use `int(...)` enough times you can assign `i=int`, which breaks even after 3 uses:

```
i=int;i;i;i;i
int;int;int;int
          ^ break-even

```

(For the record, no, you cannot use `x/1` in Python 2, because that's only floor division if both arguments are integers.)
> 3 votes

---
Tags: tips, python
---


title: When the result will reach the people?

text:
# Question
Title: When the result will reach the people?
Assume the result of an exam has been published.

After 5 minutes, First person knows the result.

In next 5 minutes, new 8 persons know the result, and in total 9 know it.

Again after 5 minutes, new 27 people know, and total 36 know.

In similar fashion, total 100, 225..... people keep knowing it on 5 minute interval.

**Challenge**

Given a total number of people knowing (n), and a starting time in hour and minutes, output when total n people will know the result.

Example: If start is 1:02, and n is 225 the output time will be 1:27.

In output colons of time aren't needed, you may input or output as list or seperate variables.

`n` will be always in the sequence of totals, i.e. (1,9,36,100,225....)

# Answer
> 0 votes
# Python 3.8 (pre-release), 85 bytes

```
lambda h,m,x:[(h+(y:=(((((x**.5)*8)+1)**.5)-1)*2.5)//60)%24+(m+y%60)//60,(m+y%60)%60]

```

Try it online!

The sequence of totals is just sum of first \\$n\\$ cubes.

It is a known formula that sum of first \\$n\\$ cubes is the square of \\$n\\$th triangular number (Proof), i.e.

\\$ \\{\frac{n(n+1)}{2}\\}^2 \\$

If we assume given input is \\$x\\$, then

\\$ \\{\frac{n(n+1)}{2}\\}^2=x \\ \frac{n(n+1)}{2}=\sqrt{x} \\ n(n+1)=2\sqrt{x} \\ n^2+n=2\sqrt{x} \\ n^2+n-2\sqrt{x}=0 \\$

We get a quadratic equation with \\$a=1, b=1, c=-2\sqrt{x}\\$

The formula for the quadratic equation is

\\$ \frac{-b\pm\sqrt{b^2-4ac}}{2a} \\$

We will only take the positive root and plug in

\\$ \frac{-b+\sqrt{b^2-4ac}}{2a} \\ =\frac{-1+\sqrt{(-1)^2-4\times(-2\sqrt{x})\times1}}{2\times1} \\ =\frac{-1+\sqrt{1+8\sqrt{x}}}{2} \\ =\frac{(\sqrt{1+8\sqrt{x}})-1}{2} \\$

Which is the formula for the \\$n\\$, then we just multiply it by 5, divmod by \\$60\\$ and add with start time.

# Answer
> 0 votes
# Retina 0.8.2, 103 bytes

```
\d+
$*
(^1|11\1)+
$#1$*
(^1|1\1)+¶(.+)
$2$1$1$1$1$1
+`:1{60}
1:
+`1{24}:
:
(1*):(1*)
$.1:$.2
:(.)$
:0$1

```

Try it online! Takes `n` on the first line and the time (including colon) on the second.Explanation:

```
\d+
$*

```

Convert to unary.

```
(^1|11\1)+
$#1$*

```

Take the square root.

```
(^1|1\1)+¶(.+)
$2$1$1$1$1$1

```

Add 5 times the triangular index to the minutes.

```
+`:1{60}
1:

```

Convert 60 minutes to an hour.

```
+`1{24}:
:

```

Ignore days.

```
(1*):(1*)
$.1:$.2
:(.)$
:0$1

```

Convert to decimal.

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


# Question
Title: Pushing the limits to make a piece of code solving the K-Goodness String problem shorter
I am trying to push my limits of making a python code as short as possible.

> I left the readability part way behind.

I was attempting the **K-Goodness String** problem from Round A of Google Kick Start 2021.

The following was my initial solution:

```
def func(N, K, S):
    if not S: return 0
    y = 0
    for i in range(N//2):
        if S[i] != S[N-i-1]:
            y += 1
    return abs(K - y)

for i in range(int(input())):
    N, K = tuple(map(int, input().split(' ')))
    S = input()
    y = func(N, K, S)
    print(f'Case #{i+1}: {y}')

```

Then I shortened it down to the following:

```
def func(N, K, S):
    if not S: return 0
    for i in range(N//2): K -= S[i] != S[N-i-1]
    return abs(K)
[print(f'Case #{_}: {func(*tuple(map(int, input().split())), input())}') for _ in range(1, int(input())+1)]

```

I seriously want to push the limits. Can anyone help me shorten the *for loop* part:

```
for i in range(N//2): K -= 1 if S[i] != S[N-i-1] else 0

```

so that I can make a lambda function out of `func`, like:

`func = lambda N, K, S: 0 if not S else ...` #something

P.S. I can do it the following way, but that is inefficient and involves redundant steps that increase time and space complexity:

```
func = lambda K, S: abs(K - list(map(lambda x: x[0] != x[1], list(zip(S, S[::-1])))).count(True)//2) if S else 0
[print(f'Case #{_}: {func(tuple(map(int, input().split()))[1], list(input()))}') for _ in range(1, int(input())+1)]

```

Please suggest a good way to do the same.

> P.S. I know its not a good practice to compress a piece of code beyond readable, but I just wanted to do this for fun.

Sample Input

```
2
5 1
ABCAA
4 2
ABAA

```

Sample Output

```
Case #1: 0
Case #2: 1

```

# Answer
### 151 bytes by @user

Here is the 151-byte solution presented in @user's answer. I recommend reading through their post for an explanation of how it works.

```
for t in range(int(input())):N,K=map(int,input().split());print(f'Case #{t+1}:',0if not(S:=input())else abs(K-sum(S[i]!=S[N-i-1]for i in range(N//2))))

```

From here, three tricks can be used to shorten it by a significant amount:

* The edge case of having an empty string \\$ S \\$ is simply unnecessary. According to the constraints in the linked problem, \\$ N \\$ is always at least 1.
* `S[N-i-1]` gets the `i`th element from the back, but the same can be achieved with `S[~i]`, as mentioned here.
* `input` is used a total of three times. We can assign it to a variable with `I=input`, and reuse `I`.

### 130 bytes

Combining these reduces the solution by 21 bytes:

```
I=input
for t in range(int(I())):N,K=map(int,I().split());S=I();print(f'Case #{t+1}:',abs(K-sum(S[i]!=S[~i]for i in range(N//2))))

```

To go even further, we'll need a slight change in approach. In particular, `sum(S[i]!=S[~i]for i in range(N//2))` can be improved with some clever use of `pop`: `sum(c!=S.pop()for c in S)`. These are logically equivalent; for each character in `S`, we compare it to the last element with `S.pop()`.

### 118 bytes

In total, we save 12 bytes this way. Note that we first need to convert `S` to a list via `*S,=input()`, since strings do not have a `pop` method.

```
I=input
for t in range(int(I())):K=int(I().split()[1]);*S,=I();print(f'Case #{t+1}:',abs(K-sum(c!=S.pop()for c in S)))

```

### 112 bytes

Finally, there is a 6-byte improvement by using `open(0)` instead of `input()`, a shortcut that essentially stores the list of lines from STDIN.

```
_,*a=open(t:=0)
while a:K,(*S,_),*a=a;t+=1;print(f'Case #{t}:',abs(int(K.split()[1])-sum(c!=S.pop()for c in S)))

```

There is a lot to unpack here (no pun intended), so I will note some of the potentially confusing parts of the code.

`_,*a=open(0)` reads all input, and stores it as a list of lines. We unpack it by storing the first line in `_`, and the rest in `a`. `_` contains the number of test cases, but it is not needed for the rest of the program.

`while a:K,(*S,_),*a=a` removes the first two elements from `a`, and stores them in `K` and `S`. If we take another look at the sample input, what this is really doing is storing `5 1` in `K`, and `ABCAA` in `S` (as in the 1st test case).

The weird-looking `(*S,_)` is due to the fact that `open(0)` includes the `\n` at the end of each line, meaning that `S` actually equals `'ABCAA\n'` instead of `'ABCAA'`. The "nested unpacking" solves this by isolating the `\n` in `_`.

The `while` loop terminates when `a` is empty, or equivalently when there is no more input left.
> 10 votes

# Answer
Here's a 176-byter after some trivial changes (based off of pxeger's comment):

```
def f(N,K,S):
 if not S:return 0
 for i in range(N//2):K-=S[i]!=S[N-i-1]
 return abs(K)
for _ in range(int(input())):print(f'Case #{_+1}:',f(*map(int,input().split()),input()))
```

Attempt This Online!

* You don't need to name your function `func`
* You can use a normal loop instead of a comprehension
* You can make a range starting at `0` and just add 1 to the case number when printing
* You don't need `tuple` (or even the shorter `list`) because `*` takes care of it
* You can make the result of `f` a separate argument to `print` to get rid of the braces

You're only calling the function once, so we can put that directly into the loop. To get around not being able to `return` from a function, we can try to turn the whole function into a single if expression. If `S` is empty, then it's just 0, but if it's not, we need to turn the for loop to decrement `K` into a single expression. The amount you're decrementing is `sum(S[i]!=S[N-i-1]for i in range(N//2))`, so the else part of the if expression is just `abs(K-<that sum>)`.

Once you do that, use semicolons instead of newlines, and use the walrus for assigning `S`, you get 151 bytes. (I renamed `_` `c` for readability)

```
for c in range(int(input())):N,K=map(int,input().split());print(f'Case #{c+1}:',0if not(S:=input())else abs(K-sum(S[i]!=S[N-i-1]for i in range(N//2))))
```

Attempt This Online!

Someone who knows Python and understands your algorithm can probably do much more, but these are some simple changes you can make. Edit: Yup, dingledooper golfed it to 112 bytes!
> 4 votes

---
Tags: tips, python
---


title: Floating Point indexOf

text:
# Question
Title: Floating Point indexOf
Given a sorted array of unique positive integers \\$A\\$ \\$(A\_0\<A\_1\<\cdots\<A\_{n-1})\\$, and an integer \\$t\\$, where \\$A\_0\le t\le A\_{n-1}\\$. Output the value \\$i\\$ such that:

* If \\$t \in A\\$, \\$A\_i=t\\$.
* If \\$t \notin A\\$, \\$ \left(i-\left\lfloor i\right\rfloor\right)\cdot A\_{\left\lceil i\right\rceil} +\left(\left\lceil i\right\rceil - i\right)\cdot A\_{\left\lfloor i\right\rfloor} = t \\$. In other words, linearly interpolate between the indices of the two elements of \\$A\\$ that most narrowly bound \\$t\\$.

In the above formula, \\$\left\lfloor i\right\rfloor\\$ means rounding \\$i\\$ down to integer; \\$\left\lceil i\right\rceil\\$ means rounding \\$i\\$ up to integer.

You may also choose 1-indexed array, though you need to adjust the formula and the test cases below accordingly.

## Rules

* This is , shortest code in bytes wins.
* Floating point errors in output are allowed, but reasonable floating point precision is required. For testcases listed here, your output should be correct with at least 2 decimal places precision.
* Fraction output is allowed as long as fractions are reduced to their lowest terms.
* It is fine to use any built-ins in your language. But if built-ins trivialize the question, consider submitting a non-trivial one too.

## Testcases

```
[42], 42 -> 0
[24, 42], 24 -> 0
[24, 42], 42 -> 1
[1, 3, 5, 7, 8, 10, 12], 1 -> 0
[1, 3, 5, 7, 8, 10, 12], 7 -> 3
[1, 3, 5, 7, 8, 10, 12], 12 -> 6
[24, 42], 33 -> 0.5
[24, 42], 30 -> 0.3333333333333333
[1, 3, 5, 7, 8, 10, 12], 2 -> 0.5
[1, 3, 5, 7, 8, 10, 12], 9 -> 4.5
[100, 200, 400, 800], 128 -> 0.28
[100, 200, 400, 800], 228 -> 1.14
[100, 200, 400, 800], 428 -> 2.07

```

# Answer
# Python 2, 59 bytes

```
f=lambda l,t,p=0:l<[t]and 1+f(l[1:],t,l[0])or(t-p)/(l[0]-p)

```

Try it online!

Outputs one-indexed. Recursively loops through the list element , each time adding `1` to the eventual index output, until reaching an element that's at least `t`. Then, outputs the fraction of the way `t` is between the current element and previous element `p`. This avoids needing to explicitly track which index we're at.

**62 bytes**

```
lambda l,t:sum(t>y or(t-x)/(y-x)for x,y in zip([0]+l,l)if x<t)

```

Try it online!

One-indexed. Same idea as the 64-byte code below. Interprets the input as "intervals" `(x, y)` of two consecutive elements of the list, starting with left endpoint `0`. The output is the sum over each interval of the fraction of it that's less below `t`, which is `1` for intervals fully below `t` and `0` for those fully above it.

```
lambda l,t:sum(min(1,max(0,(t-x)/(y-x)))for x,y in zip([0]+l,l))

```

Try it online!

The summand is `(t-x)/(y-x)` clamped between 0 and 1.
> 11 votes

# Answer
# Python 3.10, ~~79~~ ~~75~~ ~~67~~ ~~65~~ 59 bytes

```
lambda a,t:(t-a[i:=sum(x<t for x in a)])/(a[i]-[0,*a][i])+i
```

Attempt This Online!

Needs Python 3.10 to use `:=` inside a subscript.

* `t-a[0]and` guards against the edge case where `a` has only one element
* `sum(x<t for x in a)` finds the index of the first item `x` where `x<t`
* `(t-a[i]/(a[i+1]-a[i])+i` just does the linear interpolation

-4 bytes thanks to Kevin Cruijssen

-6 bytes thanks to tsh

-6 bytes thanks to xnor
> 7 votes

# Answer
# MATL, 10 bytes

```
YYhtfi3$Yn

```

Inputs are *A*, then *t*. The output is 1-based.

Try it online! Or verify all test cases.

### Explanation

```
YY     % Push infinity
h      % Implicit input: row vector A, of length n. Concatenate. This attaches
       % infinity at the end of the vector. This is necessary because
       % interpolation requires a vector of at least 2 entries. The value
       % infinity is used so that it doesn't interfere with the interpolation
tf     % Duplicate, find. This gives the row vector [1 2 3 ... n+1]
i      % Input: integer number t.
3$Yn   % 3-input linear interpolation. Implicit display

```
> 6 votes

# Answer
# JavaScript (ES6), 45 bytes

Expects `(t)(A)`.

```
t=>g=([c,...a],p=0)=>t>c?1+g(a,c):(t-c)/(c-p)

```

Try it online!
> 5 votes

# Answer
# Python 3 \+ numpy, 52 bytes

```
lambda a,t:interp(t,a,argsort(a))
from numpy import*

```

Try it online!

As `a`is sorted with no duplicates we can use `argsort` to save a byte over `r_[:len(a)]`. Note that the "no duplicates" is important because numpy doesn't use timsort by default but an unstable qsort.

# or (same length)

```
lambda a,t:interp(t,*unique(a,1))
from numpy import*

```

Try it online!

This uses `numpy.unique` (which is a nop on `a` since `a` has sorted unique values) with the `return_index` switch set. This returns the indices of the unique values v in the input. As `a` has sorted unique values this returns 0,1,...,len(a)-1
> 4 votes

# Answer
# 05AB1E (legacy), ~~18~~ ~~17~~ ~~13~~ 12 bytes

```
-D¹¥/ā+s®›Ïθ

```

First input is the list \\$A\\$, second input is \\$t\\$. The output \\$i\\$ is 1-based.

-1 byte switching to the legacy version of 05AB1E, where `[1]/[]=[1]` instead of `[]`. In the new version of 05AB1E we therefore had to add a  before the `θ` to account for single-item input-lists. Unfortunately, `d` was `is_int` instead of `>=0` in the legacy version, so we have to replace it with `®›` (`>-1`) instead, netting at -1 byte.

Try it online or verify all test cases.

**Explanation:**

```
-             # Subtract each value in the first (implicit) input-list from the
              # second (implicit) input-integer
 D            # Duplicate this list
  ¹           # Push the first input-list again
   ¥          # Pop and push its deltas / forward differences
    /         # Divide the items at the same positions in the two lists
     ā        # Push a list in the range [1,length] (without popping)
      +       # Add that to each value in the list
       s      # Swap to get the duplicated list again
        ®›    # Check for each whether it's larger than -1 (non-negative)
          Ï   # Only keep the items at the truthy indices
           θ  # Pop and leave the last item
              # (after which the result is output implicitly)

```
> 3 votes

# Answer
# , ~~57~~ 55 bytes

Or **\>=4.1, 48 bytes** by replacing the word `function` with `\`.

*-2 bytes thanks to @Dominic van Essen.*

```
function(A,t,r=which(A>=t)[1])r-((A-t)/diff(c(0,A)))[r]

```

Try it online!

1-indexed.

I couldn't make any built-in linear approximation work, but ~~it doesn't mean that such solution doesn't exist~~ @Dominic van Essen could.
> 3 votes

# Answer
# Haskell, 42 bytes

```
q 0
q p(h:r)t|h<t=1+q h r t|d<-h-p=(t-p)/d

```

Try it online!

Main function is `q 0`, outputs one-indexed.

**43 bytes**

```
l%t|let(h:r)?p|h<t=1+r?h|d<-h-p=(t-p)/d=l?0

```

Try it online!
> 3 votes

# Answer
# Charcoal, 25 bytes

```
ＩΣＥθ∧κ⌈⟦⁰⌊⟦¹∕⁻η§θ⊖κ⁻ι§θ⊖κ

```

Try it online! Link is to verbose version of code. Explanation: Port of @xnor's 64-byte Python solution.

```
   θ                        Input array
  Ｅ                         Map over elements
     κ                      Current index
    ∧                       Logical And
              η             Input value
             ⁻              Minus
               §θ⊖κ         Previous element
            ∕               Divided by
                    ι       Current element
                   ⁻        Minus
                     §θ⊖κ   Previous element
         ⌊⟦¹                Clamp above to 1
      ⌈⟦⁰                   Clamp below to 0
 Σ                          Take the sum
Ｉ                           Cast to string
                            Implicitly print

```
> 2 votes

# Answer
# Perl 5, 75 bytes

```
sub f{($t,$a,$b)=(@_,9e9);$a<=$t&&$t<=$b?($t-$a)/($b-$a):1+f(@_[0,2..$#_])}

```

Try it online!

Perl5 versions from 5.32 (TIO has 5.28) got chained comparisons capability which means `$a<=$t&&$t<=$b` can be shortened to `$a<=$t<=$b` and save 4 bytes.
> 2 votes

# Answer
# Ruby, 50 bytes

```
f=->l,n,z=0{a,*l=l;a<n ?1+f[l,n,a]:1.0*(n-a)/a-=z}

```

Try it online!
> 2 votes

# Answer
# C (clang), ~~74 71~~ 63 bytes

```
float r;f(*a,t){for(r=0;*a<t;r++)a++;r-=(*a-t)/(*a-*--a+1e-9);}

```

Try it online!

* Saved 3 thanks to @upkajdt suggestion to use a variable instead of printing it.
* Saved 5 thanks for @ths suggestion to make divisor ~0 by adding *1e-9* to it.
* Saved another 3 by using *float r* instead of *int n* as index counter.
> 2 votes

# Answer
# , 41 bytes

```
function(A,t)approx(B,seq(B<-c(A,0)),t)$y

```

Try it online!

Almost-trivial use of `approx` built-in: upvote pajonk's non-trivial R answer instead...
> 2 votes

# Answer
# Wolfram Language (Mathematica), 44 bytes

```
Sum[(i=0;{1/(#-i),x<=(i=#)}&/@#2),{x,#}]&

```

Try it online!

Input `[t, A]`. Returns 1-indexed.

The private-use character is `\[Piecewise]`, which is usually a less byte-efficient `If`/`Which`.
> 2 votes

# Answer
# Haskell, ~~76~~ ~~73~~ 71 bytes

```
s!x|(t,y:_)<-span(<x)s,u<-last$0:t=fromIntegral(length$t)-1+(x-u)/(y-u)

```

Try it online

(I hate explicit conversion (in golfing))
> 1 votes

# Answer
# Pip `-x`, 36 bytes

```
Yb>=_FIa#y-:$/(-[bMXy]+MN:b<=_FIa)|1

```

Takes the array and the number as command-line arguments. Attempt This Online!

### Explanation

```
Yb>=_FIa#y-:$/(-[bMXy]+MN:b<=_FIa)|1
       a                              Input array
     FI                               Filter for elements where
 b>=_                                 Input number is greater or equal
Y                                     Yank that list into y

                              FIa     Filter input array for elements where
                          b<=_        Input number is less or equal
                       MN:            Minimum such element
                      +               Plus
               -[    ]                Negative of each of these:
                 b                      Input number
                  MXy                   Max of y (elements <= b)
                                      We now have a list containing two distances:
                                      from the first element larger than b to b,
                                      and to the last element smaller than b
            $/(                  )    Divide the first by the second
                                  |1  If the result was 0 or division by 0,
                                      substitute 1 instead
          -:                          Subtract that result from
        #y                            Length of y (elements <= b)

```
> 0 votes

# Answer
# APL+WIN, 42 bytes

Prompts for vector followed by integer. 1 indexed.

```
(m/⍳↑⍴m)+(i-m/v)÷(m←<\(i←⎕)≤v)/v-¯1↓0,v←,⎕

```

Try it online! Thanks to Dyalog Classic
> 0 votes

# Answer
# Perl 5 \+ `-M5.10.0 -a`, 57 bytes

```
$_>"@F"&&$p<="@F"?say$.-3+("@F"-$p)/($_-$p):0,$p=$_ for<>

```

Try it online!

## Explanation

Naiive approach, but using some Perl var tricks.

`-a` stores the first input value (the target) in `@F` which, since we know will only be one value, we can access via `"@F"`. With this we can loop through all other lines of input (`for<>`) checking if we're greater than the current value and if the `$p`revious was less than of equal to the target and the current (`$_`) is greater than the target then we output (`say`) the current index (`$.` holds the current, 1-indexed, line of input being processed) plus the ratio of the differences between the current and previous, and previous and target.
> 0 votes

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


title: Recognize a Roboto Mono character

text:
# Question
Title: Recognize a Roboto Mono character
Your input will consist of an 18×18 image in any reasonable format, containing a horizontally and vertically centered 14px Roboto Mono character. This can be any of 94 printable ASCII characters (not including the space). But: **you only need to be able to recognize some 80 character subset** of your choice.

Output should be the character in the input image, as a character/string, code point, or some other reasonable representation.

To clarify input formats allowed, you can take input as an image in any reasonable representation, a matrix or array of pixels, or any other reasonable representation. You are allowed to assume the image will first be grayscaled or converted to black and white, and you can use that to, e.g., take input as a matrix of bools for white and black.

## Test cases

Since you choose a subset of printable ASCII to use, these may or may not need to be handled.

`N`, `0x4e`, `78`

`+`, `0x2b`, `43`

`z`, `0x7a`, `122`

`@`, `0x40`, `64`

## Other

You can find a `.zip` containing all 94 images here: png, pgm, pbm

This is , so shortest answer (in bytes) per-language wins.

# Answer
> 15 votes
# Python 3, 211 209 bytes

```
print("".join([")UUeG5W2jPfE-z@`od;,vlpBuF/D^Ym7Lk[]a%t}R'9>+6O_8gc=#!Z{SH~qCNyir3|xK$wn(J&T4?.Vs"[i]*(2**(0x1666a5a453070400d46a8119056156c0881a5746>>2*i&3))for i in range(81)])[sum(open(0,"rb").read())%203])

```

Reads a .rgba file from stdin and outputs the character to stdout. You can get the .rgba file with `convert input.png -depth 8 output.rgba`. The input is then hashed, by taking the sum of the byte values modulo 203. The long string and the large number are a compressed hash lookup-table.

Correctly recognizes every character except `"<MIA*1XbhO:Q\`

# Answer
> 12 votes
# Python 2, ~~150~~ ~~149~~ ~~147~~ ~~140~~ ~~136~~ 133 bytes

Takes the content of the *pbm* file as an argument.

```
lambda s:'Bf  R N  z (y !2VH:3 k9eMI7 CO;g[b#  8LGi n%u <"pEhW|_l  ,/ FJ?a10 DKo\'j*Z- $>s} ^xdm+)\{A@STv4Uwr`'[hash(s)%619914302%99]

```

Try it online! or Try the search program!

Incorrectly recognizes `&.56=PQXY]cqt~` as `kjdAm0|MMsiOyx`. I've searched for formulas of the form `hash(s)%a%b` for `a` up to the limit of signed 32-bit integers. To improve on this you probably need to use a different idea, maybe `hash(s+'...')%a%b` as suggested by dingledooper, or something involving other operations than moduli.

# Answer
> 11 votes
# Ruby `-p` \+ Tesseract (4.1.1), ~~50~~ ~~47~~ ~~35~~ 34 bytes

```
$_=`tesseract --psm 7 #$_ -`[/.$/]

```

Full program taking the name of a PNG file (terminated by EOF) from STDIN and printing the character to STDOUT. Somewhat fortuitously, exactly 80 characters are correctly identified:

```
"#%&'()*+,-.123456789;<=>?@ABDEFGHIJKMNPQRTUWXYZ[\]_abcdeghijkmnopqrstuvwxyz{|}~

```

The 14 characters not correctly recognised are:

```
input:  !$/0:CLOSV^`fl
output: t§I8fcb0sv“7F1

```

All the heavy lifting is done by Tesseract, a full-fledged OCR engine. The `--psm 7` option causes the input image to be treated as a single line of text. For this set of images, `--psm 7` gives the same results as the more appropriate but longer `--psm 10`, which enables single-character mode. (Strangely enough, the results differ for single-word mode, `--psm 8`.)

Tesseract returns a two-character string for some images (even with `--psm 10`); in these cases it turns out that the second character is correct slightly more often than the first. In the general case we therefore extract the last character before the linefeed.

---
Tags: code-golf, image-processing, classification, optical-char-recognition
---


title: Double-time is not double time

text:
# Question
Title: Double-time is not double time
Based on this challenge.

In the rhythm game osu!, the difficulty modifier "Double-time" actually only increases the speed by 50%.

Your task, is to write a program that outputs a positive *even* integer (higher than 0), and when each byte/character (your choice which) in your source code is duplicated, it should output the number multiplied by 1.5.

For example if your source code is `ABC` and that outputs 6, then `AABBCC` should output 9.

Following the original challenge's rules:

## Rules

* You must build a full program.
* The initial source must be at least 1 byte long.
* Both the integers must be in base 10 (outputting them in any other base or with scientific notation is forbidden).
* Your program must not take input (or have an unused, empty input) and must not throw any error (compiler warnings are not considered errors).
* Outputting the integers with trailing / leading spaces is allowed.
* You may not assume a newline between copies of your source.
* This is , so the fewest bytes **in each language** wins!
* **Default Loopholes** apply.

I imagine this will be far less trivial than the original challenge, but hopefully we'll see some creative and unique answers!

# Answer
> 22 votes
# Pylons, 7 5 4 bytes

Picked a random language on TIO used it

```
46vt

```

Explanation:

Try it Online!

```
46    # Stack is [4, 6]

v     # Reverse the stack [6, 4]

t     # take top of stack 4

```

Doubled:

```
4466   # Stack is [4, 4, 6, 6]

vv     # Reverse the stack twice so it's the same [4, 4, 6, 6]

tt     # take top of stack 6 and again which is 6 again

```

Saved 2 bytes thanks to *officialaimm*

Saved 1 bytes thanks to *Veedrac*

# Answer
> 21 votes
# Jelly, 2 bytes

```
!‘

```

Try it online!

Explanation:

```
!‘ Implicit 0
!  Factorial
 ‘ Increment

```

Doubled version:

```
!!‘‘

```

Try it online!

Explanation:

```
!!‘‘ Implicit 0
!    Factorial
 !   Factorial
  ‘  Increment
   ‘ Increment

```

# Answer
> 15 votes
# LibreOffice Calc, 8 bytes

```
=A2+3
19

```

Save it as `*.csv` and open it in LibreOffice Calc. You will get 22 in A1.

---

Double them:

```
==AA22++33

1199

```

You will get 33 in A1

# Answer
> 11 votes
# MATL, 3 bytes

```
TnQ

```

Try it online! Or doubled version.

### Explanation

In MATL a scalar value (number, char, logical value) is the same as a 1×1 array containing that value.

Normal version:

```
T    % Push true
n    % Number of elements of true: gives 1
Q    % Add 1: gives 2

```

Doubled version:

```
TT   % Push [true, true]
n    % Number of elements of [true, true]: gives 2
n    % Number of elements of 2: gives 1
Q    % Add 1: gives 2
Q    % Add 1: gives 3

```

# Answer
> 11 votes
## vim, 5

```
i1<esc>X<C-a>

```

Without doubling:

```
i1<esc>  insert the literal text "1"
X        delete backwards - a no-op, since there's only one character
<C-a>    increment, giving 2

```

With doubling:

```
ii11<esc>   insert the literal text "i11"
<esc>       escape in normal mode does nothing
XX          since the cursor is on the last character, delete "i1"
<C-a><C-a>  increment twice, giving 3

```

# Answer
> 10 votes
Not sure if this answer is valid. Just post here in case some one may got ideas from here.

# Node.js with -p flag, 7 bytes

By **Alex Varga**:

```
3/3*22

33//33**2222

```

# Node.js with -p flag, 11 bytes

**Old one:**

```
3*2*0/1+22

33**22**00//11++2222

```

Output 22 and 33.

# Answer
> 10 votes
# Python 2 REPL, 11 bytes

```
(3/1)*(2/1)

```

This simply evaluates to 3\*2=6. Duplicated, it is

```
((33//11))**((22//11))

```

which evaluates to 3\**2, which is 3 to the power of 2, or 9.

# Answer
> 8 votes
# APL, 7 bytes

```
⊃⍕⌊3×⍟2

```

Prints `2`.

```
⊃⊃⍕⍕⌊⌊33××⍟⍟22

```

Prints `3`.

Try it online!

### Waaat?

Single:

```
3×⍟2         → 2.079441542  ⍝  3 * ln 2
⌊2.079441542 → 2            ⍝  floor
⊃⍕           → '2'          ⍝  format and take first character

```

Double:

```
⍟⍟22          → 1.128508398  ⍝  ln ln 22
×1.128508398  → 1            ⍝ signum
33×1          → 33           ⍝  33 * 1
⌊⌊33          → 33           ⍝  floor
⊃⊃⍕⍕          → '3'          ⍝  format and take first character

```

# Answer
> 5 votes
# Actually, 3 bytes

```
1u*

```

Try it online!

Explanation:

```
1u* Errors are ignored
1   Push 1
 u  Increment
  * Multiply

```

Doubled version:

```
11uu**

```

Try it online!

Explanation:

```
11uu** Errors are ignored
1      Push 1
 1     Push 1
  u    Increment
   u   Increment
    *  Multiply
     * Multiply

```

# Answer
> 5 votes
# CJam, 4 bytes

```
],))

```

Try it normally!

Try it doubled!

### Explanation

Normal:

```
]     e# Wrap the stack in an array: []
 ,    e# Get its length: 0
  ))  e# Increment twice: 2

```

Double:

```
]         e# Wrap the stack in an array: []
 ]        e# Wrap the stack in an array: [[]]
  ,       e# Get its length: 1
   ,      e# Get the range from 0 to n-1: [0]
    )     e# Pull out its last element: 0
     )))  e# Increment 3 times: 3

```

# Answer
> 4 votes
# 05AB1E, 2 bytes

```
X>

```

Try it online!

Explanation:

```
X> Only top of stack is printed
X  Push X (default 1)
 > Increment

```

Doubled version:

```
XX>>

```

Try it online!

Explanation:

```
XX>> Only top of stack is printed
X    Push X (default 1)
 X   Push X (default 1)
  >  Increment
   > Increment

```

# Answer
> 4 votes
# Neim, 2 bytes

```
>

```

Try it online!

Explanation:

```
> Implicit 0
  Factorial
 > Increment

```

Doubled version:

```
>>

```

Try it online!

```
>> Implicit 0
    Factorial
    Factorial
  >  Increment
   > Increment

```

# Answer
> 3 votes
# Pyth, 3 bytes

```
he1

```

Try it here.

Explanation:

```
he1
h   Increment
 e   Last digit
  1   1

```

Doubled version:

```
hhee11

```

Try it here.

Explanation:

```
hhee11
h      Increment
 h      Increment
  e      Last digit
   e      Last digit
    11     11

```

# Answer
> 3 votes
# Ruby REPL, 8 bytes

```
";3#";22

```

The REPL only prints the last value evaluated: `22`.

Doubled:

```
"";;33##"";;22

```

This time `33` is the last value evaluated. The string is discarded once again, and a `#` starts a comment.

# Answer
> 3 votes
# Zsh, 14 bytes

```
<:|echo 22
3
:

```

Try it online!

Getting a full program in a non-golfing language to print anything with source code duplicated like this is a challenge. Zsh is very useful for this, because files and heredocs are implicitly passed to `cat`. Let's take a look at the first line in both cases:

```
<:|echo 22            # Give the file : on stdin to cat. cat pipes to 'echo 22', which ignores stdin
<<::||eecchhoo  2222  # Start heredoc on following lines with EOF string '::', pass to cat.
                      # Since cat exits 0, 'eecchhoo 2222' is not executed

```

So long as `3` is not a program, the first program will only print `22`. The second program will print `33` surrounded by extra newlines (due to the duplication).

---

If `3` is a function/program/alias, then this **18 byte** solution will still work!

```
<:|echo 22\\c\
3
:

```

Try it online!

The last `\` is line continuation, so the newline is discarded, effectively making the echo statement `echo '22\c3'`. The `\c` causes echo to stop printing after `22` (which also happens to suppress the newline).

# Answer
> 3 votes
# , ~~11~~ 6 bytes

```
1+7*!0

```

Try it online!

`!` is negation, and `**` is exponentiation (an alias for `^`). Numerics get converted to booleans: `0` to `FALSE`, all others to `TRUE`. Booleans get converted to integers: `FALSE` to `0`, `TRUE` to `1`, so `!0==1`, `!1==0`, `!!00==0` and `!!11==1`.

The single version thus computes \\$1+7\times 1=8\\$, and the double version computes \\$11+77^0=12\\$.

# Answer
> 2 votes
# \>\<\>, ~~19~~ 8 Bytes

```
32b*!{n;

```

Prints `22`
Try it online!

Explanation:

```
32b   push literals onto the stack: [3,2,11]
*     multiply the top two values: [3,22]
!     skip the next instruction
{     (skipped)
n     pop and print the top value from the stack (22)
;     end execution

```

### Doubled:

```
3322bb**!!{{nn;;

```

Prints `33`
Try it online!

Explanation:

```
3322bb push literals onto the stack: [3,3,2,2,11,11]
**     multiply top values (twice): [3,3,2,242]
!      skip next instruction
!      (skipped)
{{     rotate the stack to the left (twice): [2,242,3,3]
nn     pop and print the top two values from the stack (33)
;      end execution

```

Old Version:
~~Normal:~~

~~```
11+!vn;
    n
    ;

```
Prints `2`
Try it online!
Explanation:
```
1    push 1 on the stack: [1]
 1    push 1 on the stack: [1,1]
  +    add top two values of the stack: [2]
   !    skip the next instruction
    v    (skipped)
     n    print the top value of the stack (2)
      ;    end execution

```
Doubled:
```
1111++!!vvnn;;
        nn
        ;;

```
Prints `3`
Try it online!
Explanation:
```
1111    push four 1's on the stack: [1,1,1,1]
    +    add top two values of the stack: [1,1,2]
     +    add top two values of the stack: [1,3]
      !    skip the next instruction
       !    (skipped)
        v    change direction of execution (down)
         n    print the top value of the stack (3)
          ;    end execution

```~~

# Answer
> 2 votes
# Cubix, 6 bytes

```
O.1)W@

```

Prints `2`.

```
  O
. 1 ) W
  @

```

Pushes `1`, `)` increments, `W` jumps left to `O` which outputs `2`, and `@` finishes the program.

Doubled up, it's obviously `OO..11))WW@@`, which on a cube is:

```
    O O
    . .
1 1 ) ) W W @ @
. . . . . . . .
    . .
    . .

```

It pushes `1` twice, `)` increments twice, `W` jumps left again, which puts it at the right-hand `O` heading north, which outputs `3`, and then the next command is `@` which terminates the program.

Try it online!

Doubled online!

# Answer
> 2 votes
# Klein, ~~8~~ 6 bytes

```
/3+@4\

```

Single, Double

## Explanation

For the single the program follows a pretty straightforward path. The first mirror deflects it into the second which deflects it through the `4` to the end of the program.

The double is a little more complex. Here it is:

```
//33++@@44\\

```

The first two mirrors work the same, however there is a new mirror due to the doubling which deflects the ip back to the beginning, it is caught by the duplicate of the first mirror and deflected towards the end. All that is run is the `33++` which evaluates to 6.

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

Single:

```
int(√(8

```

The last expression is implicitly returned/printed in TI-Basic, so this prints `2`

Doubled:

```
int(int(√(√(88

```

Returns/prints 3

TI-Basic is a tokenized language; `int(`, `√(`, and `8` are each one byte in memory.

# Answer
> 2 votes
# Perl 6, 14 bytes

```
'|d 3#';say 22

```

Try it online! Try it doubled!

This uses the conveniently named debug function `dd` to output the doubled program to STDERR. To separate the logic we encase the doubled program in quotes, which then cancel each other out when doubled, along with a comment character `#` to comment out the now invalid normal program.

# Answer
> 2 votes
# Vyxal, 2 bytes

```
¡›

```

Try it Online!

Port of the Jelly answer.

```
   # (implicit zero)
¡  # Factorial
 › # Incremented

```

Doubled (Try it Online!):

```
¡    # 0 factorial = 1
 ¡   # 1 factorial = 1
  ›› # Incremented twice = 3

```

# Vyxal, 3 bytes

```
ðL›

```

Try it Online!

```
ð   # Space character
 L  # Length
  › # Incremented

```

Doubled (Try it Online!)

```
ðð     # Space character (one's a nop)
  LL   # Length twice (one's a nop)
    ›› # Incremented twice

```

# Answer
> 2 votes
# Hexagony, 6 bytes

```
))$$!@

```

Try it online! (Try it doubled!)

## Explanation

```
  ) )
 $ $ !
  @ .

```

This program does nothing too weird; it just executes each line in order:

* `))`: Increment twice (memory cell = `2`).
* `$$`: Jump the jump; basically a no-op.
* `!`: Print memory cell (`2`)
* `@`: Stop.

---

```
   ) ) )
  ) $ $ $
 $ ! ! @ @
  . . . .
   . . .

```

Only the first and third lines are executed, due to Hexagony's control flow:

* `)))`: Increment 3 times (memory cell = `3`).
* `)$$$`: This line is skipped.
* `$!`: Jump over the first `!`, so the memory cell isn't printed twice.
* `!`: Print `3`.
* `@`: Stop.

# Answer
> 1 votes
# Stax, 3 bytes

```
UJ^

```

Run and debug it

Run and debug the doubled one

`U` pushes -1. `J` squares. `^` increments.

# Answer
> 1 votes
# MathGolf, 2 bytes

```
▬)

```

Try it online! Try it doubled

Similar to other answers in that the first instruction produces a `1` even when doubled and the second increments it. In this case, I've used reverse exponentiation (`0**0 = 0**0**0 = 1`) but it also could have been any of the `!£≤°` instruction and perhaps even more that I missed.

# Answer
> 1 votes
# Deadfish~, 12 bytes

```
iis(ooh)iiio

```

Try it online!

Try it doubled!

## Explanation

```
iis(ooh)iiio

```

Set the accumulator to `2`, square it, print twice to get `44`, stop.

```
iiiiss((oooohh))iiiiiioo

```

Set the accumulator to 4 and square it twice to get 256.
Since Deadfish~ doesn't like the number 256, it sets the accumulator to 0 instead.
The `(...)` part of the code is ignored if the accumulator is 0, and then the rest of the code prints `66`.

# Answer
> 1 votes
# Perl 5 \+ `-M5.10.0 -MData::Dump+(dd)`, 17 bytes

```
q{\};d 3#};say 22

```

Try it online!

## Doubled

```
qq{{\\}};;dd  33##}};;ssaayy  2222

```

Try it online!

## Explanation

I was hopeful to find a way to trigger a `print` without using an external, but I couldn't come up with anything so I settled on `dd`.

The trick here was to leverage Perl's flexibly delimited strings to encase the doubled code without causing a syntax error. Using `{...}` (or any other pairs like`()`, `[]`, `<>`) means in the original code the end char can be escaped with a single `\` which when doubled is just a backslash. Using `q` is easiest as `qq` is just as valid.

```
q{\};d 3#};say 22

```

Here we have a short string containing `};d 3#`, then we just `say 22` which outputs 22.

```
qq{{\\}};;dd  33##}};;ssaayy  2222

```

Here we have a string containing a single `\` and then we `dd`ump out 33 and the rest of the program is commented out.

---

Now that I look through the other answers I see that @JoKing's answer would work as-is with my command line arguments too...

# Answer
> 0 votes
# Japt, 2 bytes

Another "factorial+1" solution.

```
ÊÄ

```

Test it

```
ÊÊÄÄ

```

Test it

# Answer
> 0 votes
# Octave, 1 byte

I think we all know this is a worthless answer. Gotta show Octave some love.

```
0

```

Try it online!

---
Tags: code-golf, source-layout
---