# Return the highest possible placement value based on the input

## Introduction

The challenge itself was something I came across and had to try and figure out for a personal of project of mine. I ended up branching out and asking family members if they could provide an equation to meet the requirements.

Note: I have (with the help of others) found a solution for this but now I'm just trying to see how others would approach this.

## Challenge

Take the following scenario where the left hand side number is N (the input):

N    Output
0 -> 9
1 -> 99
2 -> 999
3 -> 9999
4 -> 99,999
5 -> 999,999
...
15 -> 9,999,999,999,999,999


So, essentially, for an input number N, your program must provide the highest integer with N + 1 decimal places.

Note: Commas are not required to separate the numbers, I placed them above purely for readability.

## Criteria of Success

The criteria of success is based on the following:

• Shortest in terms of code size
• @Okx no, it has to be a single number. So 3 => 9999 and cannot be [9,9,9,9]. – Script47 Apr 29 '18 at 19:10
• Top of Hot Network Questions with a score of one. I'm thinking the idea about preventing HNQ when number of answers > score is a decent one. – CAD97 Apr 29 '18 at 21:01
• Someone should write an answer in 99, although I'm not sure how to do multiply/power in that esolang. ;) – Kevin Cruijssen Apr 30 '18 at 7:12
• You're getting a lot of downvotes because of the overly complicated explanation for what is, essentially, either print n+1 9s or print 10^n-1 – Jo King Apr 30 '18 at 12:41
• @Script47 It seems arbitrary to print N + 1 nines instead of just just N nines. – Adám Apr 30 '18 at 13:38

# Neim, 3 bytes

>9𝕣


Explanation:

>      Increment input
9𝕣    Repeat 9


Try it online!

• Holy moly, 3 bytes? That's insanity. – Script47 Apr 29 '18 at 19:17
• @Script Nothing surprising. Javascript/Python takes 3 builtins, this also takes 3 builtins. – user202729 Apr 30 '18 at 1:50

# 05AB1E, 3 bytes

### Code:

>°<


Uses the 05AB1E encoding. Try it online!

### Explanation:

>      # Increment the implicit input
°     # Compute 10 ** (input + 1)
<    # Decrement the result


# Proton, 11 bytes

(1+)+("9"*)


Try it online!

This is a function.

# Explanation

(1+)+("9"*)  Function
1+          Anonymous function; add the input to 1
"9"*   Anonymous function; multiply "9" by the input
+        Function Composition; add the input to 1 then multiply "9" by this number
(  ) (    )  Brackets for order of operations


:o proton beats python with its function composition for once :D

• Alternatives with same byte-count: ("9"*)+(+9) or ("9"*)+(9+). +(+n) prepends, +(n+) appends to the string ("9"*) which is the same as in @HyperNeutrino's answer above. – Kevin Cruijssen Apr 30 '18 at 10:05
• @KevinCruijssen Oh cool, thanks! I forgot that "9"+9 worked in Proton – HyperNeutrino Apr 30 '18 at 15:17

# J, 7 bytes

Anonymous tacit prefix function

9^&.>:]


Try it online!

9^] nine raised to the power of the argument

&.… while both nine and the argument are under the influence of

>: increment

I.e. increment nine and the argument, then power, then un-increment, i.e. decrement. Effectively ((9+1)^(n+1))-1.

• Also 7 bytes for output as a string: '9'$~>: – Galen Ivanov Apr 30 '18 at 6:36 • @GalenIvanov Sure, but this solution is way cooler :-) – Adám Apr 30 '18 at 8:40 • Of course, your solution is incomparably cooler. it's always a pleasure to use &. :) – Galen Ivanov Apr 30 '18 at 9:30 • @GalenIvanov Yes, I hope to get Under into APL next year, ⍢. – Adám Apr 30 '18 at 11:27 # APL+WIN, 9 5 bytes Thanks to ngn for -3 bytes and Adám for -1 byte Prompts for integer input: 1⎕/⍕9  • Save a byte with '9'⍕9. – Adám Apr 29 '18 at 23:18 • and another three with (1+⎕)⍴ -> 1⎕/ – ngn Apr 29 '18 at 23:35 • @ngn Very clever! – Adám Apr 30 '18 at 8:28 # 99, 90 bytes  999 9999 9 9 99999 99 9 9999 9 999 999 9999 9 99999 999 999 9 999999 999 9 9999  Try it online! Possibly not optimal, but it was fun to write. EDIT: looks like I was right, as Jo King outgolfed me by not incrementing the input and being smarter about the gotos.  999 assign input to tri-nine 9999 9 9 assign 0 to quad-nine 99999 99 9 9999 9 assign 81 to quint-nine for printing 999 999 9999 9 increment tri-nine 99999 print 81/nine (the numeral nine) 999 999 9 decrement tri-nine 999999 999 if tri-nine is zero exit program (goto outside program) 9 9999 else goto line nine  • Well done. Too bad the byte-count isn't 99 as well. ;p – Kevin Cruijssen Apr 30 '18 at 13:11 # 99, 69 bytes 9999 9 9 99999 99 9 9999 9 999 99999 99 999 999 999 9 9 9999  Try it online! Appropriate (but it's a pity that this didn't end up at 99 bytes) ### Explanation 9999 9 9 9999 = 9-9 99999 99 9 9999 9 99999 = 99-9+(9-9)-9 = 9*9 999 999 = input*9 Filler to get up to line 9 99999 Print (9*9)/9 as a number 99 999 Jump to line 99 if 999 is 9-9 999 999 9 999 = 999 - 9 9 9999 Jump unconditionally to line 9  • the number 9 now just looks weird to me. – Giuseppe Apr 30 '18 at 13:16 # Actually, 3 bytes u╤D  Explanation: u Increment input ╤ 10 ** x D Decrement  Try it online! # MATL, 6 bytes Q10w^q  Try it online! ### Explanation: Q % Grab input and increment by 1 10 % Push 10 w % Swap stack ^ % Raise 10 to the power of input+1 q % Decrement by 1  # Pyth, 4 *\9h  ### Explanation  Q # Implicit input h # Increment *\9 # Repeat string "9" n+1 times  • Nice, I got t^Th, also 4 bytes. – hakr14 Apr 30 '18 at 2:24 • I got *p\9 with length 4. pyth.herokuapp.com/… – NeverHopeless Apr 30 '18 at 14:13 • @NeverHopeless I see it works, but how? e.g. with input 4, I think this translates to print "9", 4 times; yet 5 "9"s are a printed? – Digital Trauma Apr 30 '18 at 15:50 • @DigitalTrauma, by enabling debugging I found that there are two print functions 'Pprint' and 'imp_print' in this statement imp_print(times(Pprint("9"),Q)) and it is written here: pyth.herokuapp.com/rev-doc.txt that p <any> Print A, with no trailing newline. **Return A**. So my understanding is that Pprint prints Q times and 'p' token return that character which is printed by 'imp_print' that is why it appears Q+1 times. – NeverHopeless May 2 '18 at 5:45 • @NeverHopeless Makes sene - thanks! – Digital Trauma May 2 '18 at 17:03 # dc, 8 A?1+^1-p  Try it online! ### Explanation A # Push 10 ? # Push input 1+ # Increment input ^ # Raise 10 to the (input + 1)th power 1- # Decrement p # Print  # Haskell, 14 13 bytes f n=10*10^n-1  Or for string output 15 bytes, f n='9'<$[0..n]

Thanks to @EsolangingFruit for a byte.

Try it online!

• f n=10*10^n-1 saves a byte. – Esolanging Fruit Apr 30 '18 at 4:13

# Zsh, 19 bytes

Zsh does a better job than Bash (needs eval):

printf 9%.s {0..$1}  Try it online! ### Alternative, 20 bytes This works for both Zsh and Bash (due to Digital Trauma): echo$[10**($1+1)-1]  Try it online! • Shorter for bash: echo$[10**($1+1)-1] – Digital Trauma Apr 30 '18 at 6:31 • @DigitalTrauma: Oh nice, works for Zsh as well (edited it in)! – ბიმო Apr 30 '18 at 8:19 # Python 3, 16 bytes lambda a:"9"*-~a  Try it online! Just a simple anonymous function. # JavaScript (Node.js), 18 bytes x=>"9".repeat(x+1)  Try it online! • Or alternatively n=>10**-~n-1 – Arnauld Apr 29 '18 at 19:42 • Though I never specified, it would be ideal to get it a int rather than a string. Nevertheless, good answer. – Script47 Apr 29 '18 at 21:30 • @Arnauld it seems that with with your code when n = 15 the output is 10000000000000000. – Script47 Apr 29 '18 at 21:32 • @Script47 JS can't support numbers greater than 9007199254740991. So, yes, it works up to n=14. – Arnauld Apr 29 '18 at 21:36 • Alternative to @Arnauld's version: n=>"10e"+n-1 – ETHproductions Apr 30 '18 at 2:37 # Jelly, 4 bytes ‘⁵*’  Try it online! ‘⁵*’ - Main link. Argument: n (integer) ‘ - n+1 ⁵* - 10 ** (n+1) ’ - (10 ** (n+1)) - 1  # Husk, 4 bytes R'9→  Try it online! R'9→ -- example input: 3 → -- increment: 4 R'9 -- replicate the character '9': ['9','9','9','9'] -- implicitly print "9999"  # Canvas, 3 bytes ╵9×  Try it here! ╵ increment the input 9 push "9" × repeat the "9" input+1 times  # Brain-Flak, 48 bytes ({}()){({}<(((((()()()){}()){}){}){}())>[()])}{}  Try it online! This uses the -A to enable ASCII output. Bonus round: A version without -A. # Brain-Flak, 50 bytes ({}(())){({}<((({})(({}){}){}){})>[()])}{}({}[()])  Try it online! # Momema, 21 bytes a00+1*0-8 9a=+*0-+1_A  Try it online! Requires the -i interpreter flag. ## Explanation A brief rundown of Momema's features: • Its only data type is the unbounded integer. It has a double-ended tape (indexed by unbounded integers) where every number is initialized to zero. • Strings of digits are integer literals which evaluate to themselves. Leading zeroes are parsed as their own integers. • +ab evaluates to the sum of a and b. • -a evaluates to the negation of a. • *a evaluates to the value of cell a on the tape. • =a evaluates to 0 if a evaluates to 0, and = otherwise. • At the top level, ab stores b at cell a on the tape. Attempting to write a number to -8 writes its decimal representation to STDOUT instead. • At the top level, [w]a (where [w] is any string of lowercase letters) acts like "relative jump forward by a jump instructions that share the label [w]." • The Momema reference implementation accepts a flag -i, which activates interactive mode. In interactive mode, _[W] (where [W] is any string of uppercase letters) is called a hole and evaluates to a number read from STDIN. However, it caches the number with its label, so if a hole with the same label is ever evaluated again it will be reused. Knowing this, here's how you expand this program: a 0 # do { 0 (+ 1 (* 0)) # n = n + 1 -8 9 # print 9 a (= (+ (* 0) (- (+ 1 _A)))) # while (n != input)  (This still parses, by the way; the Momema parser treats parentheses the same way as whitespace.) a 0  Jumps forward by 0 a instructions (i.e. does nothing). This is only here to serve as a jump target later. 0 (+ 1 (* 0))  Increments the value of cell 0 (initially 0) and stores it back in cell 0. -8 9  -8 is memory-mapped for numeric I/O, so this outputs 9 to STDOUT. a (= (+ (* 0) (- (+ 1 _A))))  Compute tape[0] - (input + 1). If it is zero (i.e. both sides were equal), then = maps the result to 0, making it a no-op. Control runs off of the end of the program. However, if it is nonzero, this is a 1. Since there are no a instructions after here, it wraps around to the beginning of the program. # brainfuck, 24 23 bytes thanks to Jo King for -1 byte -[++>+[+<]>]>+<,+[->.<]  Try it online! Takes input as ASCII • Most people wouldn't begrudge you removing that leading > – Jo King Apr 30 '18 at 7:50 • @JoKing The next time I should have a closer look while copying from the esolang page :). Thank you – ovs Apr 30 '18 at 7:54 # Whitespace, 79 bytes [S S S T S T S N _Push_10][S N S _Duplicate_10][S N S _Duplicate_10][S N S _Duplicate_10][T N T T _Read_STDIN_as_integer][T T T _Retrieve_input][N S S N _Create_Label_LOOP][S S S T N _Push_1][T S S T _Subtract][S N S _Duplicate][N T T S N _If_negative_Jump_to_Label_EXIT][S N T _Swap][S T S S T S N _Copy_2st][T S S N _Multiply][S N T _Swap][N S N N _Jump_to_Label_LOOP][N S S S N _Create_Label_EXIT][T S S S _Add][T N S T _Print_as_integer]  Letters S (space), T (tab), and N (new-line) added as highlighting only. [..._some_action] added as explanation only. Try it online (with raw spaces, tabs and new-lines only). Explanation in pseudo-code: Integer i = STDIN as integer Integer j = 10 Start LOOP: i = i - 1 If i is negative (-1): Go to function PRINT_AND_EXIT j = j * 10 Go to next iteration of LOOP function PRINT_AND_EXIT: j = j + i (Since i=-1 at this point, this is basically j = j - 1) Print j as integer Exit with error  Example run (n=4): Command Explanation Stack HEAP STDIN STDOUT STDERR SSSTSTSN Push 10 [10] SNS Duplicate top (10) [10,10] SNS Duplicate top (10) [10,10,10] SNS Duplicate top (10) [10,10,10,10] TNTT Read STDIN as integer [10,10,10] {10:4} 4 TTT Retrieve [10,10,4] {10:4} NSSN Create Label_LOOP [10,10,4] {10:4} SSSTN Push 1 [10,10,4,1] {10:4} TSST Subtract (4-1) [10,10,3] {10:4} SNS Duplicate top (3) [10,10,3,3] {10:4} NTTSN If neg.: Jump to Label_EXIT [10,10,3] {10:4} SNT Swap top two [10,3,10] {10:4} STSSTSN Copy 2nd [10,3,10,10] {10:4} TSSN Multiply (10*10) [10,3,100] {10:4} SNT Swap top two [10,100,3] {10:4} NSNN Jump to Label_LOOP [10,100,3] {10:4} SSSTN Push 1 [10,100,3,1] {10:4} TSST Subtract (3-1) [10,100,2] {10:4} SNS Duplicate top (2) [10,100,2,2] {10:4} NTTSN If neg.: Jump to Label_EXIT [10,100,2] {10:4} SNT Swap top two [10,2,100] {10:4} STSSTSN Copy 2nd [10,2,100,10] {10:4} TSSN Multiply (100*10) [10,2,1000] {10:4} SNT Swap top two [10,1000,2] {10:4} NSNN Jump to Label_LOOP [10,1000,2] {10:4} SSSTN Push 1 [10,1000,2,1] {10:4} TSST Subtract (2-1) [10,1000,1] {10:4} SNS Duplicate top (1) [10,1000,1,1] {10:4} NTTSN If neg.: Jump to Label_EXIT [10,1000,1] {10:4} SNT Swap top two [10,1,1000] {10:4} STSSTSN Copy 2nd [10,1,1000,10] {10:4} TSSN Multiply (1000*10) [10,1,10000] {10:4} SNT Swap top two [10,10000,1] {10:4} NSNN Jump to Label_LOOP [10,10000,1] {10:4} SSSTN Push 1 [10,10000,1,1] {10:4} TSST Subtract (1-1) [10,10000,0] {10:4} SNS Duplicate top (0) [10,10000,0,0] {10:4} NTTSN If neg.: Jump to Label_EXIT [10,10000,0] {10:4} SNT Swap top two [10,0,10000] {10:4} STSSTSN Copy 2nd [10,0,10000,10] {10:4} TSSN Multiply (10000*10) [10,0,100000] {10:4} SNT Swap top two [10,100000,0] {10:4} NSNN Jump to Label_LOOP [10,100000,0] {10:4} SSSTN Push 1 [10,100000,0,1] {10:4} TSST Subtract (0-1) [10,100000,-1] {10:4} SNS Duplicate top (-1) [10,100000,-1,-1] {10:4} NTTSN If neg.: Jump to Label_EXIT [10,100000,-1] {10:4} NSSSN Create Label_EXIT [10,100000,-1] {10:4} TSSS Add (10000+-1) [10,99999] {10:4} TNST Print as integer [10] {10:4} 99999 error  Stops program with error: No exit defined. # Japt, 5 4 bytes °Uî9  Try it online! Shaved off that one byte thanks to Shaggy's clever eyes. You can see the edit history for a number of 5-byte solutions. • 4 bytes: °Uî9 – Shaggy Apr 29 '18 at 23:35 • @Shaggy Nice! You should post it as an answer. – Nit Apr 30 '18 at 4:50 • It's just a variation on your first solution so work away. Also, I have a 3 byte solution to post after lunch. – Shaggy Apr 30 '18 at 12:13 # AWK, 26 bytes {for(;a++<$1;){printf"9"}}


Try it online!

# Julia, 14 bytes

f(n)="9"^(n+1)

That's if the result can be a string.

# SNOBOL4 (CSNOBOL4), 30 bytes

	OUTPUT =DUPL(9,INPUT + 1)
END


Try it online!

# Gol><>, 5 bytes

PR9H


Try it online!

This is a Gol><> function which takes the stack content as input.

### Example full program & How it works

1AG9G
PR9H

1AG    Register row 1 as function G
9G  Call G with stack [9]

P      Increment
R9   Push char '9' that many times
H  Print the stack content as chars and halt


# TI-Basic, 7 bytes

10^(Ans+1)-1


Fairly straightforward...

• Yeah, no idea why this got flagged. – Stephen Leppik Apr 30 '18 at 1:21
• @Ste Blame SE automatic bots. Why must answers here have explanation? – user202729 Apr 30 '18 at 1:57

# CJam, 6 bytes

qi)'9*


Try it online!

# Perl 5, 7 bytes

$_=9x$_
`

Try it online!

• You don't need the quotes there. Try it online! – Xcali Apr 30 '18 at 1:03
• Good spot, thx. – steve Apr 30 '18 at 5:14