Skip to main content
Saved 3 bytes thanks to @shooqie
Source Link
Copper
  • 4k
  • 1
  • 13
  • 29

Python 3.5+, 77 46 4444 41 bytes

lambda s:[a*s.count(a)for a in set(s){*s}-{' '}]

Pretty simple. Goes through the unique characters in the string by converting it to a set (using Python 3.5's extended iterable unpacking), then uses a list comprehension to construct the exploded diagrams by counting the number of times each character occurs in the string with str.count. We filter out spaces by removing them from the set.

The order of the output may vary from run to run; sets are unordered, so the order in which their items are processed, and thus this answer outputs, cannot be guaranteed.

This is a lambda expression; to use it, prefix lambda with f=.

Try it on Ideone! (Now with all test cases!)Try it on Ideone! Ideone uses Python 3.4, which isn't sufficient.

Usage example:

>>> f=lambda s:[a*s.count(a)for a in set(s){*s}-{' '}]
>>> f('Ah, abracadabra!')
[',', 'A', 'aaaaa', 'd', '!', 'bb', 'h', 'c', 'rr']

Saved 3 bytes thanks to @shooqie!

Python, 77 46 44 bytes

lambda s:[a*s.count(a)for a in set(s)-{' '}]

Pretty simple. Goes through the unique characters in the string by converting it to a set, then uses a list comprehension to construct the exploded diagrams by counting the number of times each character occurs in the string with str.count. We filter out spaces by removing them from the set.

The order of the output may vary from run to run; sets are unordered, so the order in which their items are processed, and thus this answer outputs, cannot be guaranteed.

This is a lambda expression; to use it, prefix lambda with f=.

Try it on Ideone! (Now with all test cases!)

Usage example:

>>> f=lambda s:[a*s.count(a)for a in set(s)-{' '}]
>>> f('Ah, abracadabra!')
[',', 'A', 'aaaaa', 'd', '!', 'bb', 'h', 'c', 'rr']

Python 3.5+, 77 46 44 41 bytes

lambda s:[a*s.count(a)for a in{*s}-{' '}]

Pretty simple. Goes through the unique characters in the string by converting it to a set (using Python 3.5's extended iterable unpacking), then uses a list comprehension to construct the exploded diagrams by counting the number of times each character occurs in the string with str.count. We filter out spaces by removing them from the set.

The order of the output may vary from run to run; sets are unordered, so the order in which their items are processed, and thus this answer outputs, cannot be guaranteed.

This is a lambda expression; to use it, prefix lambda with f=.

Try it on Ideone! Ideone uses Python 3.4, which isn't sufficient.

Usage example:

>>> f=lambda s:[a*s.count(a)for a in{*s}-{' '}]
>>> f('Ah, abracadabra!')
[',', 'A', 'aaaaa', 'd', '!', 'bb', 'h', 'c', 'rr']

Saved 3 bytes thanks to @shooqie!

Add test case notice
Source Link
Copper
  • 4k
  • 1
  • 13
  • 29

Python, 77 46 44 bytes

  
lambda s:[a*s.count(a)for a in set(s)-{' '}]

Pretty simple. Goes through the unique characters in the string by converting it to a set, then uses a list comprehension to construct the exploded diagrams by counting the number of times each character occurs in the string with str.count. We filter out spaces by removing them from the set.

The order of the output may vary from run to run; sets are unordered, so the order in which their items are processed, and thus this answer outputs, cannot be guaranteed.

This is a lambda expression; to use it, prefix lambda with f=.

Try it on Ideone! (Now with all test cases!)

Usage example:

>>> f=lambda s:[a*s.count(a)for a in set(s)-{' '}]
>>> f('Ah, abracadabra!')
[',', 'A', 'aaaaa', 'd', '!', 'bb', 'h', 'c', 'rr']

Python, 77 46 44 bytes

 
lambda s:[a*s.count(a)for a in set(s)-{' '}]

Pretty simple. Goes through the unique characters in the string by converting it to a set, then uses a list comprehension to construct the exploded diagrams by counting the number of times each character occurs in the string with str.count. We filter out spaces by removing them from the set.

This is a lambda expression; to use it, prefix lambda with f=.

Python, 77 46 44 bytes

 
lambda s:[a*s.count(a)for a in set(s)-{' '}]

Pretty simple. Goes through the unique characters in the string by converting it to a set, then uses a list comprehension to construct the exploded diagrams by counting the number of times each character occurs in the string with str.count. We filter out spaces by removing them from the set.

The order of the output may vary from run to run; sets are unordered, so the order in which their items are processed, and thus this answer outputs, cannot be guaranteed.

This is a lambda expression; to use it, prefix lambda with f=.

Try it on Ideone! (Now with all test cases!)

Usage example:

>>> f=lambda s:[a*s.count(a)for a in set(s)-{' '}]
>>> f('Ah, abracadabra!')
[',', 'A', 'aaaaa', 'd', '!', 'bb', 'h', 'c', 'rr']
Saved 2 bytes
Source Link
Copper
  • 4k
  • 1
  • 13
  • 29

Python, 7777 46 44 bytes

from collections import*
lambda s:[a*b [a*s.count(a)for a,b in Counterset(s).items()if'-{' '!=a]}]

Pretty simple. Uses collections.Counter, Python's version of a multiset/bag, to count each thingGoes through the unique characters in the string by converting it to a set, then uses a list comprehension to filter out the spaces and createconstruct the exploded viewsdiagrams by counting the number of times each character occurs in the string with str.count. We filter out spaces by removing them from the set.

This is a lambda expression; to use it, prefix lambda with f=.

Python, 77 bytes

from collections import*
lambda s:[a*b for a,b in Counter(s).items()if' '!=a]

Pretty simple. Uses collections.Counter, Python's version of a multiset/bag, to count each thing in the string, then uses a list comprehension to filter out the spaces and create the exploded views of each character.

This is a lambda expression; to use it, prefix lambda with f=.

Python, 77 46 44 bytes

lambda s:[a*s.count(a)for a in set(s)-{' '}]

Pretty simple. Goes through the unique characters in the string by converting it to a set, then uses a list comprehension to construct the exploded diagrams by counting the number of times each character occurs in the string with str.count. We filter out spaces by removing them from the set.

This is a lambda expression; to use it, prefix lambda with f=.

Source Link
Copper
  • 4k
  • 1
  • 13
  • 29
Loading