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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:15:44+00:00 2026-06-12T07:15:44+00:00

How do you find all the combinations of a 40 letter string? I have

  • 0

How do you find all the combinations of a 40 letter string?

I have to find how many combinations 20 D and 20 R can make.

as in one combination could be…

DDDDDDDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRR

thats 1 combination, now how do I figure out the rest?

  • 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-12T07:15:45+00:00Added an answer on June 12, 2026 at 7:15 am

    To count every combination of 20 D and 20 R, we can think of there being 40 “slots”, 20 of these slots will be filled by D, and the rest will be filled by R. So, we can calculate the total number of combinations using C(40, 20), or 40 choose 20, which can be represented with the following formula:

    40!/(20!*(40-20)!)
    

    Or in Python:

    >>> import math
    >>> math.factorial(40) / (math.factorial(20) * math.factorial(40-20))
    137846528820L
    

    Note that this is the same thing as the number of unique permutations of a string with 20 D and 20 R, but if you just calculate the number of permutations of that string you will be counting a lot of duplicates, and if you tried to calculate this by creating each permutation it will take a very long time.

    If you wanted to actually generate the unique permutations (which I don’t suggest), one way to do it would be to use itertools.combinations(range(40), 20). Each element returned here would be a tuple of 20 integers, which would be the indices of each D in that particular permutation.

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

Sidebar

Related Questions

I am given a string and i need to find all possible letter combinations
how can i find all the anchor tags with source pdf $string=hello this is
I have a sequence of letters and want to find all combinations of letters
I'm trying to find all possible combinations of a word, and have certain letters
I have some issues resolving an algorithm used to find all posible combinations taking
I'm looking to find all combinations of single items from a variable number of
My goal here is to find all possible combinations that sums to a given
I have a method that checks all of the combinations of 5 different conditions
What is the best way to find all combinations of items in an array
I'd like to find all unique combinations of element positions of an array in

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.