Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#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.

Source Link
K Zhang
  • 7.3k
  • 1
  • 11
  • 13

#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.

AltStyle によって変換されたページ (->オリジナル) /