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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:52:12+00:00 2026-06-13T23:52:12+00:00

Problem 24 clearly asks: What is the millionth lexicographic permutation of the digits 0,

  • 0

Problem 24 clearly asks:

What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?

If my initial string then is:

$str = "0123456789";

I interpret the request to mean: perform 1,000,000 permutations on $string.

for( $i = 0; $i < 1000000; $i++ ) {

    $str = lexicographicPermute($str);

}

echo $str; // prints 2783915604, an incorrect answer.

However, if I only perform 999,999 permutations instead, then it returns the correct answer.

I’m still trying to wrap my head around why it is correct though.

What interpretation of the question would lead you to not perform 1,000,000 permutations?

  • 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-13T23:52:13+00:00Added an answer on June 13, 2026 at 11:52 pm

    You miss the fact that your original string ($str = "0123456789") is actually a permutation too, and it should be counted as well. ) Consider this: what if you had written your for like this:

    for( $i = 0; $i < 1; $i++ ) {
        $str = lexicographicPermute($str);
    }
    

    … how many permutations you would have got? Two, of course: the original string and the result of lexicographicPermute() invoked on it. )

    As a sidenote, I don’t think the direct approach (literally building those (million – 1) permutations) is the right way of solving this problem. Otherwise it wouldn’t have been so much of a problem for humans, no? )

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

Sidebar

Related Questions

All right, I'll try to explain my problem as clearly as I can. I
I have a complicated problem and I hope to explain it clearly possible... I
I have the following problem: http://jsfiddle.net/DerNa/12/ Which is demonstrated more clearly the jump here:
Here is the smallest amount of code that clearly illustrates my problem: <html> <body>
This is a very strange problem, and I just hope that I can clearly
Note sure how to explain this clearly but here is the problem: I have
I will try to explain my problem clearly: I have two tables: document and
I want to discuss my problem clearly. I have a function to Swap value
I'll try to present my problem clearly, but I'm bit of a novice in
It might be a bit long, but I'll try to explain my problem clearly.

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.