# Introduction

I have an even number of bottles, all of different sizes. Unfortunately, I only know the size of the smallest bottle: 300ml.
I also know the following:

• Half of the bottles are twice the size of the other half, meaning that the smallest small bottle and the smallest large bottle are in a ratio of 2:1.
• The smaller bottles, from smallest to largest, increase in size by n%, where n is the number of bottles multiplied by 3.

Could you help find what sizes my bottles are?

# Challenge

Your input is to be an even number of bottles.
The output should be the size of all of the small bottles (from smallest to largest), then all of the large bottles (from smallest to largest).

# Example I/O

In: 2
Out: 300, 600

In: 4
Out: 300, 336, 600, 672

In: 10
Out: 300, 390, 507, 659.1, 856.83, 600, 780, 1014, 1318.2, 1713.66

(Note: commas are unnecessary; this answer can be formatted in any way you want as long as all of the "small" bottles come before the "large" bottles.)

# Rules

Standard loophole rules apply.
This is , so shortest answer in bytes wins!

# Winners

Esoteric Languages
15 bytes
05AB1E by Kevin Cruijssen

Standard Languages
36 bytes
Mathematica by attinat

• In the third testcase, does it mean 856.83 is smaller one but 600 is larger one? It is confusing.
– tsh
Nov 12, 2019 at 10:38
• Yes - the size of "smaller" bottles can be larger than the "larger" bottles. Nov 12, 2019 at 10:39
• Essentially, the first half of your output should be the "smaller" bottles, and the second half should be the "larger" bottles. Nov 12, 2019 at 10:40
• Doesn't "(at least referring to bottles)" make the title even worse when you think about it? Nov 12, 2019 at 12:50
• Let's not go there. Nov 12, 2019 at 13:40

# Python 2, 6160 59 bytes

lambda n:[a*(1+.03*n)**i*75for a in 4,8for i in range(n/2)]


Try it online!

-1 byte, thanks to Joseph Sible

• It confuses me that you've managed to get [300.0, 336.00000000000006, 600.0, 672.0000000000001]. Where did the extra 0's come from? Nov 12, 2019 at 10:57
• That's floating point precision for you.. Nov 12, 2019 at 10:59
• @Corsaka That's caused by the same thing that makes many languages say 0.1 + 0.2 != 0.3 is true Nov 12, 2019 at 16:26
• -1 byte: use 75, 4, and 8 in place of 100, 3, and 6. Nov 12, 2019 at 21:40
• @JosephSible Thanks :) Nov 13, 2019 at 15:59

# Wolfram Language (Mathematica), 36 bytes

{#,2#}&[300(1+.03#)^Range[0,#/2-1]]&


Try it online!

# 05AB1E, 15 bytes

₆v;F.03*>NmyтP,


Port of @TFeld's Python 2 answer, so make sure to upvote him.

Explanation:

₆                # Push builtin integer 36
v               # Loop y over both digits:
;              #  Halve the (implicit) input-integer
F             #  Inner loop N in the range [0, input/2):
.03*         #   Multiply the (implicit) input by 0.03
#   (alternative 4-byter: т/3* # divide by 100, multiply by 3)
>        #   Increase this by 1
Nm      #   Take it to the power N
yт    #   Push both y and 100
P   #   And take the product of the entire stack
,  #   Then pop and print this number with trailing newline

• Wait, 05AB1E has floating-point literals‽ I always assumed this wouldn't work, since . is used for extended commands. Nov 12, 2019 at 15:57
• Here's another 15, another 15, and yet another one. There are lots of possible approaches, but I'm not finding anything shorter. Nov 12, 2019 at 16:24
• @Grimmy The new version of 05AB1E indeed had floating point literals :) In the legacy version this wasn't available yet, but it's something new Adnan added in the rewrite. Nov 12, 2019 at 21:39

# Jelly, 16 bytes

×.03‘*HḶ$×300;Ḥ$


Try it online!

-2 bytes thanks to Nick Kennedy

# Explanation

×.03‘*HḶ$×300;Ḥ$  Main Link
×.03              Multiply the number of bottles by 3%
*            (Vectorized) exponent to the power of:
HḶ$[0, 1, ..., n-1] ×300 Multiply each factor by 300 ;Ḥ$  Double the list and append it

• ×.03 saves two bytes. Nov 12, 2019 at 14:58
• @NickKennedy Thanks! Nov 12, 2019 at 15:14

f n=[75*a*(1+0.03*n)**i|a<-[4,8],i<-[0..n/2-1]]


Try it online!

# Julia 1.0, 42 38 bytes

f(n,z=[75*(1+.03n).^(0:n÷2-1)])=4z,8z


-4 bytes using ideas from John and Joseph Sible.

Try it online!

# Python 2, 55 bytes

n=input()/2
for c in 4,8:exec"print c*75;c*=1+.06*n;"*n


Try it online!

The *75 trick is taken from other answers.

# JavaScript (Node.js), 63 bytes

f=(n,b=300,r=1+n*9/b,h=n/2)=>n?[b,...f(n-1,--h?b*r:600,r,h)]:[]


Try it online!

• 59 bytes Nov 12, 2019 at 11:29
• 57 bytes Nov 12, 2019 at 11:37
• 55 bytes, expanding on @Arnauld's improvements. Nov 12, 2019 at 12:08
• @Arnauld Maybe you could post as another answer. It is different enough as another answer, imo.
– tsh
Nov 13, 2019 at 2:58
• @Arnauld And use the idea from here, it is 54 bytes
– tsh
Nov 13, 2019 at 3:01

# PHP, 70 62 bytes

for($s=300;$i++<$n=$argn;$s=$n/2-$i?$s+$s*$n*.03:600)echo$s,_;  Try it online! Output numbers are seperated by _. Alternative for $s+$s*$n*.03 can be $s*=1+$n*.03 too, but both are same length.

• I'm getting errors with this one. Seems to be complaining that i was never defined Nov 12, 2019 at 13:42
• @Corsaka those are warnings or notices in stderr and are totally fine. Nov 12, 2019 at 15:46

# PowerShell, 66 54 bytes

-12 bytes thanks to mazzy

param($n)300,600|%{$y=$_;1..($n/2)|%{$y;$y*=1+\$n*.03}}


Try it online!

• 54 bytes Nov 12, 2019 at 17:52
• @mazzy breaks on the last test case. The last Small Bottle (856.83) is larger than the first Big Bottle (600) Nov 12, 2019 at 18:01
• oO! thanks. Very strange comment "the size of "smaller" bottles can be larger than the "larger" bottles". Ok. Another 54 bytes Nov 12, 2019 at 18:04

# Icon, 60 58 bytes

procedure f(n)
write(!36*(1+.03*n)^(0to n/2-1)*100)&\z
end


Try it online!

Saved 2 bytes by replacing (3|6)(alternate 3 with 6) with !36. !generates the components of a data object. When applied to a number it generates its digits. In Unicon - the descendent of Icon - !n generates the numbers in the range 1..n.

• What's the point of \z? TIO doesn't understand it. Nov 12, 2019 at 13:43
• @Corsaka 3|6 and 0to n/2-1 are generators and normally I would write every write((3|6)*...). Icon have a bactracking mechanism though and when an expression fails, it backtracks to fetch another value from the preceding generator(s). \z checks if the value z is non-null and since z is not present (declared), it backtracks until the 2 generators are exhausted. Nov 12, 2019 at 13:49
• @Corsaka TIO only complains that I use a variable that is not declared. Here I declared the variable n in the main procedure and it stopped compaining about n, only z remained. Nov 12, 2019 at 13:52

# Ruby, 57 53 bytes

->n{n.times.map{|a|300*(1+a*2/n)*(1+0.03*n)**a%=n/2}}


Try it online!

• -1 byte: use 75, 4, and 8 in place of 100, 3, and 6. Nov 12, 2019 at 21:43
• Thanks, but I've found a better way.
– G B
Nov 12, 2019 at 22:36

# K (oK), 32 bytes

{s,2*s:(-1+x%2)((1+.03*x)*)\300}


Try it online!

# Charcoal, 23 bytes

ＮθＦ²Ｅ⊘θＩ××³⁰⁰⊕ιＸ⊕×θ·⁰³κ


Try it online! Link is to verbose version of code. Outputs each list element on a separate line. Explanation:

Ｎθ


Input n

Ｆ²


Loop i twice, once for the small sizes, once for the large sizes.

Ｅ⊘θ


Loop k over half of the number of bottles, and implicitly output each calculation on its own line.

Ｉ××³⁰⁰⊕ιＸ⊕×θ·⁰³κ


Calculate 300(i+1)(.03n+1)ᵏ and cast the result to string.

# Forth (gforth), 84 bytes

: x dup 2/ 0 do fdup f. fover f* loop ; : f dup s>f .03e f* 1e f+ 3e2 x 6e2 fnip x ;


Try it online!

### Code Explanation

\ helper function to extract out common logic from the small and large numbers
: x               \ start a new word definition
dup 2/          \ duplicate the input and divide by 2
0 do            \ loop from 0 to n/2
fdup f.       \ print the top of the floating point stack
fover f*      \ multiple the top float stack value by the 2nd float stack value
loop            \ end the loop
;

: f               \ start a new word definition
dup s>f         \ duplicate n and place a copy on the float stack
0.03e f*        \ multiple by 0.03 (multiply by 3 and divide by 100)
1e f+           \ add 1 to get our increase multiplier
3e2 x           \ print the smaller numbers by starting with 300
6e2 fnip x      \ drop the remaining small number and print the large numbers from 600
;                 \ end word definition


# Pyth, 23 bytes

Fk2Fb/Q2*300*hk^h*.03Qb


Try it online!

Port of @TFeld's answer, which I was able to make decently concise. Cant help but feel like there's a more clever answer with Pyth but I wasnt able to find it.

## How it Works

Fk2Fb/Q2*300*hk^h*.03Qb
Fk2                     - For k in range(2)
Fb/Q2                - For b in range(input/2)
*300*hk         - 300 times k+1 times...
h*.03Q  - 1 + 0.03 times input
^      b - The above to the exponent b
Implicitly prints the result


# Wolfram Language (Mathematica), 40 bytes

Two independent 40-byte answers: the first is an unnamed function, the second is a named function g, both taking one argument.

Table[300i(1+.03#)^j,{i,2},{j,0,#/2-1}]&

g@n_:=300#(1+.03n)^(#2-1)&~Array~{2,n/2}


# R, 46 bytes

x=scan();b=300*(1+0.03*x)^(0:(x/2-1));c(b,b*2)


Try it online

# Java 8, 89 bytes

n->{for(int k=0,i;++k<3;)for(i=0;i<n/2;)System.out.println(Math.pow(.03*n+1,i++)*k*300);}


Port of @TFeld's Python 2 answer, so make sure to upvote him.

Try it online.

Explanation:

n->{                              // Method with integer parameter and no return-type
for(int k=0,i;++k<3;)           //  Loop k in the range (0,3) (basically [1,2]):
for(i=0;i<n/2;)               //   Inner loop i in the range [0, i/2):
System.out.println(         //    Print with trailing newline:
Math.pow(.03*n            //     n multiplied by 0.03
+1               //     incremented by 1
,i++)          //     to the power i
*k*300);} //     multiplied by k and 300


# Wren, 79 bytes

Fn.new{|n|
for(a in[300,600])for(i in 1..n/2){
System.print(a)
a=a+a*n*0.03
}
}


Try it online!

# Wren, 81 bytes

TField answer turns out to be longer.

Fn.new{|n|
for(i in 0...n/2)for(a in[3,6])System.print(a*(1+0.03*n).pow(i)*100)
}


Try it online!

# Japt, 27 23 bytes

_+3/L*Z*U}hUz
cUmÑ


Try it

_+3/L*Z*U} // function returning next element
hUz // runs the above func. U/2 times, starting from 300
cU®Ñ // concat the array obtained with the array multiplied * 2


Saved 4 thanks to @Shaggy

• 23 bytes Nov 14, 2019 at 16:19
• #Ĭ == 300 in terms of bytes! Lol Nov 14, 2019 at 19:22
• yup. But you save a byte by avoiding UTF encoding, where Ñ is 2 bytes. Nov 14, 2019 at 23:26

# C (gcc), 79 74 77 bytes

78 if the dash in compile arg is ignored. Port of TField answer. Increase in bytes is to comply with rules.

-5 bytes thanks to ceilingcat and bznein

b;c;f(a){for(b=0;++b<3;c=0)while(c<a/2)printf("%f ",pow(.03*a+1,c++)*b*300);}


Try it online!

• You can also replace for(;c<a/2;) with while(c<a/2) Nov 13, 2019 at 10:19
• Is it required for the function to be able to be called multiple times? Nov 14, 2019 at 4:44
• Yes Nov 14, 2019 at 17:06

# Husk, 20 bytes

S+mDmo*300^→*.03¹ŀ½
`

Try it online! A port of the standard answer.