Skip to main content
added 585 characters in body
Source Link
mousetail 'he-him'
  • 13.5k
  • 1
  • 39
  • 85

><> (Fish), 5653 50 46 bytes

 i:0(l'~')?v:fg1+$fpv0
v?\~1+a\~'!':fg(0:i<]r+1r[
.\{:o} 1\~rvol-d11
)^?;a1.\o:'~'<;?('!'l~oa

Try itTry it

There is already a slightly shorter ><> answerFinally beat the current fish answer. Note the link pre-populates the stack to make it faster but this one is mine and I'm proudunnecessary for the correctness of itthe program.

><> (Fish), 53 50 bytes

Each element of the stack stores how often the nth character appears in the input.

l'~')?v0
v?(0:i<]r+1r[
~
r
>:?vao~l'!'(?;
/  \1-lo

enter image description here

Try it The top row pushes ord('~') 0s to the stack.

This version actually completes beforeThe second row reads the endinput. Use [r1+r] to get the nth element of the universestack, which is niceadd 1 to it, then put it back into place. Uses

The left (red) half of the third row reverses the stack insteadso the higher valued items are on the top. Now we know that the length of the stack is the character code of the count the top element represents. This allows very convenient printing.

The left (grey) half of the bottom row checks if the count of the nth character is 0. If so go to store how often each number appearsthe right half of the third row.

The right (blue) half of the bottom row prints a line break ao. Then pops the top of the stack. If we now have less than ord('!') items on the stack only spaces remain and we exit (since we shouldn't print spaces)

The right half of the third row runs if there is more than one occurrence of the top character. If so, we subtract one occurrence, then print the length of the stack as a character.

><> (Fish), 56 bytes

 i:0(?v:fg1+$fp
?\~1+a\~'!':fg:
.\{:o} 1-d1
)?;a1.\o:'~'

Try it

There is already a slightly shorter ><> answer but this one is mine and I'm proud of it.

><> (Fish), 53 50 bytes

l'~')?v0
v?(0:i<]r+1r[
~
r
>:?vao~l'!'(?;
/  \1-lo

Try it

This version actually completes before the end of the universe, which is nice. Uses the stack instead of the code to store how often each number appears.

><> (Fish), 53 50 46 bytes

l'~')?v0
v?(0:i<]r+1r[
\~rvol-1
^?:<;?('!'l~oa

Try it

Finally beat the current fish answer. Note the link pre-populates the stack to make it faster but this is unnecessary for the correctness of the program.

Each element of the stack stores how often the nth character appears in the input.

enter image description here

The top row pushes ord('~') 0s to the stack.

The second row reads the input. Use [r1+r] to get the nth element of the stack, add 1 to it, then put it back into place.

The left (red) half of the third row reverses the stack so the higher valued items are on the top. Now we know that the length of the stack is the character code of the count the top element represents. This allows very convenient printing.

The left (grey) half of the bottom row checks if the count of the nth character is 0. If so go to the right half of the third row.

The right (blue) half of the bottom row prints a line break ao. Then pops the top of the stack. If we now have less than ord('!') items on the stack only spaces remain and we exit (since we shouldn't print spaces)

The right half of the third row runs if there is more than one occurrence of the top character. If so, we subtract one occurrence, then print the length of the stack as a character.

deleted 1488 characters in body
Source Link
mousetail 'he-him'
  • 13.5k
  • 1
  • 39
  • 85

><> (Fish), 56 bytes

 i:0(?v:fg1+$fp
?\~1+a\~'!':fg:
.\{:o} 1-d1
)?;a1.\o:'~'

Try it

There is already a slightly shorter ><> answer but this one is mine and I'm proud of it.

><> (Fish), 5353 50 bytes

l'~')?v0
v?(0:i<]r+1r[
\~rl'~
r
>:?vao~l'!'(?;
>:/  ?vao~22.
\ol\1-1/lo

Try itTry it

This version actually completes before the end of the universe, which is nice. Uses the stack instead of the code to store how often each number appears.

><> (Fish), 56 bytes

 i:0(?v:fg1+$fp
?\~1+a\~'!':fg:
.\{:o} 1-d1
)?;a1.\o:'~'

Try it

There is already a slightly shorter ><> answer but this one is mine and I'm proud of it.

><> (Fish), 53 bytes

l'~')?v0
v?(0:i<]r+1r[
\~rl'!'(?;
>:  ?vao~22.
\ol-1/

Try it

This version actually completes before the end of the universe, which is nice. Uses the stack instead of the code to store how often each number appears.

><> (Fish), 56 bytes

 i:0(?v:fg1+$fp
?\~1+a\~'!':fg:
.\{:o} 1-d1
)?;a1.\o:'~'

Try it

There is already a slightly shorter ><> answer but this one is mine and I'm proud of it.

><> (Fish), 53 50 bytes

l'~')?v0
v?(0:i<]r+1r[
~
r
>:?vao~l'!'(?;
/  \1-lo

Try it

This version actually completes before the end of the universe, which is nice. Uses the stack instead of the code to store how often each number appears.

added 2376 characters in body
Source Link
mousetail 'he-him'
  • 13.5k
  • 1
  • 39
  • 85

><> (Fish), 56 bytes

 i:0(?v:fg1+$fp
?\~1+a\~'!':fg:
.\{:o} 1-d1
)?;a1.\o:'~'

Try it

There is already a slightly shorter ><> answer but this one is mine and I'm proud of it.

><> (Fish), 53 bytes

l'~')?v0
v?(0:i<]r+1r[
\~rl'!'(?;
>:  ?vao~22.
\ol-1/

Try it

This version actually completes before the end of the universe, which is nice. Uses the stack instead of the code to store how often each number appears.

><> (Fish), 56 bytes

 i:0(?v:fg1+$fp
?\~1+a\~'!':fg:
.\{:o} 1-d1
)?;a1.\o:'~'

Try it

There is already a slightly shorter ><> answer but this one is mine and I'm proud of it.

><> (Fish), 56 bytes

 i:0(?v:fg1+$fp
?\~1+a\~'!':fg:
.\{:o} 1-d1
)?;a1.\o:'~'

Try it

There is already a slightly shorter ><> answer but this one is mine and I'm proud of it.

><> (Fish), 53 bytes

l'~')?v0
v?(0:i<]r+1r[
\~rl'!'(?;
>:  ?vao~22.
\ol-1/

Try it

This version actually completes before the end of the universe, which is nice. Uses the stack instead of the code to store how often each number appears.

Source Link
mousetail 'he-him'
  • 13.5k
  • 1
  • 39
  • 85
Loading