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

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Brainf***, 61 bytes

Chinese, 16 characters

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF-32, the whole program could technically be expressed in 6 characters.

EDIT: And thanks to Jan Dvorak Jan Dvorak for introducing me to Chinese, which compresses this into 16 characters, on par with Dennis' Dennis' CJam answer CJam answer.

蜐蕈帑聿纂胯箩悚衅鹊颂鹛拮拮氰人

Brainf***, 61 bytes

Chinese, 16 characters

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF-32, the whole program could technically be expressed in 6 characters.

EDIT: And thanks to Jan Dvorak for introducing me to Chinese, which compresses this into 16 characters, on par with Dennis' CJam answer.

蜐蕈帑聿纂胯箩悚衅鹊颂鹛拮拮氰人

Brainf***, 61 bytes

Chinese, 16 characters

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF-32, the whole program could technically be expressed in 6 characters.

EDIT: And thanks to Jan Dvorak for introducing me to Chinese, which compresses this into 16 characters, on par with Dennis' CJam answer.

蜐蕈帑聿纂胯箩悚衅鹊颂鹛拮拮氰人
Added Chinese answer.
Source Link
Hand-E-Food
  • 8.9k
  • 5
  • 33
  • 52

Brainf***, 6 characters*, 61 bytes

Chinese , 16 characters

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF-32, the whole program could technically be expressed in 6 characters.

EDIT: And thanks to Jan Dvorak for introducing me to Chinese , which compresses this into 16 characters, on par with Dennis' CJam answer .

蜐蕈帑聿纂胯箩悚衅鹊颂鹛拮拮氰人

Brainf***, 6 characters*, 61 bytes

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF-32, the whole program could technically be expressed in 6 characters.

Brainf***, 61 bytes

Chinese , 16 characters

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF-32, the whole program could technically be expressed in 6 characters.

EDIT: And thanks to Jan Dvorak for introducing me to Chinese , which compresses this into 16 characters, on par with Dennis' CJam answer .

蜐蕈帑聿纂胯箩悚衅鹊颂鹛拮拮氰人
There's no such thing as UTF64.
Source Link
Hand-E-Food
  • 8.9k
  • 5
  • 33
  • 52

Brainf***, 36 characters*, 61 bytes

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF64UTF-32, the whole program could technically be expressed in 36 characters.

Brainf***, 3 characters*, 61 bytes

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF64, the whole program could technically be expressed in 3 characters.

Brainf***, 6 characters*, 61 bytes

This requires the input is in the ASCII range 1-127 and is null-terminated. It deletes pairs of characters from the start and end of the string until there are one or two characters remaining. If there are two, it adds them together, then divides by 2, rounding down. The remaining character is printed.

,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.

Dissection:

,[>,] Get the null terminated input
<<< Move to the second last character
[ While there are at least 3 characters
 [<]> Move to the first character
 [-] Delete it
 >[>]< Move to the last character
 [-] Delete it
 <<< Move the the third last character
]
> Move to the second last character
[ If there are two characters remaining
 [->+<] Add the two characters together
 >[-[-<+<]>>] Divide the character by 2 rounding down
 <[>]<[>]<< Move to before the character to exit the if loop
]
>. Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF-32, the whole program could technically be expressed in 6 characters.

put primary score at the end, because that's the one the leaderboard uses
Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998
Loading
Optimized loops.
Source Link
Hand-E-Food
  • 8.9k
  • 5
  • 33
  • 52
Loading
Source Link
Hand-E-Food
  • 8.9k
  • 5
  • 33
  • 52
Loading

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