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 8129493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:19:51+00:00 2026-06-06T08:19:51+00:00

I have a string and a number of spaces e.g. the string is accttgagattcagt

  • 0

I have a string and a number of spaces e.g. the string is “accttgagattcagt” and I have 10 spaces to insert.

How can you iterate over all combinations of that string and spaces? The letters in the string cannot be reordered, and all spaces must be inserted.

And how can you calculate the number of rearrangements (without iterating them)?

And what is the proper word for this? Permutations, combinations or something else?

(I visualise this as strings of 1s and 0s where the 1s are used by the string and the 0s are spaces.

So a short string of 3 letters and 2 spaces would be asking for all all 5 bit numbers with 3 1s and 2 0s e.g. 11100, 11010, 11001, 10110, 10101, 10011, 01110, 01101, 01011, 00111?

But easy as short sequences are to make on paper, I am struggling to make a for-loop to do it :(. So nice pseudocode to create this sequence, and count how long it would be, please?

Recursion will be easier to understand but can it be faster if recursion is avoided somehow?)

  • 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-06-06T08:19:53+00:00Added an answer on June 6, 2026 at 8:19 am

    That’s combinations.

    So a short string of 3 letters and 2 spaces would be asking for all all 5 bit numbers with 3 1s and 2 0s e.g. 11100, 11010, 11001, 10110, 10101, 10011, 01110, 01101, 01011, 00111?

    You put the three ‘1’s on one of the 5 indices and order does not matter. So its 5 over 3:

    5!/((5-3)!3!) = 5*4/(2*1) = 10

    The article on wikipedia.org has an image illustrating a random sequence of 3 red and 2 white squares.

    This might be useful:
    Statistics: combinations in Python

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

Sidebar

Related Questions

I have a text string that starts with a number of spaces, varying between
I have a string, and I want to add a number of spaces to
I have a string that ends with _[a number] e.g. _1 _12 etc etc.
I have a string that contains a known number of double values. What's the
I have a Version class that contains a version_number string, and can obtain a
Say I have a string like this some3random5string8 I want to insert spaces after
I have a string and and a number cID = 'x1' num = 1
I have the string temp[256] and inside it there's a double number, such as
I have a String variable (basically an English sentence with an unspecified number of
i have a string and i need to add a number to it i.e

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.