Skip to main content
2 of 2
added 36 characters in body
Neil A.
  • 2.1k
  • 7
  • 22

C++ (gcc), 124 113 bytes

-11 bytes thanks to @ceilingcat

#import<string>
auto a(int n){std::string f;for(int i=30,j,k;++i<127;f+=i*!j,j=n)for(k=i;k;k/=2)j-=k&1;return f;}

Try it online!

Iterates through the printable character codes, finds those that match the number of 1 bits desired, returns the string containing those characters concatenated.

Neil A.
  • 2.1k
  • 7
  • 22