Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

75%
+4 −0
Challenges Golf golf challenge

Ruby, 110 106 bytes Fixed capitalization and refactored for -4. ->p,s{d=s-p s<2&&"Hole in one"||%w[Albatross Eagle Birdie Par Bogey Double Triple][d+3]+(d>1?" bogey":"")} Att...

posted 3y ago by snail_‭  ·  edited 3y ago by snail_‭

Answer
#3: Post edited by user avatar snail_‭ · 2021-11-28T03:42:03Z (almost 3 years ago)
-6 refactor
  • # Ruby, 110 bytes
  • Fixed capitalization for no change in length.
  • <pre><code class="lang-ruby">-&gt;p,s{k=%w[Albatross Eagle Birdie Par Bogey Double Triple]
  • d=s-p
  • s&lt;2&amp;&amp;&quot;Hole in one&quot;||k[d+3]+(d&gt;1?&quot; bogey&quot;:&quot;&quot;)}</code></pre>
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuhY383TtCnSKq7NtVcujHXOSEkuK8ouLFVwT03NSFZwyi1IyUxUCEosUnPLTUysVXPJLk4DiIUWZBTmpsVwptsW6BVzFNkZqakoe-UCJzDyF_LxUpZqa7OgUbeNYbY0UO0N7JYUkkGYlKyUlzVqIrasLSkuKFdKiTXTMYyEiCxZAaAA)
  • # Ruby, <del>110</del> 106 bytes
  • Fixed capitalization and refactored for -4.
  • ```ruby
  • ->p,s{d=s-p
  • s<2&&"Hole in one"||%w[Albatross Eagle Birdie Par Bogey Double Triple][d+3]+(d>1?" bogey":"")}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuhY383TtCnSKq7NtVcujHXOSEkuK8ouLFVwT03NSFZwyi1IyUxUCEosUnPLTUysVXPJLk4DiIUWZBTmpsVwptsW6BVzFNkZqakoe-UCJzDyF_LxUpZqa7OgUbeNYbY0UO0N7JYUkkGYlKyUlzVqIrasLSkuKFdKiTXTMYyEiCxZAaAA)
#2: Post edited by user avatar snail_‭ · 2021-11-27T14:13:20Z (almost 3 years ago)
  • # Ruby, 110 bytes
  • Maybe not the best attempt, but I'm not sure how much better you can do in Ruby.
  • <pre><code class="lang-ruby">-&gt;p,s{k=%w[Albatross Eagle Birdie Par Bogey Double Triple]
  • d=s-p
  • s&lt;2&amp;&amp;&quot;Hole in One&quot;||k[d+3]+(d&gt;1?&quot; &quot;+k[4]:&quot;&quot;)}</code></pre>
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuhY383TtCnSKq7NtVcujHXOSEkuK8ouLFVwT03NSFZwyi1IyUxUCEosUnPLTUysVXPJLk4DiIUWZBTmpsVwptsW6BVzFNkZqakoe-UCJzDwF_7xUpZqa7OgUbeNYbY0UO0N7JQUl7exok1grJSXNWoitqwtKS4oV0qJNdAxjISILFkBoAA)
  • # Ruby, 110 bytes
  • Fixed capitalization for no change in length.
  • <pre><code class="lang-ruby">-&gt;p,s{k=%w[Albatross Eagle Birdie Par Bogey Double Triple]
  • d=s-p
  • s&lt;2&amp;&amp;&quot;Hole in one&quot;||k[d+3]+(d&gt;1?&quot; bogey&quot;:&quot;&quot;)}</code></pre>
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuhY383TtCnSKq7NtVcujHXOSEkuK8ouLFVwT03NSFZwyi1IyUxUCEosUnPLTUysVXPJLk4DiIUWZBTmpsVwptsW6BVzFNkZqakoe-UCJzDyF_LxUpZqa7OgUbeNYbY0UO0N7JYUkkGYlKyUlzVqIrasLSkuKFdKiTXTMYyEiCxZAaAA)
#1: Initial revision by user avatar snail_‭ · 2021-11-26T20:44:59Z (almost 3 years ago)
# Ruby, 110 bytes
Maybe not the best attempt, but I'm not sure how much better you can do in Ruby. 

<pre><code class="lang-ruby">-&gt;p,s{k=%w[Albatross Eagle Birdie Par Bogey Double Triple]
d=s-p
s&lt;2&amp;&amp;&quot;Hole in One&quot;||k[d+3]+(d&gt;1?&quot; &quot;+k[4]:&quot;&quot;)}</code></pre>

[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuhY383TtCnSKq7NtVcujHXOSEkuK8ouLFVwT03NSFZwyi1IyUxUCEosUnPLTUysVXPJLk4DiIUWZBTmpsVwptsW6BVzFNkZqakoe-UCJzDwF_7xUpZqa7OgUbeNYbY0UO0N7JQUl7exok1grJSXNWoitqwtKS4oV0qJNdAxjISILFkBoAA)