Re: Binary System Problem
- To: mathgroup at smc.vnet.net
- Subject: [mg18659] Re: [mg18621] Binary System Problem
- From: "Don Piele" <piele at cs.uwp.edu>
- Date: Thu, 15 Jul 1999 01:45:48 -0400
- References: <199907130501.BAA09602@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Frieder, Your problem is not well defined since you did not say how many zeros you want to include. There are an infinite number of binary numbers with a fixed number of 1's. Here is a solution that lets you decide how many zeros to allow. insertZero[l_List] := Table[Insert[l, 0, {i}], {i, Length[l] + 1}] numberOfZeros = 2; listOfOnes={1,1,1,1}; Nest[Flatten[Map[insertZero, #], 1] & , {listOfOnes}, numberOfZeros] // Union {{0, 0, 1, 1, 1, 1}, {0, 1, 0, 1, 1, 1}, {0, 1, 1, 0, 1, 1}, {0, 1, 1, 1, 0, 1}, {0, 1, 1, 1, 1, 0}, {1, 0, 0, 1, 1, 1}, {1, 0, 1, 0, 1, 1}, {1, 0, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 0}, {1, 1, 0, 0, 1, 1}, {1, 1, 0, 1, 0, 1}, {1, 1, 0, 1, 1, 0}, {1, 1, 1, 0, 0, 1}, {1, 1, 1, 0, 1, 0}, {1, 1, 1, 1, 0, 0}} FromDigits[#, 10] & /@ % {1111, 10111, 11011, 11101, 11110, 100111, 101011, 101101, 101110, 110011, \ 110101, 110110, 111001, 111010, 111100} Is this what you wanted? D Piele ================================================== ----- Original Message ----- From: Frieder Schweigert <FSchweigert at airplus.de> To: mathgroup at smc.vnet.net Subject: [mg18659] [mg18621] Binary System Problem > Hi, > > does anybody know an algorithm or generating system for > those binary numbers with a fix amount of '1's, > for example (four times '1'): > > 1111 > 10111 > 11011 > 11101 > 11110
- References:
- Binary System Problem
- From: Frieder Schweigert <FSchweigert@airplus.de>
- Binary System Problem