Golf-FAQ.com

[code golf] return odd no matter what

by Isidro Hoeger Jr. Published 2 years ago Updated 2 years ago
image

[Code Golf] Return Odd No Matter What Solutions Discourse (64) Description: Given the integer n return odd numbers as they are, but subtract 1 from even numbers.

Full Answer

Jelly, 7 bytes

Swaps 2 s and 3 s in the input's prime factorization. The probability of odds is 2/3.

Java 8, 20 bytes

Port of @nwellnhof 's C answer. Some things I tried myself ended up being a few bytes longer or slightly incorrect..

x86 32-bit machine code, 12 bytes

A port of nwellnhof's C answer. Uses the regparm (1) calling convention – argument in EAX, result in EAX.

1st extra challenge: 18 bytes

Implements a function several other answers have used, mapping powers of 2 to even numbers in ascending order and other numbers to odd numbers in ascending order: f 1 ( 2 m) = 2 m + 2 , and for n ∈ [ 2 m, 2 m + 1), f 1 ( n) = 2 n − 2 m − 3.

3rd extra challenge: 12 bytes

Rearranges the bits of the value by moving the second-highest bit to the bottom. This produces 1 odd, 1 even, 1 odd, 2 even, 2 odd, 4 even, 4 odd, ...

Why are odds higher in sports?

Because of the difficulty of a player winning a tournament in fields that are often around 150, outright odds are much higher than someone betting on team sports is used to. Strategy: Because the return on investment can be so high, you can bet on numerous players and still make a nice profit if one of your players wins.

What is outright betting?

A less risky version of outright betting is wagering on a player to finish in the top 5, 10 or 20 in a tournament, depending on what your sportsbook offers. While it doesn’t offer the high odds that outright betting does, it is much less volatile and rewards steady performances from your golfers.

Why is 3-ball betting so popular?

3-Ball: An increasingly popular way to bet on golf because it provides a way to gamble on each round. 3-Ball betting typically uses the pairings in the tournament and gives odds on which player in the group will perform the best in the round. This can provide for entertaining viewing if you bet on a player in a featured group on TV.

How long can you bet on a tournament?

It’s important to stay reasonable and stick to a weekly limit on how much you bet on a tournament. Picking an outright winner is hard and you will often go weeks without getting a winner. But the profit of just one winner will typically make up for multiple weeks and more, especially if it wasn’t a heavy favorite.

Is the Open Championship cancelled?

The Open Championship. The Open Championship was canceled for 2020 but returns to the schedule for July 15-18. Royal St. George’s Golf Club in England will remain the host the 2021 Open Championship after losing the 2020 Open.

Is there betting on the first round leader?

Betting on the first-round leader is a niche market but seems to be growing. It is still not available on every sportsbook. Strategy: It’s much easier to lead a single round than win an entire golf tournament, but odds for first-round leader mostly remains the same as outright odds.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9