Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 985317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:08:45+00:00 2026-05-16T05:08:45+00:00

I want to list permutations with only 0 and 1. Similar to binary but

  • 0

I want to list permutations with only 0 and 1. Similar to binary but allowing variable lengths, doesn’t have to equal 8 length. For example:

0
1
00
01
10
11
000
001
010
011
100
101
110
111

All the way until the length of X is met. How can this be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:08:46+00:00Added an answer on May 16, 2026 at 5:08 am

    I would do this as a recursive call, one function to do all of a specific length, another to call that for all relevant lengths. The following complete C# 2008 console application shows what I mean:

    using System;
    
    namespace ConsoleApplication1 {
        class Program {
            static void permuteN(string prefix, int len) {
                if (len == 0) {
                    System.Console.WriteLine(prefix);
                    return;
                }
                permuteN(prefix + "0", len - 1);
                permuteN(prefix + "1", len - 1);
            }
    
            static void permute(int len) {
                for (int i = 1; i <= len; i++)
                    permuteN("", i);
            }
    
            static void Main(string[] args) {
                permute(3);
            }
        }
    }
    

    This outputs:

    0
    1
    00
    01
    10
    11
    000
    001
    010
    011
    100
    101
    110
    111
    

    which is what I think you were after.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a list L=[1,2,3,3,4] and I want to find all permutations of
Possible Duplicate: How to generate all permutations of a list in Python I want
In Python I have a list of n lists, each with a variable number
I have a list of tuples, e.g: A=[(1,2,3), (3,5,7,9), (7)] and want to generate
I have a list of objects (for the sake of example, let's say 5).
I'm trying to display all possible permutations of a list of numbers, for example
I have a string. I want to generate all permutations from that string, by
In my ul , I want list bullets by default, but I'd like to
I have a list of tokens, like: hel lo bye and i want to
I have a tuple of Action objects I want to create a list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.