Number of rotations
Task
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
distance radius output
10 1 2
50 2 4
52.22 4 3
3.4 0.08 7
12.5663 0.9999 3
code-golf restricted-source
add a comment |
Task
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
distance radius output
10 1 2
50 2 4
52.22 4 3
3.4 0.08 7
12.5663 0.9999 3
code-golf restricted-source
4
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 defineP
as an approximation of pi, which is probably not what you intended
– Annyo
Nov 21 '18 at 16:50
add a comment |
Task
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
distance radius output
10 1 2
50 2 4
52.22 4 3
3.4 0.08 7
12.5663 0.9999 3
code-golf restricted-source
Task
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
distance radius output
10 1 2
50 2 4
52.22 4 3
3.4 0.08 7
12.5663 0.9999 3
code-golf restricted-source
code-golf restricted-source
edited Nov 22 '18 at 12:54
Dennis♦
187k32297736
187k32297736
asked Nov 21 '18 at 12:42
Vedant KandoiVedant Kandoi
1,073226
1,073226
4
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 defineP
as an approximation of pi, which is probably not what you intended
– Annyo
Nov 21 '18 at 16:50
add a comment |
4
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 defineP
as an approximation of pi, which is probably not what you intended
– Annyo
Nov 21 '18 at 16:50
4
4
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
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
add a comment |
31 Answers
31
active
oldest
votes
1 2
next
MathGolf, 5 4 bytes
τ/╠ü
Try it online!
Explanation
τ Push tau (2*pi)
/ Divide the first argument (total distance) by tau
╠ Reverse divide (computes (distance/tau)/radius)
ü Ceiling
add a comment |
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
add a comment |
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
4
@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 digit2
, and then just use digit1
... 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
add a comment |
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
add a comment |
Python 2, 47 45 44 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 dol/(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
add a comment |
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)
add a comment |
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
Welcome to PPCG! This is a nice first answer. Yes, you do need to count#include
and the like towards your byte total. A link to an online test suite is always appreciated, here's one you are free to incorporate into your post: tio.run/…
– O.O.Balance
Nov 21 '18 at 14:53
@O.O.Balance Digits are not allowed in the code for this challenge ;)
– Annyo
Nov 21 '18 at 15:25
@Annyo I knew I was forgetting something :(
– O.O.Balance
Nov 21 '18 at 15:26
add a comment |
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
ċ/π/Ǔ
add a comment |
Stax, 5 bytes
Vt*/e
Run and debug it
Vt* multiply by tau (2pi)
/ divide
e ceiling
add a comment |
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
.
Try it online.
Explanation:
∞ # Double the first (implicit) input
/ # Divide the second (implicit) input by it
π/ # Divide it by PI
ü # Ceil (and output implicitly)
add a comment |
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.
Try it online!
add a comment |
Julia 1.0, 20 bytes
f(d,r)=cld(d/π,r+r)
Try it online!
add a comment |
R, 39 32 bytes
-7 bytes Thanks to Giuseppe
function(d,r)ceiling(d/(r+r)/pi)
Try it online!
I feel like this could definitely be golfed, but I am a bit lazy right now to do anything about it
add a comment |
PHP, 47 bytes
<?=ceil($argv[++$i]/M_PI/(($b=end($argv))+$b));
Try it online.
add a comment |
Jelly, 6 bytes
÷÷ØPHĊ
Try it online!
add a comment |
Ruby, 29 bytes
->l,r{(l/Math::PI/r+=r).ceil}
Try it online!
add a comment |
J, 10 9 bytes
>.@%o.@+:
Try it online!
add a comment |
Japt, 7 bytes
/MT/V c
Try it here
add a comment |
JavaScript (Babel Node), 25 bytes
-2 bytes using @flawr comment =D. -1 from @Kevin. -7 from @Shaggy
a=>b=>-~(a/(b+b)/Math.PI)
Try it online!
Justa=>b=>Math.ceil(a/(b+b)/Math.PI)
is 32 bytes. :)
– Kevin Cruijssen
Nov 21 '18 at 13:06
25 bytes
– Shaggy
Nov 21 '18 at 17:09
add a comment |
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.
add a comment |
Dart, 47 46 bytes
import'dart:math';f(a,b)=>(a/(b+b)/pi).ceil();
Try it online!
- -1 byte thanks to @Shaggy
46 bytes
– Shaggy
Nov 22 '18 at 12:30
add a comment |
Haskell, 25 bytes
f d r=ceiling(d/(r+r)/pi)
You can define an operator(!)
instead off
and useceiling$
instead ofceiling(..)
which saves you 3 bytes: Try it online!
– BMO
Dec 8 '18 at 15:15
add a comment |
Lua, 61 58 57 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
add a comment |
Common Lisp, 36 bytes
(lambda(a b)(ceiling(/ a(+ b b)pi)))
Try it online!
add a comment |
Tcl, 50 bytes
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
1
[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
add a comment |
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
.
?param($d,$r);($a=[math])::ceiling($d/($r+$r)/$a::pi)
– mazzy
Nov 24 '18 at 5:54
add a comment |
JavaScript (Babel Node), 23 bytes
s=>r=>-~(s/2/r/Math.PI)
Try it online!
2
There must not be any digits 0-9 in your code.
– Dennis♦
Nov 22 '18 at 12:55
add a comment |
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{2pi b} rceil$.
add a comment |
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.
add a comment |
Pari/GP, 23 bytes
(d,r)->ceil(d/(r+r)/Pi)
Try it online!
add a comment |
1 2
next
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f176328%2fnumber-of-rotations%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
31 Answers
31
active
oldest
votes
31 Answers
31
active
oldest
votes
active
oldest
votes
active
oldest
votes
1 2
next
MathGolf, 5 4 bytes
τ/╠ü
Try it online!
Explanation
τ Push tau (2*pi)
/ Divide the first argument (total distance) by tau
╠ Reverse divide (computes (distance/tau)/radius)
ü Ceiling
add a comment |
MathGolf, 5 4 bytes
τ/╠ü
Try it online!
Explanation
τ Push tau (2*pi)
/ Divide the first argument (total distance) by tau
╠ Reverse divide (computes (distance/tau)/radius)
ü Ceiling
add a comment |
MathGolf, 5 4 bytes
τ/╠ü
Try it online!
Explanation
τ Push tau (2*pi)
/ Divide the first argument (total distance) by tau
╠ Reverse divide (computes (distance/tau)/radius)
ü Ceiling
MathGolf, 5 4 bytes
τ/╠ü
Try it online!
Explanation
τ Push tau (2*pi)
/ Divide the first argument (total distance) by tau
╠ Reverse divide (computes (distance/tau)/radius)
ü Ceiling
edited Nov 21 '18 at 14:59
answered Nov 21 '18 at 14:41
maxbmaxb
2,94811132
2,94811132
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Nov 21 '18 at 14:10
answered Nov 21 '18 at 13:59
GrahamGraham
2,25678
2,25678
⌈⎕÷○+⍨⎕
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
add a comment |
⌈⎕÷○+⍨⎕
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
⌈⎕÷○+⍨⎕
works for 7 bytes.– J. Sallé
Nov 22 '18 at 13:04
⌈⎕÷○+⍨⎕
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
@J.Sallé Thanks but unfortunately my ancient APL+WIN interpreter does not have the ⍨ operator
– Graham
Nov 22 '18 at 15:51
add a comment |
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
4
@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 digit2
, and then just use digit1
... 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
add a comment |
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
4
@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 digit2
, and then just use digit1
... 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
add a comment |
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.
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.
edited Nov 21 '18 at 18:19
answered Nov 21 '18 at 13:05
Kevin CruijssenKevin Cruijssen
36k554189
36k554189
Is that the digit '1' in your code? I think that might not be allowed.
– ouflak
Nov 21 '18 at 14:18
4
@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 digit2
, and then just use digit1
... 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
add a comment |
Is that the digit '1' in your code? I think that might not be allowed.
– ouflak
Nov 21 '18 at 14:18
4
@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 digit2
, and then just use digit1
... 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
Is that the digit '1' in your code? I think that might not be allowed.
– ouflak
Nov 21 '18 at 14:18
Is that the digit '1' in your code? I think that might not be allowed.
– ouflak
Nov 21 '18 at 14:18
4
4
@ouflak Looks like it can be fixed like this.
– Erik the Outgolfer
Nov 21 '18 at 14:22
@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
@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
add a comment |
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
add a comment |
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
add a comment |
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).
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).
edited Nov 21 '18 at 20:17
answered Nov 21 '18 at 13:31
Jo KingJo King
21.1k248110
21.1k248110
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
add a comment |
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
There must not be any digits 0-9 in your code.
– Titus
Nov 21 '18 at 13:35
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
@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
Are digits in exponents also allowed?
– ouflak
Nov 21 '18 at 14:21
add a comment |
Python 2, 47 45 44 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 dol/(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
add a comment |
Python 2, 47 45 44 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 dol/(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
add a comment |
Python 2, 47 45 44 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
Python 2, 47 45 44 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
edited Nov 21 '18 at 14:23
answered Nov 21 '18 at 12:51
TFeldTFeld
14.4k21240
14.4k21240
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 dol/(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
add a comment |
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 dol/(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
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
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
@JonathanAllan Thanks :)
– TFeld
Nov 21 '18 at 14:16
add a comment |
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)
add a comment |
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)
add a comment |
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)
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)
answered Nov 21 '18 at 13:11
Kevin CruijssenKevin Cruijssen
36k554189
36k554189
add a comment |
add a comment |
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
Welcome to PPCG! This is a nice first answer. Yes, you do need to count#include
and the like towards your byte total. A link to an online test suite is always appreciated, here's one you are free to incorporate into your post: tio.run/…
– O.O.Balance
Nov 21 '18 at 14:53
@O.O.Balance Digits are not allowed in the code for this challenge ;)
– Annyo
Nov 21 '18 at 15:25
@Annyo I knew I was forgetting something :(
– O.O.Balance
Nov 21 '18 at 15:26
add a comment |
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
Welcome to PPCG! This is a nice first answer. Yes, you do need to count#include
and the like towards your byte total. A link to an online test suite is always appreciated, here's one you are free to incorporate into your post: tio.run/…
– O.O.Balance
Nov 21 '18 at 14:53
@O.O.Balance Digits are not allowed in the code for this challenge ;)
– Annyo
Nov 21 '18 at 15:25
@Annyo I knew I was forgetting something :(
– O.O.Balance
Nov 21 '18 at 15:26
add a comment |
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
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
answered Nov 21 '18 at 14:30
bzneinbznein
1213
1213
Welcome to PPCG! This is a nice first answer. Yes, you do need to count#include
and the like towards your byte total. A link to an online test suite is always appreciated, here's one you are free to incorporate into your post: tio.run/…
– O.O.Balance
Nov 21 '18 at 14:53
@O.O.Balance Digits are not allowed in the code for this challenge ;)
– Annyo
Nov 21 '18 at 15:25
@Annyo I knew I was forgetting something :(
– O.O.Balance
Nov 21 '18 at 15:26
add a comment |
Welcome to PPCG! This is a nice first answer. Yes, you do need to count#include
and the like towards your byte total. A link to an online test suite is always appreciated, here's one you are free to incorporate into your post: tio.run/…
– O.O.Balance
Nov 21 '18 at 14:53
@O.O.Balance Digits are not allowed in the code for this challenge ;)
– Annyo
Nov 21 '18 at 15:25
@Annyo I knew I was forgetting something :(
– O.O.Balance
Nov 21 '18 at 15:26
Welcome to PPCG! This is a nice first answer. Yes, you do need to count
#include
and the like towards your byte total. A link to an online test suite is always appreciated, here's one you are free to incorporate into your post: tio.run/…– O.O.Balance
Nov 21 '18 at 14:53
Welcome to PPCG! This is a nice first answer. Yes, you do need to count
#include
and the like towards your byte total. A link to an online test suite is always appreciated, here's one you are free to incorporate into your post: tio.run/…– O.O.Balance
Nov 21 '18 at 14:53
@O.O.Balance Digits are not allowed in the code for this challenge ;)
– Annyo
Nov 21 '18 at 15:25
@O.O.Balance Digits are not allowed in the code for this challenge ;)
– Annyo
Nov 21 '18 at 15:25
@Annyo I knew I was forgetting something :(
– O.O.Balance
Nov 21 '18 at 15:26
@Annyo I knew I was forgetting something :(
– O.O.Balance
Nov 21 '18 at 15:26
add a comment |
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
ċ/π/Ǔ
add a comment |
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
ċ/π/Ǔ
add a comment |
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
ċ/π/Ǔ
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
ċ/π/Ǔ
edited Nov 21 '18 at 14:32
answered Nov 21 '18 at 14:23
OkxOkx
12.6k127102
12.6k127102
add a comment |
add a comment |
Stax, 5 bytes
Vt*/e
Run and debug it
Vt* multiply by tau (2pi)
/ divide
e ceiling
add a comment |
Stax, 5 bytes
Vt*/e
Run and debug it
Vt* multiply by tau (2pi)
/ divide
e ceiling
add a comment |
Stax, 5 bytes
Vt*/e
Run and debug it
Vt* multiply by tau (2pi)
/ divide
e ceiling
Stax, 5 bytes
Vt*/e
Run and debug it
Vt* multiply by tau (2pi)
/ divide
e ceiling
answered Nov 21 '18 at 17:29
recursiverecursive
4,9991221
4,9991221
add a comment |
add a comment |
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
.
Try it online.
Explanation:
∞ # Double the first (implicit) input
/ # Divide the second (implicit) input by it
π/ # Divide it by PI
ü # Ceil (and output implicitly)
add a comment |
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
.
Try it online.
Explanation:
∞ # Double the first (implicit) input
/ # Divide the second (implicit) input by it
π/ # Divide it by PI
ü # Ceil (and output implicitly)
add a comment |
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
.
Try it online.
Explanation:
∞ # Double the first (implicit) input
/ # Divide the second (implicit) input by it
π/ # Divide it by PI
ü # Ceil (and output implicitly)
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
.
Try it online.
Explanation:
∞ # Double the first (implicit) input
/ # Divide the second (implicit) input by it
π/ # Divide it by PI
ü # Ceil (and output implicitly)
edited Nov 21 '18 at 18:14
answered Nov 21 '18 at 13:25
Kevin CruijssenKevin Cruijssen
36k554189
36k554189
add a comment |
add a comment |
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.
Try it online!
add a comment |
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.
Try it online!
add a comment |
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.
Try it online!
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.
Try it online!
edited Nov 21 '18 at 18:24
answered Nov 21 '18 at 17:57
gastropnergastropner
2,0501411
2,0501411
add a comment |
add a comment |
Julia 1.0, 20 bytes
f(d,r)=cld(d/π,r+r)
Try it online!
add a comment |
Julia 1.0, 20 bytes
f(d,r)=cld(d/π,r+r)
Try it online!
add a comment |
Julia 1.0, 20 bytes
f(d,r)=cld(d/π,r+r)
Try it online!
Julia 1.0, 20 bytes
f(d,r)=cld(d/π,r+r)
Try it online!
edited Nov 21 '18 at 21:11
answered Nov 21 '18 at 18:45
gggggggg
1,22656
1,22656
add a comment |
add a comment |
R, 39 32 bytes
-7 bytes Thanks to Giuseppe
function(d,r)ceiling(d/(r+r)/pi)
Try it online!
I feel like this could definitely be golfed, but I am a bit lazy right now to do anything about it
add a comment |
R, 39 32 bytes
-7 bytes Thanks to Giuseppe
function(d,r)ceiling(d/(r+r)/pi)
Try it online!
I feel like this could definitely be golfed, but I am a bit lazy right now to do anything about it
add a comment |
R, 39 32 bytes
-7 bytes Thanks to Giuseppe
function(d,r)ceiling(d/(r+r)/pi)
Try it online!
I feel like this could definitely be golfed, but I am a bit lazy right now to do anything about it
R, 39 32 bytes
-7 bytes Thanks to Giuseppe
function(d,r)ceiling(d/(r+r)/pi)
Try it online!
I feel like this could definitely be golfed, but I am a bit lazy right now to do anything about it
edited Nov 21 '18 at 21:45
answered Nov 21 '18 at 20:23
Sumner18Sumner18
4007
4007
add a comment |
add a comment |
PHP, 47 bytes
<?=ceil($argv[++$i]/M_PI/(($b=end($argv))+$b));
Try it online.
add a comment |
PHP, 47 bytes
<?=ceil($argv[++$i]/M_PI/(($b=end($argv))+$b));
Try it online.
add a comment |
PHP, 47 bytes
<?=ceil($argv[++$i]/M_PI/(($b=end($argv))+$b));
Try it online.
PHP, 47 bytes
<?=ceil($argv[++$i]/M_PI/(($b=end($argv))+$b));
Try it online.
edited Nov 21 '18 at 13:55
answered Nov 21 '18 at 13:47
TitusTitus
13k11238
13k11238
add a comment |
add a comment |
Jelly, 6 bytes
÷÷ØPHĊ
Try it online!
add a comment |
Jelly, 6 bytes
÷÷ØPHĊ
Try it online!
add a comment |
Jelly, 6 bytes
÷÷ØPHĊ
Try it online!
Jelly, 6 bytes
÷÷ØPHĊ
Try it online!
answered Nov 21 '18 at 14:02
Erik the OutgolferErik the Outgolfer
31.4k429103
31.4k429103
add a comment |
add a comment |
Ruby, 29 bytes
->l,r{(l/Math::PI/r+=r).ceil}
Try it online!
add a comment |
Ruby, 29 bytes
->l,r{(l/Math::PI/r+=r).ceil}
Try it online!
add a comment |
Ruby, 29 bytes
->l,r{(l/Math::PI/r+=r).ceil}
Try it online!
Ruby, 29 bytes
->l,r{(l/Math::PI/r+=r).ceil}
Try it online!
answered Nov 21 '18 at 14:09
G BG B
7,6861328
7,6861328
add a comment |
add a comment |
J, 10 9 bytes
>.@%o.@+:
Try it online!
add a comment |
J, 10 9 bytes
>.@%o.@+:
Try it online!
add a comment |
J, 10 9 bytes
>.@%o.@+:
Try it online!
J, 10 9 bytes
>.@%o.@+:
Try it online!
edited Nov 21 '18 at 15:11
answered Nov 21 '18 at 14:59
Galen IvanovGalen Ivanov
6,41711032
6,41711032
add a comment |
add a comment |
Japt, 7 bytes
/MT/V c
Try it here
add a comment |
Japt, 7 bytes
/MT/V c
Try it here
add a comment |
Japt, 7 bytes
/MT/V c
Try it here
Japt, 7 bytes
/MT/V c
Try it here
answered Nov 21 '18 at 17:06
ShaggyShaggy
19.2k21666
19.2k21666
add a comment |
add a comment |
JavaScript (Babel Node), 25 bytes
-2 bytes using @flawr comment =D. -1 from @Kevin. -7 from @Shaggy
a=>b=>-~(a/(b+b)/Math.PI)
Try it online!
Justa=>b=>Math.ceil(a/(b+b)/Math.PI)
is 32 bytes. :)
– Kevin Cruijssen
Nov 21 '18 at 13:06
25 bytes
– Shaggy
Nov 21 '18 at 17:09
add a comment |
JavaScript (Babel Node), 25 bytes
-2 bytes using @flawr comment =D. -1 from @Kevin. -7 from @Shaggy
a=>b=>-~(a/(b+b)/Math.PI)
Try it online!
Justa=>b=>Math.ceil(a/(b+b)/Math.PI)
is 32 bytes. :)
– Kevin Cruijssen
Nov 21 '18 at 13:06
25 bytes
– Shaggy
Nov 21 '18 at 17:09
add a comment |
JavaScript (Babel Node), 25 bytes
-2 bytes using @flawr comment =D. -1 from @Kevin. -7 from @Shaggy
a=>b=>-~(a/(b+b)/Math.PI)
Try it online!
JavaScript (Babel Node), 25 bytes
-2 bytes using @flawr comment =D. -1 from @Kevin. -7 from @Shaggy
a=>b=>-~(a/(b+b)/Math.PI)
Try it online!
edited Nov 21 '18 at 18:01
answered Nov 21 '18 at 12:52
Luis felipe De jesus MunozLuis felipe De jesus Munoz
4,09421254
4,09421254
Justa=>b=>Math.ceil(a/(b+b)/Math.PI)
is 32 bytes. :)
– Kevin Cruijssen
Nov 21 '18 at 13:06
25 bytes
– Shaggy
Nov 21 '18 at 17:09
add a comment |
Justa=>b=>Math.ceil(a/(b+b)/Math.PI)
is 32 bytes. :)
– Kevin Cruijssen
Nov 21 '18 at 13:06
25 bytes
– Shaggy
Nov 21 '18 at 17:09
Just
a=>b=>Math.ceil(a/(b+b)/Math.PI)
is 32 bytes. :)– Kevin Cruijssen
Nov 21 '18 at 13:06
Just
a=>b=>Math.ceil(a/(b+b)/Math.PI)
is 32 bytes. :)– Kevin Cruijssen
Nov 21 '18 at 13:06
25 bytes
– Shaggy
Nov 21 '18 at 17:09
25 bytes
– Shaggy
Nov 21 '18 at 17:09
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 22 '18 at 11:53
Panda0nEarthPanda0nEarth
1013
1013
add a comment |
add a comment |
Dart, 47 46 bytes
import'dart:math';f(a,b)=>(a/(b+b)/pi).ceil();
Try it online!
- -1 byte thanks to @Shaggy
46 bytes
– Shaggy
Nov 22 '18 at 12:30
add a comment |
Dart, 47 46 bytes
import'dart:math';f(a,b)=>(a/(b+b)/pi).ceil();
Try it online!
- -1 byte thanks to @Shaggy
46 bytes
– Shaggy
Nov 22 '18 at 12:30
add a comment |
Dart, 47 46 bytes
import'dart:math';f(a,b)=>(a/(b+b)/pi).ceil();
Try it online!
- -1 byte thanks to @Shaggy
Dart, 47 46 bytes
import'dart:math';f(a,b)=>(a/(b+b)/pi).ceil();
Try it online!
- -1 byte thanks to @Shaggy
edited Nov 22 '18 at 12:42
answered Nov 22 '18 at 7:31
ElcanElcan
32115
32115
46 bytes
– Shaggy
Nov 22 '18 at 12:30
add a comment |
46 bytes
– Shaggy
Nov 22 '18 at 12:30
46 bytes
– Shaggy
Nov 22 '18 at 12:30
46 bytes
– Shaggy
Nov 22 '18 at 12:30
add a comment |
Haskell, 25 bytes
f d r=ceiling(d/(r+r)/pi)
You can define an operator(!)
instead off
and useceiling$
instead ofceiling(..)
which saves you 3 bytes: Try it online!
– BMO
Dec 8 '18 at 15:15
add a comment |
Haskell, 25 bytes
f d r=ceiling(d/(r+r)/pi)
You can define an operator(!)
instead off
and useceiling$
instead ofceiling(..)
which saves you 3 bytes: Try it online!
– BMO
Dec 8 '18 at 15:15
add a comment |
Haskell, 25 bytes
f d r=ceiling(d/(r+r)/pi)
Haskell, 25 bytes
f d r=ceiling(d/(r+r)/pi)
edited Nov 22 '18 at 12:59
answered Nov 22 '18 at 12:32
memomemo
1113
1113
You can define an operator(!)
instead off
and useceiling$
instead ofceiling(..)
which saves you 3 bytes: Try it online!
– BMO
Dec 8 '18 at 15:15
add a comment |
You can define an operator(!)
instead off
and useceiling$
instead ofceiling(..)
which saves you 3 bytes: Try it online!
– BMO
Dec 8 '18 at 15:15
You can define an operator
(!)
instead of f
and use ceiling$
instead of ceiling(..)
which saves you 3 bytes: Try it online!– BMO
Dec 8 '18 at 15:15
You can define an operator
(!)
instead of f
and use ceiling$
instead of ceiling(..)
which saves you 3 bytes: Try it online!– BMO
Dec 8 '18 at 15:15
add a comment |
Lua, 61 58 57 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
add a comment |
Lua, 61 58 57 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
add a comment |
Lua, 61 58 57 49 bytes
function(s,r)return math.ceil(s/(r+r)/math.pi)end
Try it online!
Thanks to KirillL. -8 bytes.
Lua, 61 58 57 49 bytes
function(s,r)return math.ceil(s/(r+r)/math.pi)end
Try it online!
Thanks to KirillL. -8 bytes.
edited Nov 22 '18 at 13:12
answered Nov 21 '18 at 14:49
ouflakouflak
1931311
1931311
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
add a comment |
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
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
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
@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
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
add a comment |
Common Lisp, 36 bytes
(lambda(a b)(ceiling(/ a(+ b b)pi)))
Try it online!
add a comment |
Common Lisp, 36 bytes
(lambda(a b)(ceiling(/ a(+ b b)pi)))
Try it online!
add a comment |
Common Lisp, 36 bytes
(lambda(a b)(ceiling(/ a(+ b b)pi)))
Try it online!
Common Lisp, 36 bytes
(lambda(a b)(ceiling(/ a(+ b b)pi)))
Try it online!
edited Nov 22 '18 at 15:14
answered Nov 22 '18 at 15:07
RenzoRenzo
1,660516
1,660516
add a comment |
add a comment |
Tcl, 50 bytes
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
1
[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
add a comment |
Tcl, 50 bytes
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
1
[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
add a comment |
Tcl, 50 bytes
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!
Tcl, 50 bytes
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!
edited Dec 8 '18 at 12:50
answered Nov 22 '18 at 18:55
sergiolsergiol
2,5021925
2,5021925
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
1
[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
add a comment |
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
1
[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
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
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
1
1
[incr i]
is quite clever but I think you can use $d/$d
or $r/$r
instead.– david
Nov 22 '18 at 20:17
[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
Saved some bytes thanks to @david's idea!
– sergiol
Nov 22 '18 at 22:56
add a comment |
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
.
?param($d,$r);($a=[math])::ceiling($d/($r+$r)/$a::pi)
– mazzy
Nov 24 '18 at 5:54
add a comment |
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
.
?param($d,$r);($a=[math])::ceiling($d/($r+$r)/$a::pi)
– mazzy
Nov 24 '18 at 5:54
add a comment |
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
.
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
.
edited Dec 9 '18 at 23:32
answered Nov 24 '18 at 2:05
Gabriel MillsGabriel Mills
1609
1609
?param($d,$r);($a=[math])::ceiling($d/($r+$r)/$a::pi)
– mazzy
Nov 24 '18 at 5:54
add a comment |
?param($d,$r);($a=[math])::ceiling($d/($r+$r)/$a::pi)
– mazzy
Nov 24 '18 at 5:54
?
param($d,$r);($a=[math])::ceiling($d/($r+$r)/$a::pi)
– mazzy
Nov 24 '18 at 5:54
?
param($d,$r);($a=[math])::ceiling($d/($r+$r)/$a::pi)
– mazzy
Nov 24 '18 at 5:54
add a comment |
JavaScript (Babel Node), 23 bytes
s=>r=>-~(s/2/r/Math.PI)
Try it online!
2
There must not be any digits 0-9 in your code.
– Dennis♦
Nov 22 '18 at 12:55
add a comment |
JavaScript (Babel Node), 23 bytes
s=>r=>-~(s/2/r/Math.PI)
Try it online!
2
There must not be any digits 0-9 in your code.
– Dennis♦
Nov 22 '18 at 12:55
add a comment |
JavaScript (Babel Node), 23 bytes
s=>r=>-~(s/2/r/Math.PI)
Try it online!
JavaScript (Babel Node), 23 bytes
s=>r=>-~(s/2/r/Math.PI)
Try it online!
answered Nov 22 '18 at 12:43
Igor SowinskiIgor Sowinski
191
191
2
There must not be any digits 0-9 in your code.
– Dennis♦
Nov 22 '18 at 12:55
add a comment |
2
There must not be any digits 0-9 in your code.
– Dennis♦
Nov 22 '18 at 12:55
2
2
There must not be any digits 0-9 in your code.
– Dennis♦
Nov 22 '18 at 12:55
There must not be any digits 0-9 in your code.
– Dennis♦
Nov 22 '18 at 12:55
add a comment |
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{2pi b} rceil$.
add a comment |
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{2pi b} rceil$.
add a comment |
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{2pi b} rceil$.
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{2pi b} rceil$.
answered Nov 23 '18 at 2:02
TheGreatGeekTheGreatGeek
714
714
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 25 '18 at 18:22
Misha LavrovMisha Lavrov
4,211424
4,211424
add a comment |
add a comment |
Pari/GP, 23 bytes
(d,r)->ceil(d/(r+r)/Pi)
Try it online!
add a comment |
Pari/GP, 23 bytes
(d,r)->ceil(d/(r+r)/Pi)
Try it online!
add a comment |
Pari/GP, 23 bytes
(d,r)->ceil(d/(r+r)/Pi)
Try it online!
Pari/GP, 23 bytes
(d,r)->ceil(d/(r+r)/Pi)
Try it online!
answered Nov 25 '18 at 18:41
alephalphaalephalpha
21.2k32989
21.2k32989
add a comment |
add a comment |
1 2
next
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f176328%2fnumber-of-rotations%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
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 defineP
as an approximation of pi, which is probably not what you intended– Annyo
Nov 21 '18 at 16:50