#Pyth, 19 bytes
Pyth, 19 bytes
eSmi.>>.<.BQd8d2a6l
Alternative answer:
eSmi.<<8.>.BQdd2a6l
Explanation:
eSmi.>>.<.BQd8d2a6lQ | Implicit Q at the end, where Q = input
m a6lQ | Map the over [0, 1, 2, ... , floor(log base 2 of Q) - 7]
.BQ | Convert Q to binary string
.< d | Cyclically rotate left by d
> 8 | Get string from position 8 to end.
.> d | Cyclically rotate right by d
i 2 | Convert from binary string to integer
eS | Find the last element of sorted list (maximum value)
The other answer uses a similar approach, except that it rotates right first, and gets all bits except the last 8.
#Pyth, 19 bytes
eSmi.>>.<.BQd8d2a6l
Alternative answer:
eSmi.<<8.>.BQdd2a6l
Explanation:
eSmi.>>.<.BQd8d2a6lQ | Implicit Q at the end, where Q = input
m a6lQ | Map the over [0, 1, 2, ... , floor(log base 2 of Q) - 7]
.BQ | Convert Q to binary string
.< d | Cyclically rotate left by d
> 8 | Get string from position 8 to end.
.> d | Cyclically rotate right by d
i 2 | Convert from binary string to integer
eS | Find the last element of sorted list (maximum value)
The other answer uses a similar approach, except that it rotates right first, and gets all bits except the last 8.
Pyth, 19 bytes
eSmi.>>.<.BQd8d2a6l
Alternative answer:
eSmi.<<8.>.BQdd2a6l
Explanation:
eSmi.>>.<.BQd8d2a6lQ | Implicit Q at the end, where Q = input
m a6lQ | Map the over [0, 1, 2, ... , floor(log base 2 of Q) - 7]
.BQ | Convert Q to binary string
.< d | Cyclically rotate left by d
> 8 | Get string from position 8 to end.
.> d | Cyclically rotate right by d
i 2 | Convert from binary string to integer
eS | Find the last element of sorted list (maximum value)
The other answer uses a similar approach, except that it rotates right first, and gets all bits except the last 8.
#Pyth, 19 bytes
eSmi.>>.<.BQd8d2a6l
Alternative answer:
eSmi.<<8.>.BQdd2a6l
Explanation:
eSmi.>>.<.BQd8d2a6lQ | Implicit Q at the end, where Q = input
m a6lQ | Map the over [0, 1, 2, ... , floor(log base 2 of Q) - 7]
.BQ | Convert Q to binary string
.< d | Cyclically rotate left by d
> 8 | Get string from position 8 to end.
.> d | Cyclically rotate right by d
i 2 | Convert from binary string to integer
eS | Find the last element of sorted list (maximum value)
The other answer uses a similar approach, except that it rotates right first, and gets all bits except the last 8.