Number of rotations

Write a function or a program to find the number of rotations required by a wheel to travel a given distance, given its radius.

Rules

Input can be 2 positive rational numbers and can be taken in any convenient format.

Both inputs are of same unit.

There must not be any digits 0-9 in your code.

The output will be an integer (in case of float, round to infinity)

This is code-golf so shortest code wins

Examples

10       1       2
50       2       4
52.22    4       3
3.4      0.08    7
12.5663  0.9999  3
• You probably should add that digits are also forbidden in compiler options (or anywhere else): if you limit this constraint to code only, with gcc we can do something like -DP=3.14 in compiler flags, that would define P as an approximation of pi, which is probably not what you intended – Annyo Nov 21 '18 at 16:50

MathGolf, 5 4 bytes

τ/╠ü

Try it online!

Explanation

τ      Push tau (2*pi)
/     Divide the first argument (total distance) by tau
ü   Ceiling

APL+WIN, 9 bytes

Prompts for radius followed by distance:

⌈⎕÷○r+r←⎕

Try it online! Courtesy of Dyalog Classic

Explanation:

○r+r←⎕ prompt for radius and double it and multiply by pie

⌈⎕÷ prompt for distance, divide by result above and take ceiling
• ⌈⎕÷○+⍨⎕ works for 7 bytes. – J. Sallé Nov 22 '18 at 13:04
• @J.Sallé Thanks but unfortunately my ancient APL+WIN interpreter does not have the ⍨ operator – Graham Nov 22 '18 at 15:51

Java 8, 32 30 bytes

a->b->-~(int)(a/b/Math.PI/'')

Contains unprintable \u0002 between the single quotes.

Port of @jOKing's Perl 6 answer.

Try it online.

• Is that the digit '1' in your code? I think that might not be allowed. – ouflak Nov 21 '18 at 14:18
• @ouflak Looks like it can be fixed like this. – Erik the Outgolfer Nov 21 '18 at 14:22
• @ouflak Woops, that was a pretty stupid mistake.. Using the unprintable so I don't use the digit 2, and then just use digit 1... Luckily Erik is indeed right that a simple negative unary has the same effect as +1 (often used to get rid of parenthesis since the negative and unary have higher precedence than most other operators). – Kevin Cruijssen Nov 21 '18 at 18:21

Perl 6, 15 12 bytes

-3 bytes tjanks to nwellnhof reminding me about tau

*/*/τ+|$+!$

Try it online!

Anonymous Whatever lambda that uses the formula (a/b/tau).floor+1. Tau is two times pi. The two anonymous variables $are coerced to the number 0, which is used to floor the number +|0 (bitwise or 0) and add one +!$ (plus not zero).

• There must not be any digits 0-9 in your code. – Titus Nov 21 '18 at 13:35
• @Titus I can't believe I forgot that. Thanks, fixed! – Jo King Nov 21 '18 at 13:37
• Are digits in exponents also allowed? – ouflak Nov 21 '18 at 14:21

Python 2, 474544 43 bytes

lambda l,r:l/(r+r)//math.pi+l/l
import math

Try it online!

• -2 bytes, thanks to flawr
• -1 byte, thanks to Jonathan Allan
• Since inputs have been guaranteed to be both (strictly) positive and rational we never hit the edge-case of requiring an exact number of rotations, so I think we can do l/(r+r)//pi+l/l and save a byte. – Jonathan Allan Nov 21 '18 at 13:50
• @JonathanAllan Thanks :) – TFeld Nov 21 '18 at 14:16

05AB1E, 6 bytes

·/žq/î

Port of @flawr's Python 2 comment.
Takes the input in the order radius,distance.

Explanation:

·         # Double the first (implicit) input
/        # Divide the second (implicit) input by it
žq/     # Divide it by PI
î    # Ceil it (and output implicitly)

Lua, 615857 49 bytes

function(s,r)return math.ceil(s/(r+r)/math.pi)end

Try it online!

Thanks to KirillL. -8 bytes.

• I don't know much Lua (so maybe it's still too long), but it appears to be shorter as a function: 49 bytes – Kirill L. Nov 22 '18 at 11:18
• @KirillL., I'm still learning the rules here. The OP's challenge is pretty open on the input. So my question is, would we have to count your program call() against the byte count? If not, your's definitely shaves off a nice chunk. – ouflak Nov 22 '18 at 11:43
• A quite common style of submission here is an anonymous function (so that we don't have to count the name, unless it is recursive), which outputs by its return value. The footer section with function calls and actual printing to console is then basically used for visualizing the results and doesn't count towards your score. BTW, you may add more of the OP's test examples to the footer, so that they can be conveniently viewed all at once. Note that in some cases a full program may actually turn out to be golfier! – Kirill L. Nov 22 '18 at 11:58

Common Lisp, 36 bytes

(lambda(a b)(ceiling(/ a(+ b b)pi)))

Try it online!

proc N d\ r {expr ceil($d/(($r+$r)*acos(-$r/$r)))} Try it online! Tcl, 53 bytes proc N d\ r {expr ceil($d/(($r+$r)*acos(-[incr i])))}

Try it online!

Lack of a pi constant or function makes me lose the golf competition!

• Do I need to remove the .0 at end of each output? It would make me consume more bytes! – sergiol Nov 22 '18 at 18:55
• [incr i] is quite clever but I think you can use $d/$d or $r/$r instead. – david Nov 22 '18 at 20:17
• Saved some bytes thanks to @david's idea! – sergiol Nov 22 '18 at 22:56

PowerShell, 5352 51 bytes

-1 byte thanks to @mazzy
-1 byte after I realized I don't need a semicolon after the param() block

param($d,$r)($a=[math])::ceiling($d/($r+$r)/$a::pi) Try it online! Takes input from two commandline parameters, distance -d and radius -r. • ? param($d,$r);($a=[math])::ceiling($d/($r+$r)/$a::pi) – mazzy Nov 24 '18 at 5:54

JavaScript (Babel Node), 23 bytes

s=>r=>-~(s/2/r/Math.PI)

Try it online!

• There must not be any digits 0-9 in your code. – Dennis Nov 22 '18 at 12:55

Clojure, 50 bytes

(fn[a b](int(Math/ceil(/ a Math/PI(count"  ")b))))

An anonymous function that accepts two integers a and b as arguments: the distance and the wheel's radius, respectively.

Try it online!

(count " ") evaluates to 2, so this function implements $$\\lceil \dfrac a{2\pi b} \rceil\$$.

TI-Basic (83 series), 12 bytes

-int(-Tmax⁻¹min(e^(ΔList(ln(Ans

Takes input as a list of radius and distance in Ans: for example, {0.9999:12.5663:prgmX.

e^(ΔList(ln(Ans will take the ratio of those distances, and min( turns this into a number. Then we divide by Tmax, which is a graphing parameter that's equal to 2π by default. Finally, -int(- takes the ceiling.

Pari/GP, 23 bytes

(d,r)->ceil(d/(r+r)/Pi)

Try it online!