All ASCII characters with a given bit count Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) The PPCG Site design is on its way - help us make it awesome! Sandbox for Proposed ChallengesBiplex: an important useless operatorConvert a “mixed-base” string to ASCIIAll Aboard the ASCII TrainSum of Modulo SumsCount the characters - bit by bit!Calculate the binary split sum of a wordMap inputted ASCII charactersDiluted Integer SumsCount the lucky tickets within the given rangeASCII Art Octagons

Co-worker works way more than he should

Why is arima in R one time step off?

Israeli soda type drink

Marquee sign letters

Writing a T-SQL stored procedure to receive 4 numbers and insert them into a table

How do I deal with an erroneously large refund?

SQL Server placement of master database files vs resource database files

Protagonist's race is hidden - should I reveal it?

Why would the Overseers waste their stock of slaves on the Game?

All ASCII characters with a given bit count

Are there existing rules/lore for MTG planeswalkers?

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

Is it appropriate to mention a relatable company blog post when you're asked about the company?

Feather, the Redeemed and Dire Fleet Daredevil

Why do people think Winterfell crypts is the safest place for women, children & old people?

Has a Nobel Peace laureate ever been accused of war crimes?

What is the ongoing value of the Kanban board to the developers as opposed to management

Why I cannot instantiate a class whose constructor is private in a friend class?

Did war bonds have better investment alternatives during WWII?

"Working on a knee"

Why doesn't the university give past final exams' answers?

/bin/ls sorts differently than just ls

How to keep bees out of canned beverages?

`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY



All ASCII characters with a given bit count



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
The PPCG Site design is on its way - help us make it awesome!
Sandbox for Proposed ChallengesBiplex: an important useless operatorConvert a “mixed-base” string to ASCIIAll Aboard the ASCII TrainSum of Modulo SumsCount the characters - bit by bit!Calculate the binary split sum of a wordMap inputted ASCII charactersDiluted Integer SumsCount the lucky tickets within the given rangeASCII Art Octagons










8












$begingroup$


(Title with thanks to @ChasBrown)



Sandbox



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.



Examples (showing output in four possible acceptable formats)



Input: 1



Output:

" "

"@"



Input: 2



Output: '!"$(0ABDHP`'



Input: 3



Output: "#%&)*,1248CEFIJLQRTXabdhp"



Input: 6



Output: ['?', '_', 'o', 'w', '', '', '~']



The Rules



  1. Assume the input will always be an integer (or string representation of an integer) between 1 and 6 inclusive.

  2. You may write a program to display the results or a function to return them.

  3. Output may be in any acceptable 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.

  4. Standard loopholes prohibited as usual.

  5. This is code golf so shortest code in each language wins.

Test Cases



A full set of expected results is available here (TIO) (ungolfed Python implementation).










share|improve this question









$endgroup$











  • $begingroup$
    Are we allowed to return/print a list of the decimal ascii values or do we need to have them in the form of characters (eg. 63 vs ?)?
    $endgroup$
    – Benjamin Urquhart
    4 hours ago






  • 1




    $begingroup$
    Must be the actual characters.
    $endgroup$
    – ElPedro
    4 hours ago






  • 1




    $begingroup$
    "the same type of quotes must be used for all inputs" Python, for example, uses single quotes (') 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$
    – Erik the Outgolfer
    4 hours ago











  • $begingroup$
    @EriktheOutgolfer Agreed. That is why I thought it might be interesting just to throw that in as an extra rule :-)
    $endgroup$
    – ElPedro
    1 hour ago















8












$begingroup$


(Title with thanks to @ChasBrown)



Sandbox



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.



Examples (showing output in four possible acceptable formats)



Input: 1



Output:

" "

"@"



Input: 2



Output: '!"$(0ABDHP`'



Input: 3



Output: "#%&)*,1248CEFIJLQRTXabdhp"



Input: 6



Output: ['?', '_', 'o', 'w', '', '', '~']



The Rules



  1. Assume the input will always be an integer (or string representation of an integer) between 1 and 6 inclusive.

  2. You may write a program to display the results or a function to return them.

  3. Output may be in any acceptable 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.

  4. Standard loopholes prohibited as usual.

  5. This is code golf so shortest code in each language wins.

Test Cases



A full set of expected results is available here (TIO) (ungolfed Python implementation).










share|improve this question









$endgroup$











  • $begingroup$
    Are we allowed to return/print a list of the decimal ascii values or do we need to have them in the form of characters (eg. 63 vs ?)?
    $endgroup$
    – Benjamin Urquhart
    4 hours ago






  • 1




    $begingroup$
    Must be the actual characters.
    $endgroup$
    – ElPedro
    4 hours ago






  • 1




    $begingroup$
    "the same type of quotes must be used for all inputs" Python, for example, uses single quotes (') 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$
    – Erik the Outgolfer
    4 hours ago











  • $begingroup$
    @EriktheOutgolfer Agreed. That is why I thought it might be interesting just to throw that in as an extra rule :-)
    $endgroup$
    – ElPedro
    1 hour ago













8












8








8


1



$begingroup$


(Title with thanks to @ChasBrown)



Sandbox



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.



Examples (showing output in four possible acceptable formats)



Input: 1



Output:

" "

"@"



Input: 2



Output: '!"$(0ABDHP`'



Input: 3



Output: "#%&)*,1248CEFIJLQRTXabdhp"



Input: 6



Output: ['?', '_', 'o', 'w', '', '', '~']



The Rules



  1. Assume the input will always be an integer (or string representation of an integer) between 1 and 6 inclusive.

  2. You may write a program to display the results or a function to return them.

  3. Output may be in any acceptable 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.

  4. Standard loopholes prohibited as usual.

  5. This is code golf so shortest code in each language wins.

Test Cases



A full set of expected results is available here (TIO) (ungolfed Python implementation).










share|improve this question









$endgroup$




(Title with thanks to @ChasBrown)



Sandbox



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.



Examples (showing output in four possible acceptable formats)



Input: 1



Output:

" "

"@"



Input: 2



Output: '!"$(0ABDHP`'



Input: 3



Output: "#%&)*,1248CEFIJLQRTXabdhp"



Input: 6



Output: ['?', '_', 'o', 'w', '', '', '~']



The Rules



  1. Assume the input will always be an integer (or string representation of an integer) between 1 and 6 inclusive.

  2. You may write a program to display the results or a function to return them.

  3. Output may be in any acceptable 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.

  4. Standard loopholes prohibited as usual.

  5. This is code golf so shortest code in each language wins.

Test Cases



A full set of expected results is available here (TIO) (ungolfed Python implementation).







code-golf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 5 hours ago









ElPedroElPedro

3,6031023




3,6031023











  • $begingroup$
    Are we allowed to return/print a list of the decimal ascii values or do we need to have them in the form of characters (eg. 63 vs ?)?
    $endgroup$
    – Benjamin Urquhart
    4 hours ago






  • 1




    $begingroup$
    Must be the actual characters.
    $endgroup$
    – ElPedro
    4 hours ago






  • 1




    $begingroup$
    "the same type of quotes must be used for all inputs" Python, for example, uses single quotes (') 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$
    – Erik the Outgolfer
    4 hours ago











  • $begingroup$
    @EriktheOutgolfer Agreed. That is why I thought it might be interesting just to throw that in as an extra rule :-)
    $endgroup$
    – ElPedro
    1 hour ago
















  • $begingroup$
    Are we allowed to return/print a list of the decimal ascii values or do we need to have them in the form of characters (eg. 63 vs ?)?
    $endgroup$
    – Benjamin Urquhart
    4 hours ago






  • 1




    $begingroup$
    Must be the actual characters.
    $endgroup$
    – ElPedro
    4 hours ago






  • 1




    $begingroup$
    "the same type of quotes must be used for all inputs" Python, for example, uses single quotes (') 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$
    – Erik the Outgolfer
    4 hours ago











  • $begingroup$
    @EriktheOutgolfer Agreed. That is why I thought it might be interesting just to throw that in as an extra rule :-)
    $endgroup$
    – ElPedro
    1 hour ago















$begingroup$
Are we allowed to return/print a list of the decimal ascii values or do we need to have them in the form of characters (eg. 63 vs ?)?
$endgroup$
– Benjamin Urquhart
4 hours ago




$begingroup$
Are we allowed to return/print a list of the decimal ascii values or do we need to have them in the form of characters (eg. 63 vs ?)?
$endgroup$
– Benjamin Urquhart
4 hours ago




1




1




$begingroup$
Must be the actual characters.
$endgroup$
– ElPedro
4 hours ago




$begingroup$
Must be the actual characters.
$endgroup$
– ElPedro
4 hours ago




1




1




$begingroup$
"the same type of quotes must be used for all inputs" Python, for example, uses single quotes (') 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$
– Erik the Outgolfer
4 hours ago





$begingroup$
"the same type of quotes must be used for all inputs" Python, for example, uses single quotes (') 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$
– Erik the Outgolfer
4 hours ago













$begingroup$
@EriktheOutgolfer Agreed. That is why I thought it might be interesting just to throw that in as an extra rule :-)
$endgroup$
– ElPedro
1 hour ago




$begingroup$
@EriktheOutgolfer Agreed. That is why I thought it might be interesting just to throw that in as an extra rule :-)
$endgroup$
– ElPedro
1 hour ago










17 Answers
17






active

oldest

votes


















5












$begingroup$

8088 assembly, IBM PC DOS, 35 34 bytes



Machine code:



be81 00ad 80ec 308a f433 db8a c8d0 e973 0143 75f9 3af3 7504 b40e cd10 403c 7e7e e8c3


Listing:



BE 0081 MOV SI, 081H ; address of DOS PSP command line
AD LODSW ; load space (20H) and value from command line
80 EC 30 SUB AH, '0' ; convert to numeric value
8A F4 MOV DH, AH ; AL = counter, DH = target value
CHR_LOOP:
33 DB XOR BX, BX ; clear bit counter
8A C8 MOV CL, AL ; current char to CL for test
BIT_LOOP:
D0 E9 SHR CL, 1 ; shift LSB to CF
73 01 JNC EBIT_LOOP ; if LSB = 0, don't increment
43 INC BX ; increment '1' bit counter
EBIT_LOOP:
75 F9 JNZ BIT_LOOP ; loop until CL = 0
3A F3 CMP DH, BL ; is current char the target value?
75 04 JNE ECHR_LOOP ; if not, do not display
B4 0E MOV AH, 0EH ; BIOS write char function
CD 10 INT 10H ; write AL to screen
ECHR_LOOP:
40 INC AX ; increment char loop
3C 7E CMP AL, 126 ; is char <= 126?
7E E8 JLE CHR_LOOP ; if so, keep looping
C3 RET ; return to DOS


Standalone PC DOS executable program, input number from command line. Output is displayed to console window.



enter image description here



Download and test ABCT.COM.






share|improve this answer











$endgroup$




















    3












    $begingroup$


    05AB1E, 8 bytes



    žQʒÇbSOQ


    Try it online!



    Explanation



    žQ # push the printable ascii characters
    ʒ # filter, keep elements whose
    Ç # character code
    b # converted to binary
    SO # has a digit sum
    Q # equal to the input





    share|improve this answer









    $endgroup$




















      3












      $begingroup$


      Python 2, 62 bytes





      lambda n:[chr(i)for i in range(32,127)if bin(i).count('1')==n]


      Try it online!






      share|improve this answer









      $endgroup$












      • $begingroup$
        I was trying to make count work but couldn't quite work out how. Respect as always.
        $endgroup$
        – ElPedro
        56 mins ago


















      3












      $begingroup$


      Japt, 9 bytes



      ;EƶXc¤è1


      Try it



      ;EƶXc¤è1 :Implicit input of integer U
      ;E :Printable ASCII
      Æ :Filter each X
      ¶ :Test U for equality with
      Xc : Character code of X
      ¤ : To binary string
      è1 : Count the 1s





      share|improve this answer









      $endgroup$




















        2












        $begingroup$


        Wolfram Language (Mathematica), 70 bytes



        FromCharacterCode/@Select[32~Range~126,s=#;Tr@IntegerDigits[#,2]==s&]&


        Try it online!






        share|improve this answer









        $endgroup$




















          2












          $begingroup$


          Python 2, 69 bytes





          lambda n:[chr(i)for i in range(32,127)if sum(map(int,bin(i)[2:]))==n]


          Try it online!






          share|improve this answer









          $endgroup$












          • $begingroup$
            That's exactly what I got when I golfed my ref implementation. +1
            $endgroup$
            – ElPedro
            4 hours ago


















          2












          $begingroup$


          Gaia, 10 bytes



          ₵R⟪¤cbΣ=⟫⁇


          Try it online!



          		| implicit input, n
          ₵R | push printable ascii
          ⟪ ⟫⁇ | filter the list where:
          ¤cbΣ | the sum of the code point in binary
          = | is equal to n





          share|improve this answer









          $endgroup$




















            2












            $begingroup$

            Java 8, 131 bytes



            Returns a java.util.stream.Stream<String>



            n->java.util.stream.IntStream.range(32,127).filter(i->Long.toBinaryString(i).chars().map(c->c-48).sum()==n).mapToObj(c->(char)c+"")


            Try it online!


            Using HashSet, 135 bytes. Returns a Set<Object>:



            n->new java.util.HashSet()for(int i=31;i++<126;add(Long.toBinaryString(i).chars().map(c->c-48).sum()==n?(char)i+"":""),remove(""));


            Try it online!






            share|improve this answer











            $endgroup$












            • $begingroup$
              128 bytes
              $endgroup$
              – Expired Data
              41 mins ago






            • 1




              $begingroup$
              Static access from non-static context reeeeeee. Thanks.
              $endgroup$
              – Benjamin Urquhart
              40 mins ago


















            2












            $begingroup$


            Jelly, 8 bytes



            ØṖOB§=ʋƇ


            Try it online!



            ØṖ printable ascii character list
            OB to binary
            § popcount
            = equal to input?
            ʋƇ filter (implicitly output)





            share|improve this answer









            $endgroup$




















              2












              $begingroup$

              Dyalog APL Extended, 24 bytes



              ⎕ucs a⌿⍨(+⌿2⊤a←32…126)∘=


              Try it online!



              25 bytes in dzaima/APL:



              ⎕ucs a⌿⍨(+/¨2⊤¨a←32…126)=


              Try it online!






              share|improve this answer











              $endgroup$




















                2












                $begingroup$


                JavaScript (Node.js),  70  69 bytes





                n=>(g=x=>x>>7?'':Buffer((h=x=>x&&x%2+h(x>>1))(x)-n?0:[x])+g(x+1))(32)


                Try it online!






                share|improve this answer











                $endgroup$




















                  2












                  $begingroup$


                  PowerShell, 83 bytes





                  param($n)[char[]](32..126|?([convert]::ToString($_,2))


                  Try it online!



                  Takes input $n, constructs a range from 32 to 126 and pulls out those numbers where |?: the number, converted ToString in base 2; converted toCharArray; grouped into 0s and 1s; taking the [1] index of that grouping; taking the .count thereof, and checking that it's -equal to our input $number. Those numbers are then cast as a char-array and left on the pipeline. Output is implicit, with newlines between elements.






                  share|improve this answer









                  $endgroup$




















                    2












                    $begingroup$


                    PHP, 72 bytes





                    for($x=31;$x++<126;)echo$argn==count_chars(decbin($x),1)[49]?chr($x):'';


                    Try it online!






                    share|improve this answer








                    New contributor




                    Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.






                    $endgroup$




















                      1












                      $begingroup$


                      Ruby, 48 bytes





                      ->n(' '..?~).selectx.ord.digits(2).sum==n


                      Try it online!






                      share|improve this answer









                      $endgroup$




















                        1












                        $begingroup$


                        Perl 5 -a, 50 bytes





                        map(sprintf'%b',$_)=~y/1//-$F[0]32..126


                        Try it online!






                        share|improve this answer









                        $endgroup$




















                          1












                          $begingroup$


                          Charcoal, 10 bytes



                          Φγ⁼Σ↨℅ι²Iθ


                          Try it online! Link is to verbose version of code. Explanation:



                           γ Predefined ASCII characters
                          Φ Filtered by
                          ι Current character's
                          ℅ ASCII code
                          ↨ Converted to base
                          ² Literal 2
                          Σ Summed
                          ⁼ Equals
                          θ First input
                          I Cast to integer
                          Implicitly printed





                          share|improve this answer









                          $endgroup$




















                            1












                            $begingroup$

                            Excel (2016 or later), 76 bytes



                            =CONCAT(IF(LEN(SUBSTITUTE(DEC2BIN(ROW(32:126)),0,))=A1,CHAR(ROW(32:126)),""))


                            Takes input from A1, outputs in whatever cell you put this formula. This is an array formula, so you need to press Ctrl-Shift-Enter to input it. The "2016 or later" is because it needs the CONCAT function (the deprecated CONCATENATE won't take an array as argument).






                            share|improve this answer









                            $endgroup$












                            • $begingroup$
                              I like this. I'm a Lotus Notes and 123 guy so this works for me :-)
                              $endgroup$
                              – ElPedro
                              52 mins ago











                            Your Answer






                            StackExchange.ifUsing("editor", function ()
                            StackExchange.using("externalEditor", function ()
                            StackExchange.using("snippets", function ()
                            StackExchange.snippets.init();
                            );
                            );
                            , "code-snippets");

                            StackExchange.ready(function()
                            var channelOptions =
                            tags: "".split(" "),
                            id: "200"
                            ;
                            initTagRenderer("".split(" "), "".split(" "), channelOptions);

                            StackExchange.using("externalEditor", function()
                            // Have to fire editor after snippets, if snippets enabled
                            if (StackExchange.settings.snippets.snippetsEnabled)
                            StackExchange.using("snippets", function()
                            createEditor();
                            );

                            else
                            createEditor();

                            );

                            function createEditor()
                            StackExchange.prepareEditor(
                            heartbeatType: 'answer',
                            autoActivateHeartbeat: false,
                            convertImagesToLinks: false,
                            noModals: true,
                            showLowRepImageUploadWarning: true,
                            reputationToPostImages: null,
                            bindNavPrevention: true,
                            postfix: "",
                            imageUploader:
                            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                            allowUrls: true
                            ,
                            onDemand: true,
                            discardSelector: ".discard-answer"
                            ,immediatelyShowMarkdownHelp:true
                            );



                            );













                            draft saved

                            draft discarded


















                            StackExchange.ready(
                            function ()
                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183625%2fall-ascii-characters-with-a-given-bit-count%23new-answer', 'question_page');

                            );

                            Post as a guest















                            Required, but never shown

























                            17 Answers
                            17






                            active

                            oldest

                            votes








                            17 Answers
                            17






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes









                            5












                            $begingroup$

                            8088 assembly, IBM PC DOS, 35 34 bytes



                            Machine code:



                            be81 00ad 80ec 308a f433 db8a c8d0 e973 0143 75f9 3af3 7504 b40e cd10 403c 7e7e e8c3


                            Listing:



                            BE 0081 MOV SI, 081H ; address of DOS PSP command line
                            AD LODSW ; load space (20H) and value from command line
                            80 EC 30 SUB AH, '0' ; convert to numeric value
                            8A F4 MOV DH, AH ; AL = counter, DH = target value
                            CHR_LOOP:
                            33 DB XOR BX, BX ; clear bit counter
                            8A C8 MOV CL, AL ; current char to CL for test
                            BIT_LOOP:
                            D0 E9 SHR CL, 1 ; shift LSB to CF
                            73 01 JNC EBIT_LOOP ; if LSB = 0, don't increment
                            43 INC BX ; increment '1' bit counter
                            EBIT_LOOP:
                            75 F9 JNZ BIT_LOOP ; loop until CL = 0
                            3A F3 CMP DH, BL ; is current char the target value?
                            75 04 JNE ECHR_LOOP ; if not, do not display
                            B4 0E MOV AH, 0EH ; BIOS write char function
                            CD 10 INT 10H ; write AL to screen
                            ECHR_LOOP:
                            40 INC AX ; increment char loop
                            3C 7E CMP AL, 126 ; is char <= 126?
                            7E E8 JLE CHR_LOOP ; if so, keep looping
                            C3 RET ; return to DOS


                            Standalone PC DOS executable program, input number from command line. Output is displayed to console window.



                            enter image description here



                            Download and test ABCT.COM.






                            share|improve this answer











                            $endgroup$

















                              5












                              $begingroup$

                              8088 assembly, IBM PC DOS, 35 34 bytes



                              Machine code:



                              be81 00ad 80ec 308a f433 db8a c8d0 e973 0143 75f9 3af3 7504 b40e cd10 403c 7e7e e8c3


                              Listing:



                              BE 0081 MOV SI, 081H ; address of DOS PSP command line
                              AD LODSW ; load space (20H) and value from command line
                              80 EC 30 SUB AH, '0' ; convert to numeric value
                              8A F4 MOV DH, AH ; AL = counter, DH = target value
                              CHR_LOOP:
                              33 DB XOR BX, BX ; clear bit counter
                              8A C8 MOV CL, AL ; current char to CL for test
                              BIT_LOOP:
                              D0 E9 SHR CL, 1 ; shift LSB to CF
                              73 01 JNC EBIT_LOOP ; if LSB = 0, don't increment
                              43 INC BX ; increment '1' bit counter
                              EBIT_LOOP:
                              75 F9 JNZ BIT_LOOP ; loop until CL = 0
                              3A F3 CMP DH, BL ; is current char the target value?
                              75 04 JNE ECHR_LOOP ; if not, do not display
                              B4 0E MOV AH, 0EH ; BIOS write char function
                              CD 10 INT 10H ; write AL to screen
                              ECHR_LOOP:
                              40 INC AX ; increment char loop
                              3C 7E CMP AL, 126 ; is char <= 126?
                              7E E8 JLE CHR_LOOP ; if so, keep looping
                              C3 RET ; return to DOS


                              Standalone PC DOS executable program, input number from command line. Output is displayed to console window.



                              enter image description here



                              Download and test ABCT.COM.






                              share|improve this answer











                              $endgroup$















                                5












                                5








                                5





                                $begingroup$

                                8088 assembly, IBM PC DOS, 35 34 bytes



                                Machine code:



                                be81 00ad 80ec 308a f433 db8a c8d0 e973 0143 75f9 3af3 7504 b40e cd10 403c 7e7e e8c3


                                Listing:



                                BE 0081 MOV SI, 081H ; address of DOS PSP command line
                                AD LODSW ; load space (20H) and value from command line
                                80 EC 30 SUB AH, '0' ; convert to numeric value
                                8A F4 MOV DH, AH ; AL = counter, DH = target value
                                CHR_LOOP:
                                33 DB XOR BX, BX ; clear bit counter
                                8A C8 MOV CL, AL ; current char to CL for test
                                BIT_LOOP:
                                D0 E9 SHR CL, 1 ; shift LSB to CF
                                73 01 JNC EBIT_LOOP ; if LSB = 0, don't increment
                                43 INC BX ; increment '1' bit counter
                                EBIT_LOOP:
                                75 F9 JNZ BIT_LOOP ; loop until CL = 0
                                3A F3 CMP DH, BL ; is current char the target value?
                                75 04 JNE ECHR_LOOP ; if not, do not display
                                B4 0E MOV AH, 0EH ; BIOS write char function
                                CD 10 INT 10H ; write AL to screen
                                ECHR_LOOP:
                                40 INC AX ; increment char loop
                                3C 7E CMP AL, 126 ; is char <= 126?
                                7E E8 JLE CHR_LOOP ; if so, keep looping
                                C3 RET ; return to DOS


                                Standalone PC DOS executable program, input number from command line. Output is displayed to console window.



                                enter image description here



                                Download and test ABCT.COM.






                                share|improve this answer











                                $endgroup$



                                8088 assembly, IBM PC DOS, 35 34 bytes



                                Machine code:



                                be81 00ad 80ec 308a f433 db8a c8d0 e973 0143 75f9 3af3 7504 b40e cd10 403c 7e7e e8c3


                                Listing:



                                BE 0081 MOV SI, 081H ; address of DOS PSP command line
                                AD LODSW ; load space (20H) and value from command line
                                80 EC 30 SUB AH, '0' ; convert to numeric value
                                8A F4 MOV DH, AH ; AL = counter, DH = target value
                                CHR_LOOP:
                                33 DB XOR BX, BX ; clear bit counter
                                8A C8 MOV CL, AL ; current char to CL for test
                                BIT_LOOP:
                                D0 E9 SHR CL, 1 ; shift LSB to CF
                                73 01 JNC EBIT_LOOP ; if LSB = 0, don't increment
                                43 INC BX ; increment '1' bit counter
                                EBIT_LOOP:
                                75 F9 JNZ BIT_LOOP ; loop until CL = 0
                                3A F3 CMP DH, BL ; is current char the target value?
                                75 04 JNE ECHR_LOOP ; if not, do not display
                                B4 0E MOV AH, 0EH ; BIOS write char function
                                CD 10 INT 10H ; write AL to screen
                                ECHR_LOOP:
                                40 INC AX ; increment char loop
                                3C 7E CMP AL, 126 ; is char <= 126?
                                7E E8 JLE CHR_LOOP ; if so, keep looping
                                C3 RET ; return to DOS


                                Standalone PC DOS executable program, input number from command line. Output is displayed to console window.



                                enter image description here



                                Download and test ABCT.COM.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 2 hours ago

























                                answered 3 hours ago









                                gwaughgwaugh

                                2,4981619




                                2,4981619





















                                    3












                                    $begingroup$


                                    05AB1E, 8 bytes



                                    žQʒÇbSOQ


                                    Try it online!



                                    Explanation



                                    žQ # push the printable ascii characters
                                    ʒ # filter, keep elements whose
                                    Ç # character code
                                    b # converted to binary
                                    SO # has a digit sum
                                    Q # equal to the input





                                    share|improve this answer









                                    $endgroup$

















                                      3












                                      $begingroup$


                                      05AB1E, 8 bytes



                                      žQʒÇbSOQ


                                      Try it online!



                                      Explanation



                                      žQ # push the printable ascii characters
                                      ʒ # filter, keep elements whose
                                      Ç # character code
                                      b # converted to binary
                                      SO # has a digit sum
                                      Q # equal to the input





                                      share|improve this answer









                                      $endgroup$















                                        3












                                        3








                                        3





                                        $begingroup$


                                        05AB1E, 8 bytes



                                        žQʒÇbSOQ


                                        Try it online!



                                        Explanation



                                        žQ # push the printable ascii characters
                                        ʒ # filter, keep elements whose
                                        Ç # character code
                                        b # converted to binary
                                        SO # has a digit sum
                                        Q # equal to the input





                                        share|improve this answer









                                        $endgroup$




                                        05AB1E, 8 bytes



                                        žQʒÇbSOQ


                                        Try it online!



                                        Explanation



                                        žQ # push the printable ascii characters
                                        ʒ # filter, keep elements whose
                                        Ç # character code
                                        b # converted to binary
                                        SO # has a digit sum
                                        Q # equal to the input






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 4 hours ago









                                        EmignaEmigna

                                        48.3k434147




                                        48.3k434147





















                                            3












                                            $begingroup$


                                            Python 2, 62 bytes





                                            lambda n:[chr(i)for i in range(32,127)if bin(i).count('1')==n]


                                            Try it online!






                                            share|improve this answer









                                            $endgroup$












                                            • $begingroup$
                                              I was trying to make count work but couldn't quite work out how. Respect as always.
                                              $endgroup$
                                              – ElPedro
                                              56 mins ago















                                            3












                                            $begingroup$


                                            Python 2, 62 bytes





                                            lambda n:[chr(i)for i in range(32,127)if bin(i).count('1')==n]


                                            Try it online!






                                            share|improve this answer









                                            $endgroup$












                                            • $begingroup$
                                              I was trying to make count work but couldn't quite work out how. Respect as always.
                                              $endgroup$
                                              – ElPedro
                                              56 mins ago













                                            3












                                            3








                                            3





                                            $begingroup$


                                            Python 2, 62 bytes





                                            lambda n:[chr(i)for i in range(32,127)if bin(i).count('1')==n]


                                            Try it online!






                                            share|improve this answer









                                            $endgroup$




                                            Python 2, 62 bytes





                                            lambda n:[chr(i)for i in range(32,127)if bin(i).count('1')==n]


                                            Try it online!







                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered 4 hours ago









                                            LynnLynn

                                            51.2k899234




                                            51.2k899234











                                            • $begingroup$
                                              I was trying to make count work but couldn't quite work out how. Respect as always.
                                              $endgroup$
                                              – ElPedro
                                              56 mins ago
















                                            • $begingroup$
                                              I was trying to make count work but couldn't quite work out how. Respect as always.
                                              $endgroup$
                                              – ElPedro
                                              56 mins ago















                                            $begingroup$
                                            I was trying to make count work but couldn't quite work out how. Respect as always.
                                            $endgroup$
                                            – ElPedro
                                            56 mins ago




                                            $begingroup$
                                            I was trying to make count work but couldn't quite work out how. Respect as always.
                                            $endgroup$
                                            – ElPedro
                                            56 mins ago











                                            3












                                            $begingroup$


                                            Japt, 9 bytes



                                            ;EƶXc¤è1


                                            Try it



                                            ;EƶXc¤è1 :Implicit input of integer U
                                            ;E :Printable ASCII
                                            Æ :Filter each X
                                            ¶ :Test U for equality with
                                            Xc : Character code of X
                                            ¤ : To binary string
                                            è1 : Count the 1s





                                            share|improve this answer









                                            $endgroup$

















                                              3












                                              $begingroup$


                                              Japt, 9 bytes



                                              ;EƶXc¤è1


                                              Try it



                                              ;EƶXc¤è1 :Implicit input of integer U
                                              ;E :Printable ASCII
                                              Æ :Filter each X
                                              ¶ :Test U for equality with
                                              Xc : Character code of X
                                              ¤ : To binary string
                                              è1 : Count the 1s





                                              share|improve this answer









                                              $endgroup$















                                                3












                                                3








                                                3





                                                $begingroup$


                                                Japt, 9 bytes



                                                ;EƶXc¤è1


                                                Try it



                                                ;EƶXc¤è1 :Implicit input of integer U
                                                ;E :Printable ASCII
                                                Æ :Filter each X
                                                ¶ :Test U for equality with
                                                Xc : Character code of X
                                                ¤ : To binary string
                                                è1 : Count the 1s





                                                share|improve this answer









                                                $endgroup$




                                                Japt, 9 bytes



                                                ;EƶXc¤è1


                                                Try it



                                                ;EƶXc¤è1 :Implicit input of integer U
                                                ;E :Printable ASCII
                                                Æ :Filter each X
                                                ¶ :Test U for equality with
                                                Xc : Character code of X
                                                ¤ : To binary string
                                                è1 : Count the 1s






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered 4 hours ago









                                                ShaggyShaggy

                                                19.1k21768




                                                19.1k21768





















                                                    2












                                                    $begingroup$


                                                    Wolfram Language (Mathematica), 70 bytes



                                                    FromCharacterCode/@Select[32~Range~126,s=#;Tr@IntegerDigits[#,2]==s&]&


                                                    Try it online!






                                                    share|improve this answer









                                                    $endgroup$

















                                                      2












                                                      $begingroup$


                                                      Wolfram Language (Mathematica), 70 bytes



                                                      FromCharacterCode/@Select[32~Range~126,s=#;Tr@IntegerDigits[#,2]==s&]&


                                                      Try it online!






                                                      share|improve this answer









                                                      $endgroup$















                                                        2












                                                        2








                                                        2





                                                        $begingroup$


                                                        Wolfram Language (Mathematica), 70 bytes



                                                        FromCharacterCode/@Select[32~Range~126,s=#;Tr@IntegerDigits[#,2]==s&]&


                                                        Try it online!






                                                        share|improve this answer









                                                        $endgroup$




                                                        Wolfram Language (Mathematica), 70 bytes



                                                        FromCharacterCode/@Select[32~Range~126,s=#;Tr@IntegerDigits[#,2]==s&]&


                                                        Try it online!







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered 4 hours ago









                                                        J42161217J42161217

                                                        14.4k21354




                                                        14.4k21354





















                                                            2












                                                            $begingroup$


                                                            Python 2, 69 bytes





                                                            lambda n:[chr(i)for i in range(32,127)if sum(map(int,bin(i)[2:]))==n]


                                                            Try it online!






                                                            share|improve this answer









                                                            $endgroup$












                                                            • $begingroup$
                                                              That's exactly what I got when I golfed my ref implementation. +1
                                                              $endgroup$
                                                              – ElPedro
                                                              4 hours ago















                                                            2












                                                            $begingroup$


                                                            Python 2, 69 bytes





                                                            lambda n:[chr(i)for i in range(32,127)if sum(map(int,bin(i)[2:]))==n]


                                                            Try it online!






                                                            share|improve this answer









                                                            $endgroup$












                                                            • $begingroup$
                                                              That's exactly what I got when I golfed my ref implementation. +1
                                                              $endgroup$
                                                              – ElPedro
                                                              4 hours ago













                                                            2












                                                            2








                                                            2





                                                            $begingroup$


                                                            Python 2, 69 bytes





                                                            lambda n:[chr(i)for i in range(32,127)if sum(map(int,bin(i)[2:]))==n]


                                                            Try it online!






                                                            share|improve this answer









                                                            $endgroup$




                                                            Python 2, 69 bytes





                                                            lambda n:[chr(i)for i in range(32,127)if sum(map(int,bin(i)[2:]))==n]


                                                            Try it online!







                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered 4 hours ago









                                                            NeilNeil

                                                            2,002324




                                                            2,002324











                                                            • $begingroup$
                                                              That's exactly what I got when I golfed my ref implementation. +1
                                                              $endgroup$
                                                              – ElPedro
                                                              4 hours ago
















                                                            • $begingroup$
                                                              That's exactly what I got when I golfed my ref implementation. +1
                                                              $endgroup$
                                                              – ElPedro
                                                              4 hours ago















                                                            $begingroup$
                                                            That's exactly what I got when I golfed my ref implementation. +1
                                                            $endgroup$
                                                            – ElPedro
                                                            4 hours ago




                                                            $begingroup$
                                                            That's exactly what I got when I golfed my ref implementation. +1
                                                            $endgroup$
                                                            – ElPedro
                                                            4 hours ago











                                                            2












                                                            $begingroup$


                                                            Gaia, 10 bytes



                                                            ₵R⟪¤cbΣ=⟫⁇


                                                            Try it online!



                                                            		| implicit input, n
                                                            ₵R | push printable ascii
                                                            ⟪ ⟫⁇ | filter the list where:
                                                            ¤cbΣ | the sum of the code point in binary
                                                            = | is equal to n





                                                            share|improve this answer









                                                            $endgroup$

















                                                              2












                                                              $begingroup$


                                                              Gaia, 10 bytes



                                                              ₵R⟪¤cbΣ=⟫⁇


                                                              Try it online!



                                                              		| implicit input, n
                                                              ₵R | push printable ascii
                                                              ⟪ ⟫⁇ | filter the list where:
                                                              ¤cbΣ | the sum of the code point in binary
                                                              = | is equal to n





                                                              share|improve this answer









                                                              $endgroup$















                                                                2












                                                                2








                                                                2





                                                                $begingroup$


                                                                Gaia, 10 bytes



                                                                ₵R⟪¤cbΣ=⟫⁇


                                                                Try it online!



                                                                		| implicit input, n
                                                                ₵R | push printable ascii
                                                                ⟪ ⟫⁇ | filter the list where:
                                                                ¤cbΣ | the sum of the code point in binary
                                                                = | is equal to n





                                                                share|improve this answer









                                                                $endgroup$




                                                                Gaia, 10 bytes



                                                                ₵R⟪¤cbΣ=⟫⁇


                                                                Try it online!



                                                                		| implicit input, n
                                                                ₵R | push printable ascii
                                                                ⟪ ⟫⁇ | filter the list where:
                                                                ¤cbΣ | the sum of the code point in binary
                                                                = | is equal to n






                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered 4 hours ago









                                                                GiuseppeGiuseppe

                                                                18k31155




                                                                18k31155





















                                                                    2












                                                                    $begingroup$

                                                                    Java 8, 131 bytes



                                                                    Returns a java.util.stream.Stream<String>



                                                                    n->java.util.stream.IntStream.range(32,127).filter(i->Long.toBinaryString(i).chars().map(c->c-48).sum()==n).mapToObj(c->(char)c+"")


                                                                    Try it online!


                                                                    Using HashSet, 135 bytes. Returns a Set<Object>:



                                                                    n->new java.util.HashSet()for(int i=31;i++<126;add(Long.toBinaryString(i).chars().map(c->c-48).sum()==n?(char)i+"":""),remove(""));


                                                                    Try it online!






                                                                    share|improve this answer











                                                                    $endgroup$












                                                                    • $begingroup$
                                                                      128 bytes
                                                                      $endgroup$
                                                                      – Expired Data
                                                                      41 mins ago






                                                                    • 1




                                                                      $begingroup$
                                                                      Static access from non-static context reeeeeee. Thanks.
                                                                      $endgroup$
                                                                      – Benjamin Urquhart
                                                                      40 mins ago















                                                                    2












                                                                    $begingroup$

                                                                    Java 8, 131 bytes



                                                                    Returns a java.util.stream.Stream<String>



                                                                    n->java.util.stream.IntStream.range(32,127).filter(i->Long.toBinaryString(i).chars().map(c->c-48).sum()==n).mapToObj(c->(char)c+"")


                                                                    Try it online!


                                                                    Using HashSet, 135 bytes. Returns a Set<Object>:



                                                                    n->new java.util.HashSet()for(int i=31;i++<126;add(Long.toBinaryString(i).chars().map(c->c-48).sum()==n?(char)i+"":""),remove(""));


                                                                    Try it online!






                                                                    share|improve this answer











                                                                    $endgroup$












                                                                    • $begingroup$
                                                                      128 bytes
                                                                      $endgroup$
                                                                      – Expired Data
                                                                      41 mins ago






                                                                    • 1




                                                                      $begingroup$
                                                                      Static access from non-static context reeeeeee. Thanks.
                                                                      $endgroup$
                                                                      – Benjamin Urquhart
                                                                      40 mins ago













                                                                    2












                                                                    2








                                                                    2





                                                                    $begingroup$

                                                                    Java 8, 131 bytes



                                                                    Returns a java.util.stream.Stream<String>



                                                                    n->java.util.stream.IntStream.range(32,127).filter(i->Long.toBinaryString(i).chars().map(c->c-48).sum()==n).mapToObj(c->(char)c+"")


                                                                    Try it online!


                                                                    Using HashSet, 135 bytes. Returns a Set<Object>:



                                                                    n->new java.util.HashSet()for(int i=31;i++<126;add(Long.toBinaryString(i).chars().map(c->c-48).sum()==n?(char)i+"":""),remove(""));


                                                                    Try it online!






                                                                    share|improve this answer











                                                                    $endgroup$



                                                                    Java 8, 131 bytes



                                                                    Returns a java.util.stream.Stream<String>



                                                                    n->java.util.stream.IntStream.range(32,127).filter(i->Long.toBinaryString(i).chars().map(c->c-48).sum()==n).mapToObj(c->(char)c+"")


                                                                    Try it online!


                                                                    Using HashSet, 135 bytes. Returns a Set<Object>:



                                                                    n->new java.util.HashSet()for(int i=31;i++<126;add(Long.toBinaryString(i).chars().map(c->c-48).sum()==n?(char)i+"":""),remove(""));


                                                                    Try it online!







                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited 4 hours ago

























                                                                    answered 4 hours ago









                                                                    Benjamin UrquhartBenjamin Urquhart

                                                                    688111




                                                                    688111











                                                                    • $begingroup$
                                                                      128 bytes
                                                                      $endgroup$
                                                                      – Expired Data
                                                                      41 mins ago






                                                                    • 1




                                                                      $begingroup$
                                                                      Static access from non-static context reeeeeee. Thanks.
                                                                      $endgroup$
                                                                      – Benjamin Urquhart
                                                                      40 mins ago
















                                                                    • $begingroup$
                                                                      128 bytes
                                                                      $endgroup$
                                                                      – Expired Data
                                                                      41 mins ago






                                                                    • 1




                                                                      $begingroup$
                                                                      Static access from non-static context reeeeeee. Thanks.
                                                                      $endgroup$
                                                                      – Benjamin Urquhart
                                                                      40 mins ago















                                                                    $begingroup$
                                                                    128 bytes
                                                                    $endgroup$
                                                                    – Expired Data
                                                                    41 mins ago




                                                                    $begingroup$
                                                                    128 bytes
                                                                    $endgroup$
                                                                    – Expired Data
                                                                    41 mins ago




                                                                    1




                                                                    1




                                                                    $begingroup$
                                                                    Static access from non-static context reeeeeee. Thanks.
                                                                    $endgroup$
                                                                    – Benjamin Urquhart
                                                                    40 mins ago




                                                                    $begingroup$
                                                                    Static access from non-static context reeeeeee. Thanks.
                                                                    $endgroup$
                                                                    – Benjamin Urquhart
                                                                    40 mins ago











                                                                    2












                                                                    $begingroup$


                                                                    Jelly, 8 bytes



                                                                    ØṖOB§=ʋƇ


                                                                    Try it online!



                                                                    ØṖ printable ascii character list
                                                                    OB to binary
                                                                    § popcount
                                                                    = equal to input?
                                                                    ʋƇ filter (implicitly output)





                                                                    share|improve this answer









                                                                    $endgroup$

















                                                                      2












                                                                      $begingroup$


                                                                      Jelly, 8 bytes



                                                                      ØṖOB§=ʋƇ


                                                                      Try it online!



                                                                      ØṖ printable ascii character list
                                                                      OB to binary
                                                                      § popcount
                                                                      = equal to input?
                                                                      ʋƇ filter (implicitly output)





                                                                      share|improve this answer









                                                                      $endgroup$















                                                                        2












                                                                        2








                                                                        2





                                                                        $begingroup$


                                                                        Jelly, 8 bytes



                                                                        ØṖOB§=ʋƇ


                                                                        Try it online!



                                                                        ØṖ printable ascii character list
                                                                        OB to binary
                                                                        § popcount
                                                                        = equal to input?
                                                                        ʋƇ filter (implicitly output)





                                                                        share|improve this answer









                                                                        $endgroup$




                                                                        Jelly, 8 bytes



                                                                        ØṖOB§=ʋƇ


                                                                        Try it online!



                                                                        ØṖ printable ascii character list
                                                                        OB to binary
                                                                        § popcount
                                                                        = equal to input?
                                                                        ʋƇ filter (implicitly output)






                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered 4 hours ago









                                                                        ZylviijZylviij

                                                                        32014




                                                                        32014





















                                                                            2












                                                                            $begingroup$

                                                                            Dyalog APL Extended, 24 bytes



                                                                            ⎕ucs a⌿⍨(+⌿2⊤a←32…126)∘=


                                                                            Try it online!



                                                                            25 bytes in dzaima/APL:



                                                                            ⎕ucs a⌿⍨(+/¨2⊤¨a←32…126)=


                                                                            Try it online!






                                                                            share|improve this answer











                                                                            $endgroup$

















                                                                              2












                                                                              $begingroup$

                                                                              Dyalog APL Extended, 24 bytes



                                                                              ⎕ucs a⌿⍨(+⌿2⊤a←32…126)∘=


                                                                              Try it online!



                                                                              25 bytes in dzaima/APL:



                                                                              ⎕ucs a⌿⍨(+/¨2⊤¨a←32…126)=


                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$















                                                                                2












                                                                                2








                                                                                2





                                                                                $begingroup$

                                                                                Dyalog APL Extended, 24 bytes



                                                                                ⎕ucs a⌿⍨(+⌿2⊤a←32…126)∘=


                                                                                Try it online!



                                                                                25 bytes in dzaima/APL:



                                                                                ⎕ucs a⌿⍨(+/¨2⊤¨a←32…126)=


                                                                                Try it online!






                                                                                share|improve this answer











                                                                                $endgroup$



                                                                                Dyalog APL Extended, 24 bytes



                                                                                ⎕ucs a⌿⍨(+⌿2⊤a←32…126)∘=


                                                                                Try it online!



                                                                                25 bytes in dzaima/APL:



                                                                                ⎕ucs a⌿⍨(+/¨2⊤¨a←32…126)=


                                                                                Try it online!







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited 4 hours ago

























                                                                                answered 4 hours ago









                                                                                dzaimadzaima

                                                                                16.1k22060




                                                                                16.1k22060





















                                                                                    2












                                                                                    $begingroup$


                                                                                    JavaScript (Node.js),  70  69 bytes





                                                                                    n=>(g=x=>x>>7?'':Buffer((h=x=>x&&x%2+h(x>>1))(x)-n?0:[x])+g(x+1))(32)


                                                                                    Try it online!






                                                                                    share|improve this answer











                                                                                    $endgroup$

















                                                                                      2












                                                                                      $begingroup$


                                                                                      JavaScript (Node.js),  70  69 bytes





                                                                                      n=>(g=x=>x>>7?'':Buffer((h=x=>x&&x%2+h(x>>1))(x)-n?0:[x])+g(x+1))(32)


                                                                                      Try it online!






                                                                                      share|improve this answer











                                                                                      $endgroup$















                                                                                        2












                                                                                        2








                                                                                        2





                                                                                        $begingroup$


                                                                                        JavaScript (Node.js),  70  69 bytes





                                                                                        n=>(g=x=>x>>7?'':Buffer((h=x=>x&&x%2+h(x>>1))(x)-n?0:[x])+g(x+1))(32)


                                                                                        Try it online!






                                                                                        share|improve this answer











                                                                                        $endgroup$




                                                                                        JavaScript (Node.js),  70  69 bytes





                                                                                        n=>(g=x=>x>>7?'':Buffer((h=x=>x&&x%2+h(x>>1))(x)-n?0:[x])+g(x+1))(32)


                                                                                        Try it online!







                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited 4 hours ago

























                                                                                        answered 4 hours ago









                                                                                        ArnauldArnauld

                                                                                        81.9k798337




                                                                                        81.9k798337





















                                                                                            2












                                                                                            $begingroup$


                                                                                            PowerShell, 83 bytes





                                                                                            param($n)[char[]](32..126|?([convert]::ToString($_,2))


                                                                                            Try it online!



                                                                                            Takes input $n, constructs a range from 32 to 126 and pulls out those numbers where |?: the number, converted ToString in base 2; converted toCharArray; grouped into 0s and 1s; taking the [1] index of that grouping; taking the .count thereof, and checking that it's -equal to our input $number. Those numbers are then cast as a char-array and left on the pipeline. Output is implicit, with newlines between elements.






                                                                                            share|improve this answer









                                                                                            $endgroup$

















                                                                                              2












                                                                                              $begingroup$


                                                                                              PowerShell, 83 bytes





                                                                                              param($n)[char[]](32..126|?([convert]::ToString($_,2))


                                                                                              Try it online!



                                                                                              Takes input $n, constructs a range from 32 to 126 and pulls out those numbers where |?: the number, converted ToString in base 2; converted toCharArray; grouped into 0s and 1s; taking the [1] index of that grouping; taking the .count thereof, and checking that it's -equal to our input $number. Those numbers are then cast as a char-array and left on the pipeline. Output is implicit, with newlines between elements.






                                                                                              share|improve this answer









                                                                                              $endgroup$















                                                                                                2












                                                                                                2








                                                                                                2





                                                                                                $begingroup$


                                                                                                PowerShell, 83 bytes





                                                                                                param($n)[char[]](32..126|?([convert]::ToString($_,2))


                                                                                                Try it online!



                                                                                                Takes input $n, constructs a range from 32 to 126 and pulls out those numbers where |?: the number, converted ToString in base 2; converted toCharArray; grouped into 0s and 1s; taking the [1] index of that grouping; taking the .count thereof, and checking that it's -equal to our input $number. Those numbers are then cast as a char-array and left on the pipeline. Output is implicit, with newlines between elements.






                                                                                                share|improve this answer









                                                                                                $endgroup$




                                                                                                PowerShell, 83 bytes





                                                                                                param($n)[char[]](32..126|?([convert]::ToString($_,2))


                                                                                                Try it online!



                                                                                                Takes input $n, constructs a range from 32 to 126 and pulls out those numbers where |?: the number, converted ToString in base 2; converted toCharArray; grouped into 0s and 1s; taking the [1] index of that grouping; taking the .count thereof, and checking that it's -equal to our input $number. Those numbers are then cast as a char-array and left on the pipeline. Output is implicit, with newlines between elements.







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered 4 hours ago









                                                                                                AdmBorkBorkAdmBorkBork

                                                                                                28.1k468241




                                                                                                28.1k468241





















                                                                                                    2












                                                                                                    $begingroup$


                                                                                                    PHP, 72 bytes





                                                                                                    for($x=31;$x++<126;)echo$argn==count_chars(decbin($x),1)[49]?chr($x):'';


                                                                                                    Try it online!






                                                                                                    share|improve this answer








                                                                                                    New contributor




                                                                                                    Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                    Check out our Code of Conduct.






                                                                                                    $endgroup$

















                                                                                                      2












                                                                                                      $begingroup$


                                                                                                      PHP, 72 bytes





                                                                                                      for($x=31;$x++<126;)echo$argn==count_chars(decbin($x),1)[49]?chr($x):'';


                                                                                                      Try it online!






                                                                                                      share|improve this answer








                                                                                                      New contributor




                                                                                                      Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                      Check out our Code of Conduct.






                                                                                                      $endgroup$















                                                                                                        2












                                                                                                        2








                                                                                                        2





                                                                                                        $begingroup$


                                                                                                        PHP, 72 bytes





                                                                                                        for($x=31;$x++<126;)echo$argn==count_chars(decbin($x),1)[49]?chr($x):'';


                                                                                                        Try it online!






                                                                                                        share|improve this answer








                                                                                                        New contributor




                                                                                                        Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                        Check out our Code of Conduct.






                                                                                                        $endgroup$




                                                                                                        PHP, 72 bytes





                                                                                                        for($x=31;$x++<126;)echo$argn==count_chars(decbin($x),1)[49]?chr($x):'';


                                                                                                        Try it online!







                                                                                                        share|improve this answer








                                                                                                        New contributor




                                                                                                        Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                        Check out our Code of Conduct.









                                                                                                        share|improve this answer



                                                                                                        share|improve this answer






                                                                                                        New contributor




                                                                                                        Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                        Check out our Code of Conduct.









                                                                                                        answered 2 hours ago









                                                                                                        Russ GRuss G

                                                                                                        313




                                                                                                        313




                                                                                                        New contributor




                                                                                                        Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                        Check out our Code of Conduct.





                                                                                                        New contributor





                                                                                                        Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                        Check out our Code of Conduct.






                                                                                                        Russ G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                        Check out our Code of Conduct.





















                                                                                                            1












                                                                                                            $begingroup$


                                                                                                            Ruby, 48 bytes





                                                                                                            ->n(' '..?~).selectx.ord.digits(2).sum==n


                                                                                                            Try it online!






                                                                                                            share|improve this answer









                                                                                                            $endgroup$

















                                                                                                              1












                                                                                                              $begingroup$


                                                                                                              Ruby, 48 bytes





                                                                                                              ->n(' '..?~).selectx.ord.digits(2).sum==n


                                                                                                              Try it online!






                                                                                                              share|improve this answer









                                                                                                              $endgroup$















                                                                                                                1












                                                                                                                1








                                                                                                                1





                                                                                                                $begingroup$


                                                                                                                Ruby, 48 bytes





                                                                                                                ->n(' '..?~).selectx.ord.digits(2).sum==n


                                                                                                                Try it online!






                                                                                                                share|improve this answer









                                                                                                                $endgroup$




                                                                                                                Ruby, 48 bytes





                                                                                                                ->n(' '..?~).selectx.ord.digits(2).sum==n


                                                                                                                Try it online!







                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered 4 hours ago









                                                                                                                G BG B

                                                                                                                8,3261429




                                                                                                                8,3261429





















                                                                                                                    1












                                                                                                                    $begingroup$


                                                                                                                    Perl 5 -a, 50 bytes





                                                                                                                    map(sprintf'%b',$_)=~y/1//-$F[0]32..126


                                                                                                                    Try it online!






                                                                                                                    share|improve this answer









                                                                                                                    $endgroup$

















                                                                                                                      1












                                                                                                                      $begingroup$


                                                                                                                      Perl 5 -a, 50 bytes





                                                                                                                      map(sprintf'%b',$_)=~y/1//-$F[0]32..126


                                                                                                                      Try it online!






                                                                                                                      share|improve this answer









                                                                                                                      $endgroup$















                                                                                                                        1












                                                                                                                        1








                                                                                                                        1





                                                                                                                        $begingroup$


                                                                                                                        Perl 5 -a, 50 bytes





                                                                                                                        map(sprintf'%b',$_)=~y/1//-$F[0]32..126


                                                                                                                        Try it online!






                                                                                                                        share|improve this answer









                                                                                                                        $endgroup$




                                                                                                                        Perl 5 -a, 50 bytes





                                                                                                                        map(sprintf'%b',$_)=~y/1//-$F[0]32..126


                                                                                                                        Try it online!







                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered 3 hours ago









                                                                                                                        XcaliXcali

                                                                                                                        5,535521




                                                                                                                        5,535521





















                                                                                                                            1












                                                                                                                            $begingroup$


                                                                                                                            Charcoal, 10 bytes



                                                                                                                            Φγ⁼Σ↨℅ι²Iθ


                                                                                                                            Try it online! Link is to verbose version of code. Explanation:



                                                                                                                             γ Predefined ASCII characters
                                                                                                                            Φ Filtered by
                                                                                                                            ι Current character's
                                                                                                                            ℅ ASCII code
                                                                                                                            ↨ Converted to base
                                                                                                                            ² Literal 2
                                                                                                                            Σ Summed
                                                                                                                            ⁼ Equals
                                                                                                                            θ First input
                                                                                                                            I Cast to integer
                                                                                                                            Implicitly printed





                                                                                                                            share|improve this answer









                                                                                                                            $endgroup$

















                                                                                                                              1












                                                                                                                              $begingroup$


                                                                                                                              Charcoal, 10 bytes



                                                                                                                              Φγ⁼Σ↨℅ι²Iθ


                                                                                                                              Try it online! Link is to verbose version of code. Explanation:



                                                                                                                               γ Predefined ASCII characters
                                                                                                                              Φ Filtered by
                                                                                                                              ι Current character's
                                                                                                                              ℅ ASCII code
                                                                                                                              ↨ Converted to base
                                                                                                                              ² Literal 2
                                                                                                                              Σ Summed
                                                                                                                              ⁼ Equals
                                                                                                                              θ First input
                                                                                                                              I Cast to integer
                                                                                                                              Implicitly printed





                                                                                                                              share|improve this answer









                                                                                                                              $endgroup$















                                                                                                                                1












                                                                                                                                1








                                                                                                                                1





                                                                                                                                $begingroup$


                                                                                                                                Charcoal, 10 bytes



                                                                                                                                Φγ⁼Σ↨℅ι²Iθ


                                                                                                                                Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                 γ Predefined ASCII characters
                                                                                                                                Φ Filtered by
                                                                                                                                ι Current character's
                                                                                                                                ℅ ASCII code
                                                                                                                                ↨ Converted to base
                                                                                                                                ² Literal 2
                                                                                                                                Σ Summed
                                                                                                                                ⁼ Equals
                                                                                                                                θ First input
                                                                                                                                I Cast to integer
                                                                                                                                Implicitly printed





                                                                                                                                share|improve this answer









                                                                                                                                $endgroup$




                                                                                                                                Charcoal, 10 bytes



                                                                                                                                Φγ⁼Σ↨℅ι²Iθ


                                                                                                                                Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                 γ Predefined ASCII characters
                                                                                                                                Φ Filtered by
                                                                                                                                ι Current character's
                                                                                                                                ℅ ASCII code
                                                                                                                                ↨ Converted to base
                                                                                                                                ² Literal 2
                                                                                                                                Σ Summed
                                                                                                                                ⁼ Equals
                                                                                                                                θ First input
                                                                                                                                I Cast to integer
                                                                                                                                Implicitly printed






                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered 3 hours ago









                                                                                                                                NeilNeil

                                                                                                                                83.2k745179




                                                                                                                                83.2k745179





















                                                                                                                                    1












                                                                                                                                    $begingroup$

                                                                                                                                    Excel (2016 or later), 76 bytes



                                                                                                                                    =CONCAT(IF(LEN(SUBSTITUTE(DEC2BIN(ROW(32:126)),0,))=A1,CHAR(ROW(32:126)),""))


                                                                                                                                    Takes input from A1, outputs in whatever cell you put this formula. This is an array formula, so you need to press Ctrl-Shift-Enter to input it. The "2016 or later" is because it needs the CONCAT function (the deprecated CONCATENATE won't take an array as argument).






                                                                                                                                    share|improve this answer









                                                                                                                                    $endgroup$












                                                                                                                                    • $begingroup$
                                                                                                                                      I like this. I'm a Lotus Notes and 123 guy so this works for me :-)
                                                                                                                                      $endgroup$
                                                                                                                                      – ElPedro
                                                                                                                                      52 mins ago















                                                                                                                                    1












                                                                                                                                    $begingroup$

                                                                                                                                    Excel (2016 or later), 76 bytes



                                                                                                                                    =CONCAT(IF(LEN(SUBSTITUTE(DEC2BIN(ROW(32:126)),0,))=A1,CHAR(ROW(32:126)),""))


                                                                                                                                    Takes input from A1, outputs in whatever cell you put this formula. This is an array formula, so you need to press Ctrl-Shift-Enter to input it. The "2016 or later" is because it needs the CONCAT function (the deprecated CONCATENATE won't take an array as argument).






                                                                                                                                    share|improve this answer









                                                                                                                                    $endgroup$












                                                                                                                                    • $begingroup$
                                                                                                                                      I like this. I'm a Lotus Notes and 123 guy so this works for me :-)
                                                                                                                                      $endgroup$
                                                                                                                                      – ElPedro
                                                                                                                                      52 mins ago













                                                                                                                                    1












                                                                                                                                    1








                                                                                                                                    1





                                                                                                                                    $begingroup$

                                                                                                                                    Excel (2016 or later), 76 bytes



                                                                                                                                    =CONCAT(IF(LEN(SUBSTITUTE(DEC2BIN(ROW(32:126)),0,))=A1,CHAR(ROW(32:126)),""))


                                                                                                                                    Takes input from A1, outputs in whatever cell you put this formula. This is an array formula, so you need to press Ctrl-Shift-Enter to input it. The "2016 or later" is because it needs the CONCAT function (the deprecated CONCATENATE won't take an array as argument).






                                                                                                                                    share|improve this answer









                                                                                                                                    $endgroup$



                                                                                                                                    Excel (2016 or later), 76 bytes



                                                                                                                                    =CONCAT(IF(LEN(SUBSTITUTE(DEC2BIN(ROW(32:126)),0,))=A1,CHAR(ROW(32:126)),""))


                                                                                                                                    Takes input from A1, outputs in whatever cell you put this formula. This is an array formula, so you need to press Ctrl-Shift-Enter to input it. The "2016 or later" is because it needs the CONCAT function (the deprecated CONCATENATE won't take an array as argument).







                                                                                                                                    share|improve this answer












                                                                                                                                    share|improve this answer



                                                                                                                                    share|improve this answer










                                                                                                                                    answered 55 mins ago









                                                                                                                                    Sophia LechnerSophia Lechner

                                                                                                                                    86017




                                                                                                                                    86017











                                                                                                                                    • $begingroup$
                                                                                                                                      I like this. I'm a Lotus Notes and 123 guy so this works for me :-)
                                                                                                                                      $endgroup$
                                                                                                                                      – ElPedro
                                                                                                                                      52 mins ago
















                                                                                                                                    • $begingroup$
                                                                                                                                      I like this. I'm a Lotus Notes and 123 guy so this works for me :-)
                                                                                                                                      $endgroup$
                                                                                                                                      – ElPedro
                                                                                                                                      52 mins ago















                                                                                                                                    $begingroup$
                                                                                                                                    I like this. I'm a Lotus Notes and 123 guy so this works for me :-)
                                                                                                                                    $endgroup$
                                                                                                                                    – ElPedro
                                                                                                                                    52 mins ago




                                                                                                                                    $begingroup$
                                                                                                                                    I like this. I'm a Lotus Notes and 123 guy so this works for me :-)
                                                                                                                                    $endgroup$
                                                                                                                                    – ElPedro
                                                                                                                                    52 mins ago

















                                                                                                                                    draft saved

                                                                                                                                    draft discarded
















































                                                                                                                                    If this is an answer to a challenge…



                                                                                                                                    • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                    • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                      Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                    • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                                                                                                    More generally…



                                                                                                                                    • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                    • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                                                                                                    draft saved


                                                                                                                                    draft discarded














                                                                                                                                    StackExchange.ready(
                                                                                                                                    function ()
                                                                                                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183625%2fall-ascii-characters-with-a-given-bit-count%23new-answer', 'question_page');

                                                                                                                                    );

                                                                                                                                    Post as a guest















                                                                                                                                    Required, but never shown





















































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown

































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown







                                                                                                                                    Popular posts from this blog

                                                                                                                                    Magento 2 - Add success message with knockout Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Success / Error message on ajax request$.widget is not a function when loading a homepage after add custom jQuery on custom themeHow can bind jQuery to current document in Magento 2 When template load by ajaxRedirect page using plugin in Magento 2Magento 2 - Update quantity and totals of cart page without page reload?Magento 2: Quote data not loaded on knockout checkoutMagento 2 : I need to change add to cart success message after adding product into cart through pluginMagento 2.2.5 How to add additional products to cart from new checkout step?Magento 2 Add error/success message with knockoutCan't validate Post Code on checkout page

                                                                                                                                    Fil:Tokke komm.svg

                                                                                                                                    Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?