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

edited body
Source Link
histocrat
  • 22.3k
  • 4
  • 39
  • 81

Ruby, 27 bytes

->n{('%34b'%n).tr'01','ah'}

Try it online!

('%34b'%n) Converts an integer into its binary representation, using ..1 to indicate a negative number (this is meant to represent an infinitely-long prefix of 1s), and left-pads this out to 34 characters using spaces. Then we replace the 0s with 'a' and the 1s with 'b''h' to create the Maniacal Base 2 Representation: strings like "haaahahahaaha" prepended with spaces and sometimes ... Since every step here is invertible this is 1:1.

Edit: Let the record show that @manatwork posted this identical solution first. Oops. I should've refreshed.

Ruby, 27 bytes

->n{('%34b'%n).tr'01','ah'}

Try it online!

('%34b'%n) Converts an integer into its binary representation, using ..1 to indicate a negative number (this is meant to represent an infinitely-long prefix of 1s), and left-pads this out to 34 characters using spaces. Then we replace the 0s with 'a' and the 1s with 'b' to create the Maniacal Base 2 Representation: strings like "haaahahahaaha" prepended with spaces and sometimes ... Since every step here is invertible this is 1:1.

Edit: Let the record show that @manatwork posted this identical solution first. Oops. I should've refreshed.

Ruby, 27 bytes

->n{('%34b'%n).tr'01','ah'}

Try it online!

('%34b'%n) Converts an integer into its binary representation, using ..1 to indicate a negative number (this is meant to represent an infinitely-long prefix of 1s), and left-pads this out to 34 characters using spaces. Then we replace the 0s with 'a' and the 1s with 'h' to create the Maniacal Base 2 Representation: strings like "haaahahahaaha" prepended with spaces and sometimes ... Since every step here is invertible this is 1:1.

Edit: Let the record show that @manatwork posted this identical solution first. Oops. I should've refreshed.

added 112 characters in body
Source Link
histocrat
  • 22.3k
  • 4
  • 39
  • 81

Ruby, 27 bytes

->n{('%34b'%n).tr'01','ah'}

Try it online!

('%34b'%n) Converts an integer into its binary representation, using ..1 to indicate a negative number (this is meant to represent an infinitely-long prefix of 1s), and left-pads this out to 34 characters using spaces. Then we replace the 0s with 'a' and the 1s with 'b' to create the Maniacal Base 2 Representation: strings like "haaahahahaaha" prepended with spaces and sometimes ... Since every step here is invertible this is 1:1.

Edit: Let the record show that @manatwork posted this identical solution first. Oops. I should've refreshed.

Ruby, 27 bytes

->n{('%34b'%n).tr'01','ah'}

Try it online!

('%34b'%n) Converts an integer into its binary representation, using ..1 to indicate a negative number (this is meant to represent an infinitely-long prefix of 1s), and left-pads this out to 34 characters using spaces. Then we replace the 0s with 'a' and the 1s with 'b' to create the Maniacal Base 2 Representation: strings like "haaahahahaaha" prepended with spaces and sometimes ... Since every step here is invertible this is 1:1.

Ruby, 27 bytes

->n{('%34b'%n).tr'01','ah'}

Try it online!

('%34b'%n) Converts an integer into its binary representation, using ..1 to indicate a negative number (this is meant to represent an infinitely-long prefix of 1s), and left-pads this out to 34 characters using spaces. Then we replace the 0s with 'a' and the 1s with 'b' to create the Maniacal Base 2 Representation: strings like "haaahahahaaha" prepended with spaces and sometimes ... Since every step here is invertible this is 1:1.

Edit: Let the record show that @manatwork posted this identical solution first. Oops. I should've refreshed.

Source Link
histocrat
  • 22.3k
  • 4
  • 39
  • 81

Ruby, 27 bytes

->n{('%34b'%n).tr'01','ah'}

Try it online!

('%34b'%n) Converts an integer into its binary representation, using ..1 to indicate a negative number (this is meant to represent an infinitely-long prefix of 1s), and left-pads this out to 34 characters using spaces. Then we replace the 0s with 'a' and the 1s with 'b' to create the Maniacal Base 2 Representation: strings like "haaahahahaaha" prepended with spaces and sometimes ... Since every step here is invertible this is 1:1.

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