| Bytes | Lang | Time | Link |
|---|---|---|---|
| 030 | Perl 5 MMathTrig p | 250226T171812Z | Xcali |
| 031 | YASEPL | 250225T161219Z | madeforl |
| 019 | Desmos | 250222T215839Z | DesmosEn |
| 050 | Tcl | 181122T185503Z | sergiol |
| 018 | Factor + cursors | 220506T203626Z | chunes |
| 022 | Desmos | 220506T185026Z | naffetS |
| 019 | Pari/GP | 181125T184134Z | alephalp |
| 031 | Ruby | 190122T112802Z | Asone Tu |
| 022 | Intel 8087 FPU assembly | 190122T034433Z | 640KB |
| 028 | SmileBASIC | 190122T001654Z | 12Me21 |
| 051 | PowerShell | 181124T020524Z | GMills |
| 012 | TIBasic 83 series | 181125T182240Z | Misha La |
| 050 | Clojure | 181123T020202Z | TheGreat |
| 036 | Common Lisp | 181122T150737Z | Renzo |
| 049 | Lua | 181121T144956Z | ouflak |
| 025 | Haskell | 181122T123218Z | memo |
| 023 | JavaScript Babel Node | 181122T124303Z | Igor Sow |
| 046 | Dart | 181122T073128Z | Elcan |
| 016 | min | 181122T115309Z | Panda0nE |
| 032 | R | 181121T202307Z | Sumner18 |
| 020 | Julia 1.0 | 181121T184556Z | gggg |
| 012 | Perl 6 | 181121T133155Z | Jo King |
| 045 | C gcc | 181121T175755Z | gastropn |
| 030 | Java 8 | 181121T130547Z | Kevin Cr |
| 005 | MathGolf | 181121T132505Z | Kevin Cr |
| 025 | JavaScript Babel Node | 181121T125229Z | Luis fel |
| 005 | Stax | 181121T172916Z | recursiv |
| 007 | Japt | 181121T170607Z | Shaggy |
| 009 | J | 181121T145936Z | Galen Iv |
| 004 | MathGolf | 181121T144109Z | maxb |
| 008 | Catholicon | 181121T142340Z | Okx |
| 046 | C | 181121T143048Z | bznein |
| 043 | Python 2 | 181121T125111Z | TFeld |
| 009 | APL+WIN | 181121T135903Z | Graham |
| 029 | Ruby | 181121T140921Z | G B |
| 006 | Jelly | 181121T140242Z | Erik the |
| 047 | PHP | 181121T134746Z | Titus |
| 006 | 05AB1E | 181121T131108Z | Kevin Cr |
YASEPL, 31 bytes
=d'=r'=gπ+g*r!/g=h$=l$d%h:h+d<
input distance then radius
explanation:
=d'=r'=gπ+g*r!/g=h$=l$d%h:h+d< packed
=d' get distance (D)
=r' get radius (R)
=gπ+g*r calculate 2πr
=gπ set G as pi
+g add itself
*r multiply by R
!/g divide D by 2πr
=h$=l$d%h:h+d round up D
=h$ create H (replacement for 1)
=l$d set L as D
%h modulo by 1
:h subtract that from 1
+d add D
< output the final number
Desmos, 19 bytes
f(d,r)=ceil(d/τ/r)
f takes distance d, and rotations r, returning the ceiling of d/tau/r or more simply, d/(tau*r).
Tcl, 50 bytes
proc N d\ r {expr ceil($d/(($r+$r)*acos(-$r/$r)))}
---
Tcl, 53 bytes
proc N d\ r {expr ceil($d/(($r+$r)*acos(-[incr i])))}
Lack of a pi constant or function makes me lose the golf competition!
Factor + cursors, 18 bytes
[ / pi pi + up/i ]
Divide the distance by the radius, then ceiling-integer-divide that by 2pi. The ceiling-integer-division word up/i is provided by the cursors vocabulary.
Intel 8087 FPU assembly, 22 bytes
; input: D,R (shortreal,shortreal)
; output: O (memsixteen)
FDIST MACRO D, R, O
FLD D ; ST[] = D
FLDPI ; ST[] = PI
FDIV ; ST = D / PI
FLD R ; ST[] = R
FLD ST ; ST[] = R
FADD ; ST = R + R
FDIV ; ST = D / PI / R + R
FISTP O
ENDM
Uses only the Intel Eighty-Eighty-Seven math-coprocessor. Inputs Distance (D) and Radius (R) as thirty-two bit IEEE Seven-Fifty-Four single-precision real. Returns O as a sixteen bit unsigned int.
SmileBASIC, 28 bytes
INPUT D,R?CEIL(D/(R+R)/PI())
PowerShell, 53 52 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)
Takes input from two commandline parameters, distance -d and radius -r.
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.
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.
(count " ") evaluates to 2, so this function implements \$\lceil \dfrac a{2\pi b} \rceil\$.
Lua, 61 58 57 49 bytes
function(s,r)return math.ceil(s/(r+r)/math.pi)end
Thanks to KirillL. -8 bytes.
Haskell, 25 bytes
f d r=ceiling(d/(r+r)/pi)
min, 16 bytes
/ tau / ceil int
Takes the distance and radius put on the stack in that order. Then divides by tau, rounds, and makes int.
R, 39 32 bytes
-7 bytes Thanks to Giuseppe
function(d,r)ceiling(d/(r+r)/pi)
I feel like this could definitely be golfed, but I am a bit lazy right now to do anything about it
Perl 6, 15 12 bytes
-3 bytes tjanks to nwellnhof reminding me about tau
*/*/τ+|$+!$
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).
C (gcc), 45 47 45 bytes
f(d,r,R)float d,r;{R=ceil(d/r/'G'/'\n'*'q');}
A reasonable approximation of pi is 355/113. Since circumference C = 2 * r * PI, we can instead of pi use tau, which is then of course ~710/113. 710 happens to have the convenient factors 2 * 5 * 71, which is compactly expressed as 'G' * '\n'. We add one (r/r) to force rounding to infinity.
Edit: My trick was too clever for its own good: it of course made it fail if the distance was a multiple of the circumference.
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.
MathGolf, 6 5 bytes
∞/π/ü
Semi-port of @flawr's Python 2 comment.
Takes the input in the order radius distance.
-1 byte because ceil builtin has just been added, replacing the floor+1.
Explanation:
∞ # Double the first (implicit) input
/ # Divide the second (implicit) input by it
π/ # Divide it by PI
ü # Ceil (and output implicitly)
JavaScript (Babel Node), 25 bytes
-2 bytes using @flawr comment =D. -1 from @Kevin. -7 from @Shaggy
a=>b=>-~(a/(b+b)/Math.PI)
MathGolf, 5 4 bytes
τ/╠ü
Explanation
τ Push tau (2*pi)
/ Divide the first argument (total distance) by tau
╠ Reverse divide (computes (distance/tau)/radius)
ü Ceiling
Catholicon, 8 bytes
ċ//ĊǓĊ`Ė
Explanation:
/ĊǓĊ divide the first input by the doubled second input
/ `Ė divide that by pi
ċ ceil
New version (pi builtin made one byte, division parameters swapped), 5 bytes
ċ/π/Ǔ
C, 46 bytes
f(float a,float b){return ceil(a/(b+b)/M_PI);}
I'm new to PPCG, so I'm not sure wether I have to count other parts in the byte count, such as the
include <math.h>
needed for the ceil function, which will rise the count to 64 bytes
Python 2, 47 45 44 43 bytes
lambda l,r:l/(r+r)//math.pi+l/l
import math
- -2 bytes, thanks to flawr
- -1 byte, thanks to Jonathan Allan
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
05AB1E, 6 bytes
·/žq/î
Port of @flawr's Python 2 comment.
Takes the input in the order radius,distance.
Try it online or verify all test cases.
Explanation:
· # Double the first (implicit) input
/ # Divide the second (implicit) input by it
žq/ # Divide it by PI
î # Ceil it (and output implicitly)