(Title with thanks to @ChasBrown)
The Background
This challenge is inspired by a question that I recently posted on Puzzling Stack Exchange. Please feel free to follow the link if you are interested in the original question. If not then I won't bore you with the details here.
The Facts
Every printable standard ASCII character has a decimal value between 32 and 126 inclusive. These can be converted to their corresponding binary numbers in the range 100000 to 1111110 inclusive. When you sum the bits of these binary numbers you will always end up with an integer between 1 and 6 inclusive.
The Challenge
Given an integer between 1 and 6 inclusive as input, write a program or function which will output in any acceptable format all of the printable standard ASCII characters where the sum of the bits of their binary value is equal to the input integer.
The Examples/Test Cases
1 -> ' @'
2 -> '!"$(0ABDHP`'
3 -> '#%&)*,1248CEFIJLQRTXabdhp'
4 -> ''+-.3569:<GKMNSUVYZ\cefijlqrtx'
5 -> '/7;=>OW[]^gkmnsuvyz|'
6 -> '?_ow{}~'
An ungolfed Python reference implementation is available here (TIO).
The Rules
- Assume the input will always be an integer (or string representation of an integer) between 1 and 6 inclusive.
- You may write a program to display the results or a function to return them.
- Output may be in any reasonable format but must be consistent for all inputs. If you choose to output a quoted string then the same type of quotes must be used for all inputs.
- Standard loopholes prohibited as usual.
- This is code golf so shortest code in each language wins.
63
vs?
)? \$\endgroup\$'
) for the string representation of a string by default, but uses double quotes ("
) if the string contain a single quote and no double quotes. Not that this specific case will matter much, as you're probably better off returning the actual string instead of its representation, and you can still use single quotes in such a string for input anyway, but I feel it's worth mentioning here. \$\endgroup\$« »
)? :D \$\endgroup\$