# What is my volume?

Given an input integer, output the volume corresponding to the value. The value will always be in the range $$\[0,100]\$$.

## Examples

If the input $$\=0\$$:

 _/|
|  |\/
|_ |/\
\|


If the input $$\>0\$$ and $$\<33\$$:

 _/|
|  |\
|_ |/
\|


If the input $$\\ge33\$$ and $$\<66\$$:

 _/| \
|  |\ \
|_ |/ /
\| /


If the input $$\\ge66\$$, $$\\le100\$$:

 _/| \ \
|  |\ \ \
|_ |/ / /
\| / /


## Rules

• Input/output can be given by any convenient method.
• You can print it to STDOUT or return it as a function result.
• Either a full program or a function are acceptable.
• Any amount of extraneous whitespace is permitted, provided the characters line up appropriately.
• Standard loopholes are forbidden.
• This is so all usual golfing rules apply, and the shortest code (in bytes) wins.
• You should have based the volume on 0 - 10 so that someone could answer with "mine goes to 11" Nov 14 '19 at 13:35

# JavaScript (ES6), 98 bytes

n=> _/|2
|  |\\0
|_ |/1
\\|3.replace(/\d/g,k=>n?(k&1?' /':' \\').repeat(n/33^n>98):['/\\'[k]])


Try it online!

### How?

We use the following template:

 _/|2
|  |\0
|_ |/1
\|3


If $$\n=0\$$ (volume muted):

• $$\0\$$ is replaced with / and $$\1\$$ is replaced with \
• the other digits are removed

If $$\n\neq 0\$$:

• odd digits are replaced with the string " /" repeated $$\k\$$ times
• even digits are replaced with the string " \" repeated $$\k\$$ times

where $$\k\$$ is defined as:

$$k=\cases{\left\lfloor n/33\right\rfloor&\text{n<99}\\ 2&\text{n\ge 99} }$$

• for 99 and 100, output has an unnecessary line Nov 8 '19 at 13:28
• @NahuelFouilleul Thanks for reporting this. Now fixed. Nov 8 '19 at 13:49

# 05AB1E, 65 64 bytes

„ /SõD‚„\ Â‚D4δ∍D)T•4aÖ™é•“| 0\


When I started I thought I would be able to make this pretty short with the approach I had in mind, but it had some annoying edge cases to fix.. Can definitely be golfed, though. Will take another look later on.

Explanation:

„ /              # Push string " /"
S             # Convert it to a list of characters: [" ","/"]
õD‚              # Push an empty string "", duplicate it, and pair them together: ["",""]
„\               # Push string "\ "
Â             # Bifurcate it (shorter for duplicate and reverse copy)
‚            # Pair them together: ["\ ","\ "]
D                # Duplicate it
4δ∍             # Extend both inner strings to size 4: ["\ \ ","\ \ "]
D                # Duplicate it
)                # Wrap all lists on the stack into a list:
#  [[" ","/"],["",""],["\ ","\ "],["\ \ ","\ \ "],["\ \ ","\ \ "]]
T                # Push 10
•4aÖ™é•          # Push compressed integer 17523821317
“| 0\
1/“              # Push string "| 0\\n1/"
Åв            # Convert the integer to custom base-"| 0\\n1/"
J           # And join these characters together to a single string:
#  "  /| 1\n
#   |  |\0"
r                # Reverse the items on the stack (list, 10, string to string, 10, list)
I33÷            # Push the input, and integer-divide it by 33
IĀ          # Push the input again, and truthy it (0 if 0; else 1)
+         # And add them together (0→0; 1..32→1; 33..65→2; 66..98→3; 98..100→4)
©        # Store it in variable ® (without popping)
è       # And index it into the list we created at the start
‡      # Then transliterate the ["1","0"] of 10 to the strings in this pair
∊                # Now vertically mirror the entire string
#  (i.e. "  /|  \n
#         |  |\/" becomes:
#   "  /|  \n
#    |  |\/\n
#    |  |/\\n
#      \|  "
•/Tδ•        # Push compressed integer 7095187
₂в      # Converted to base-26 as list: [15,13,17,21,21]
®     # Push variable ® again
è    # Index it into this list
1         ‚   # Pair it with a leading 1
'_           ǝ '# And insert a "_" at those 0-based positions inside the string
# (after which the result is output implicitly)


See this 05AB1E tips of mine (section How to compress large integers? and How to compress integer lists?) to understand why •4aÖ™é• is 17523821317; •/Tδ• is 7095187, and •/Tδ•₂в is [15,13,17,21,21].

# Python 2, 111101 90 bytes

n=input()
for s in'\ _/|','\|  |\/','/|_ |/\\','/  \|':print s[1:6+0**n],s[:n>32],s[:n/66]


Try it online!

-11 bytes, thanks to xnor

• Nice method! I found a way to shorten it by encoding b in the first character of each string rather than as a zip, and extracting from there: Try it online!
– xnor
Nov 9 '19 at 5:38
• @xnor Wow nice! Thanks :) Nov 10 '19 at 7:49

# Lua, 308 259 246 242 219 180 bytes

i=io.read("*n")
print(i<1 and[[ _/|
|  |\/
|_ |/\
\|]]or i<33 and[[ _/|
|  |\
|_ |/
\|]]or i<66 and[[ _/| \
|  |\ \
|_ |/ /
\| /]]or[[ _/| \ \
|  |\ \ \
|_ |/ / /
\| / /]])


Try it online!

New to code golf and coding in general.
Thanks to all comments for their help!

• Hey, quick tip: the input is guaranteed to be within $[0, 100]$ so you don't need to check that it is less than 101. Also your third line doesn't appear to be necessary. Nov 8 '19 at 14:44
• Third line? Edited now so may be different, but all were necessary excluding the 100/0 input check.. Nov 8 '19 at 14:48
• yes my comment was made before your edit :) Anyways, you are still unnecessarily checking for $i<101$, when it is guaranteed that $i<101$. Nov 8 '19 at 14:51
• You can replace i==0 with i<1 Nov 9 '19 at 17:25
• also use [[long strings like this to not escape \ and newlines]]
– LMD
Nov 9 '19 at 18:43

# PowerShell, 113 bytes

param($n)' _/|'+($y=' \'*($x=($n-ge33)+($n-ge66))) '| |\'+($y,'/')[!$n] '|_ |/'+(($z=' /'*$x),'\')[!$n]
"  \|$z"  Try it online! # Perl 5 (-p), 86 bytes inspired from @Arnauld's solution $_=' _/|3
|  |\\1
|_ |/0
\|2'=~s,\d,$_?"$&"x($_/33-$_/99):$&<2&&$&^1,ger;y;0213;//\


Try it online!

# PowerShell, 94 92 bytes

param($n)33,66-le$n|%{$y+=' \';$z+=' /'}
" _/|$y | |\$y"+'/'*!$n "|_ |/$z"+'\'*!$n " \|$z"


Try it online!

# Canvas, 3227 26 bytes

┤＃Mi‾‟⁸？⁸‾｛÷ｕ２ｍ２＼×＋］ ¶/＋｝═


Try it here!

# Charcoal, 40 bytes

ＮθＦ AＦ›θ℅ι \Ｃ¹¦¹⸿\Ｆ¬θ/‖Ｍ↓⸿←Ｐ↑⁴←↖¹←_↑² _/


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

Ｎθ


Input the volume.

Ｆ AＦ›θ℅ι \


Output a space and a \ for each character ordinal in space and A that the volume is greater than. In other words, output once for inputs of 33 or more and twice for inputs of 66 or more.

Ｃ¹¦¹


Copy the \s one square diagonally.

⸿\


Output an extra \ at the start of the second line.

Ｆ¬θ/


If the volume was zero then add a /.

‖Ｍ↓


Reflect to complete the volume.

⸿←Ｐ↑⁴←↖¹←_↑² _/


Draw the speaker symbol.

# Keg, -hd 167 bytes

¿:0=[ _/|\n|  |\\/\n|_ |/\\\n  \\||:1\!"∂[ _/|\n|  |\\\n|_ |/\n  \\||:\!B"∂[ _/| \\\n|  |\\ \\\n|_ |/ /\n  \\| /| _/| \\ \\\n|  |\\ \\ \\\n|_ |/ / /\n  \\| / /


Try it online!

Definitely golfable by using variables and string formatting. That's what Imma go do now. Anyhow, it acts as a sort of switch statement to determine which range the volume is in and prints the corresponding string.

Nevermind. Variables only make the program longer.

# Python 3, 109 bytes

lambda n:'\n'.join(i[:5+0**n]+(n//33*(' '+j))[:4]for i,j in zip([' _/|','|  |\\/','|_ |/\\','  \|'],'\\\//'))


Try it online!

# Lua, 196 bytes

i=tonumber(io.read())
t=[[ _/|%s
|  |\%s
|_ |/%s
\|%s]]
t=(i==0 and t:format("","/","\\","")) or t
while i>=33 do t=t:format(" \\%s"," \\%s"," /%s"," /%s");i=i-34 end
t=t:gsub("%%s","")
print(t)


Try it online!

A bit shorter (below 200) than the other Lua answer.