New answers tagged number
0
votes
How Many Paint Tins Do I Need?
MathGolf, 3 bytes
*́
Inputs (as floats) in the same order as the challenge description: \$length,height,coverage\$.
Try it online.
Explanation:
...
0
votes
How Many Paint Tins Do I Need?
05AB1E, 3 bytes
/*î
Inputs in the order \$coverage,length,height\$.
Try it online or verify all test cases.
Explanation:
...
-1
votes
Convert real numbers between factoradic and positive integer bases
I got the same problems as you
0
votes
How Many Paint Tins Do I Need?
ARBLE, 11 bytes
ceil(l*h/c)
Not the most imaginative answer.
Arguments as coverage, height, length
Try it online!
1
vote
How Many Paint Tins Do I Need?
Google Sheets, 18 bytes
=roundup(A1*B1/C1)
Put the input in cells A1:C1.
In Microsoft Excel, ...
2
votes
4
votes
How Many Paint Tins Do I Need?
Vyxal 3, 3 bytes
÷×⌈
Try it Online!
Similar to most other answers. Divide by coverage, multiply by other dimension, take ceiling.
4
votes
How Many Paint Tins Do I Need?
APL (Dyalog Classic), 3 bytes
⌈÷/
Try it online!
Written as a tacit function that takes a vector with entries length, coverage, and height, in that order.
...
5
votes
How Many Paint Tins Do I Need?
Jelly, 3 bytes
P÷Ċ
A monadic Link that accepts the dimensions on the left and the paint tin coverage on the right and yields the number of tins required.
Try it ...
1
vote
Convert real numbers between factoradic and positive integer bases
Jelly, 94 93 bytes
⁹1!ḍ@¥1#ḢR;!:¥ɗU×1¦%Ḣd¥\FḊU
:1!>¥1#Ḣ’!€Ɗ;ƲUṪd¥\FḊ,ç
ḅç/
ẈḶ!U×¥:@ƭ€FṀ$©$ḋ⁸S;®:g/$b
A⁵ŀ⁹×1¦ṠFḢɗ
Try it online!
Test suite
A full program taking ...
0
votes
German pharmacy payment
*><>, 90 89 bytes
-1 byte by removing a semicolon that shouldn't have been there
I'm still trying to condense it using the dive u and rise ...
2
votes
3
votes
How Many Paint Tins Do I Need?
Retina 0.8.2, 39 bytes
.+
$*
1(?=1*¶(1+)¶)
$1
(1+)(?=1*¶1+¶\1)
Try it online! Takes input on separate lines but link is to test suite that splits on commas for ...
3
votes
How Many Paint Tins Do I Need?
Charcoal, 8 bytes
I±÷×NN±N
Try it online! Link is to verbose version of code. Explanation: Port of @SevC_10's Python answer.
...
3
votes
2
votes
0
votes
3
votes
3
votes
How Many Paint Tins Do I Need?
Python 3.8 (pre-release), 25 23 bytes
lambda l,h,c:-(-l*h//c)
Try it online!
Edit
-2 bytes thanks to Neil
2
votes
How Many Paint Tins Do I Need?
PowerShell, 40 bytes
param($l,$h,$c)[math]::Ceiling($l*$h/$c)
Try it online!
Thanks Julian!
PowerShell, 47 bytes
...
2
votes
3
votes
How Many Paint Tins Do I Need?
APL+WIN, 6 bytes
Prompts for three numbers. Coverage followed by wall dimensions:
⌈⎕×⎕÷⎕
Try it online! Thanks to Dyalog Classic
5
votes
How Many Paint Tins Do I Need?
Uiua, 4 3 bytes
⌈×÷
Try it!
-1 thanks to alephalpha
Takes input in the order coverage length height
...
3
votes
How Many Paint Tins Do I Need?
JavaScript (Node.js), 22 bytes
(a,b,c)=>(a*b+c-1)/c|0
Try it online!
JavaScript (Node.js), 20 bytes suggested by Arnauld
...
1
vote
Sum of all integers from 1 to n
bc, 9 bytes
n*(n+1)/2
Try it online!
Weird how some shell solutions call bc instead of just writing ...
4
votes
German pharmacy payment
APL (Dyalog Unicode), 13 bytes
2⍕⊢⌊10⌊5⌈.1×⊢
Try it online!
Tacit prefix function. Takes input as number.
Thanks to Graham for original APL solution.
How it works:...
0
votes
German pharmacy payment
Rust, 50 bytes
|x|(500f64.max(1e1*x).min(1e3).round()/1e2).min(x)
Try it online!
-1
votes
German pharmacy payment
Desmos, 30 actually 35 bytes
A one-liner Desmos equation for once (thanks to Aiden Chow for the fix and optimization):
f(x)=round([x,5,10,x/10].sort[2],2)
Try it ...
1
vote
German pharmacy payment
Python, 41 bytes
lambda x:min(max(5,(x*20+1)//2/100),x,10)
Attempt This Online!
Straight-forward implementation of OP's formula. For the rounding it uses floor ...
0
votes
German pharmacy payment
Scala 3, 106 100 bytes
Saved 6 bytes thanks to @corvus_192
Golfed version. Attempt This Online!
...
0
votes
German pharmacy payment
AWK, 48 bytes
{y=$0/10;a=y>5?y>10?10:y:5>$0?$0:5;print a+1e-4}
Try it online!
Ungolfed :
...
0
votes
German pharmacy payment
05AB1E, 16 (or 25) bytes
T/5‚à‚Tªß4°z+2.ò
Try it online or verify all test cases.
This outputs 5.0 or ...
0
votes
German pharmacy payment
PARI/GP, 44 bytes
x->printf("%.2f",min(x,min(max(x/10,5),10)))
Attempt This Online!
A port of @Evargalo's R answer.
Prints the result to stdout.
0
votes
German pharmacy payment
Wolfram Language (Mathematica), 36 bytes
#~Min~Max[.1#,5]~Min~10~Round~.01&@x
Alas, we cannot save an extra byte by using infix notation with ...
0
votes
German pharmacy payment
sclin, 26 bytes
dup.1*5|10,` &/100* |~100/
Try it on scline!
sclin's default real/rational number representation comes in handy here.
Explanation
Prettified ...
5
votes
German pharmacy payment
R, 39 bytes
\(x)round(.001+min(x,max(.1*x,5),10),2)
Basically using the formula given by the OP.
-5 bytes thanks to @doubleunary
-3 bytes and fix a rounding error ...
0
votes
2
votes
German pharmacy payment
Ruby, 42 36 bytes
->a{[a,[a/10,5].max,10].min.round 2}
Try it online!
Ruby, 38 bytes
Formatted as per initial requirement:
...
2
votes
German pharmacy payment
Google Sheets / Microsoft Excel, 31 bytes
=fixed(min(10,A1,max(5,A1/10)))
Put the input in cell A1 and the formula in ...
0
votes
German pharmacy payment
Charcoal, 21 bytes
NθI⌊⟦θχ⌈⟦⁵∕⌊⁺·⁵×θχ¹⁰⁰
Try it online! Link is to verbose version of code. Explanation: Port of the formula given in the question, but with ...
2
votes
German pharmacy payment
Retina 0.8.2, 95 92 bytes
\.
.+
$*
^(.{1000}(?=.{8995})|.(.{499,998})(?=\2{9}....)|.{0,500}).*
00$.1
0*(.+)(..)
$1.$2
Try it online! Link includes test cases. ...
8
votes
German pharmacy payment
Jelly, 14 bytes
÷⁵«⁵»5«+ȷ-4ær2
A monadic Link that accepts the full price as a float and outputs the charge as a float.
Try it online!
How?
...
1
vote
German pharmacy payment
JavaScript (ES6), 45 bytes
x=>~~(Math.min(x*10,x<50?50:x,100)*10+.5)/100
Try it online!
40 bytes
This one works in theory, but fails on some test cases ...
6
votes
German pharmacy payment
APL+WIN, 21 bytes
Prompts for input
2⍕(n⌊((.1×n←⎕)⌈5))⌊10
Try it online! Thanks to Dyalog Classic
3
votes
German pharmacy payment
JavaScript (Node.js), 40 bytes
x=>Math.min(x,x<50?5:(x*10+.5|0)/100,10)
Try it online!
Python 3, 45 bytes
...
1
vote
Print 0 to 100 without 1-9 characters
Hexagony, 19 bytes
&!)')$0<.0.>.;/-{@_
Try it online! or on hexagony.net
In hexagon layout:
...
0
votes
Print 0 to 100 without 1-9 characters
vemf, 5 bytes
0,│d↨
cancats 0 and the integers on [1, 100]
1
vote
Golf me the Schlosberg Numbers
Scala 3, 52 bytes
Stream.from(0).filter(n=>math.sqrt(n).toInt%2==0)(_)
Attempt This Online!
0
votes
Print 0 to 100 without 1-9 characters
Commodore 64 = 27 Bytes
0FORO=.TO{PI}+{PI}*{PI}*{PI}*{PI}:PRINTO;:NEXT
1
vote
Print 0 to 100 without 1-9 characters
Vyxal SH, 7 bitsv2, 0.875 bytes
ʀ
Try it Online!
Another flag cocktail.
Bitstring
0001101
Top 50 recent answers are included
Related Tags
number × 1300code-golf × 1209
math × 295
sequence × 241
arithmetic × 151
integer × 116
string × 104
number-theory × 98
decision-problem × 95
array × 87
primes × 66
base-conversion × 55
code-challenge × 46
binary × 41
ascii-art × 35
kolmogorov-complexity × 32
combinatorics × 28
random × 23
fibonacci × 22
matrix × 21
restricted-source × 19
rational-numbers × 19
sorting × 18
permutations × 18
fastest-code × 17