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

  • Home
  • SEARCH
  • 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 7578887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:32:18+00:00 2026-05-30T17:32:18+00:00

Sort of an odd question- how would I go about generating a character string

  • 0

Sort of an odd question- how would I go about generating a character string that doesn’t match any in a set of strings? I don’t want to make any assumptions about the strings. Solution is ideally STL based, but doesn’t have to be

Example:

vector<string> strings;
/*...*/
string unMatching = generateUnmatching(strings); //this is the function I want

assert(find(strings.begin(), strings.end(), unMatching) == strings.end());
  • 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-30T17:32:19+00:00Added an answer on May 30, 2026 at 5:32 pm

    One way is to use diagonalization:

    • Start with an empty string s.
    • Look at the first character of the first string in the set. Choose any character other than that one, and append it to s.
    • Look at the second character of the second string in the set. Choose any character other than that one, and append it to s.
    • Follow the same pattern, always looking at the ith character of the ith string and appending a different character to s.
    • When you’ve finished with the last string in the set, s will differ from every string in the set in at least one position.

    Another method would be to copy the longest string in the set and append any character to the copy. This new string will be different from every string in the set.

    There are all kinds of other ways to accomplish the same thing. Adding some constraints to the problem would help in selecting an algorithm that makes the most sense for your problem. For example, you might decide to generate the shortest string that doesn’t match any string in the set, or one with the lowest lexigraphic sort value, or one with the smallest number of characters in common with the other strings, or…

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

Sidebar

Related Questions

This is sort of an odd question. I know that SAS has a PROC
Hi I have a question about Batcher's odd-even-merge sort. I have the following code:
This is a fairly odd question... I believe it would involve some sort of
Here's a sort of odd question. I'm in the process of writing a book
Sort of a methods/best practices question here that I am sure has been addressed,
I'm trying to make in sort that odd <tr> and even <tr> have different
I thought it was odd that C# let me call sort on my class
This is sort of an odd request. I have a byte array that I
This might sound odd, but my issue is that I have a text string
I would like to sort an array in ascending order using C/C++ . The

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.