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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:59:42+00:00 2026-06-13T04:59:42+00:00

The Question is_match: (str, str) -> bool The first parameter is a puzzle and

  • 0

The Question

is_match:
(str, str) -> bool

The first parameter is a puzzle and the second is a view. Return True iff the view could be a view of the given puzzle.

My Answer

I came up with this:

def is_match(puzzle, view):
    if len(puzzle) != len(view):
        return False
    if len(puzzle) == len(view):
        return True

I also found this online:

def is_match(given_puzzle, view):
    if len(given_puzzle) != len(view):
        return False
    unique_letters = set(ch for ch in view if ch != '^')
    for (a, b) in zip(given_puzzle, view):
        if a in unique_letters and a != b:
            return False
    return True

This issue I am having is that if I input:

is_match('blah', 'tr^^')

It will return True for both of the given codes. Which must be wrong due to the fact that the characters don’t even match only the length of the string does
What could i do to fix this?

  • 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-13T04:59:43+00:00Added an answer on June 13, 2026 at 4:59 am

    Based on a previous string of questions about this “puzzle” game, I infer that you want something like:

    def is_match(puzzle,view):
        return all(p == v for p,v in zip(puzzle,view) if v != '^' )
    

    *Note that this assumes that puzzle and view have the same length.

    What this does is iterate over puzzle and view at the same time, yielding the next character from each as p and v (the magic of zip). I check to make sure that v is not '^' (the placeholder character). If it isn’t a placeholder, I check if it equals p (the character from puzzle). If at any time this latter check fails, then the function returns False. Otherwise, it returns True.

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

Sidebar

Related Questions

Hopefully someone here might have an answer to my question. I have a basic
The answer to a previous question showed that Nexus implement a custom authentication helper
i am referring to answer to my question , answer was provided by @abhy,
I was asked this question in an interview for an internship, and the first
I somehow know that the answer to this question will be obvious, but I've
Question: Is is possible, with regex, to match a word that contains the same
My question is simple. Is there a PHP's preg_match() function equivalent in the C++
I have the following regexp: (?P<question>.+(?<!\[\[)) It is designed to match hello world! in
This question is about the threshold at which Math.Floor(double) and Math.Ceiling(double) decide to give
My apologies if you think this question is supposed to be on the Math

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.