CCC '16 S1 - Ragaman

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2016 Stage 1, Senior #1

An anagram of a string is formed by rearranging the letters in the string. For example, the anagrams of aab are aab, aba, and baa.

A wildcard anagram of a string is an anagram of the string where some of the letters might have been replaced with an asterisk (*). For example, two possible wildcard anagrams of aab are *ab and *b*.

Given two strings, determine whether the second string is a wildcard anagram of the first string.

Input Specification

The two lines of input will both consist of N (1 \le N \le 100) characters. Each character in the first line will be a lowercase letter. Each character in the second line will be either a lowercase letter or an asterisk.

For 8 of the 15 available marks, the second line will not contain any asterisk characters.

Output Specification

Output the character A if the string on the second line is a wildcard anagram of the string on the first line. Otherwise, output the character N.

Sample Input 1

abba
baaa

Output for Sample Input 1

N

Sample Input 2

cccrocks
socc*rk*

Output for Sample Input 2

A

Comments


  • 0
    TianrunZhang  commented on Nov. 27, 2022, 12:34 p.m.

    It says that the wildcard anagram of a string is an anagram of the string where some of the letters might have been replaced with an asterisk (*).

    Does this mean at least one asterisk (*) must be present in the output?

    eg. Is "baab" considered a wildcard anagram of "abba", or only the anagram of "abba"?


    • -3
      volcano  commented on Nov. 27, 2022, 4:28 p.m. edit 2

      An anagram is a rearrangement of letters in a word to form a new word.

      A wildcard anagram is defined as an anagram of a word where some letters have been replaced by *. For example, b**b is a wildcard anagram of abba.

      By this definition, baab would be considered an anagram of abba, but not a wildcard anagram (since none of the letters have been replaced by *).


      • 0
        fireheartjerry  commented on Jan. 21, 2023, 3:15 p.m. edit 2

        This comment is incorrect, a program with input

        abcde
        edcba

        Would output A.

        ...where some of the letters might have been replaced...


  • -2
    MarkR  commented on Oct. 30, 2022, 10:20 a.m.

    Why am I getting name error?


  • 1
    BT  commented on Oct. 22, 2022, 1:38 p.m. edited

    Can the strings be uppercase? Edit --> i read the problem more carefully, it cant be


  • 0
    EricHan  commented on July 28, 2022, 5:37 p.m.

    Warning: do not include a check if there are no wild cards


  • 12
    bonnehomme  commented on Jan. 8, 2019, 4:04 p.m. edited

    Could an input be ****?


    • 2
      Ch4rIes  commented on Sept. 11, 2020, 2:01 a.m.

      Yes it can be


  • 10
    IanHu  commented on Dec. 29, 2018, 3:07 p.m.

    Can i use "*" to replace two different letters? eg: aabcd ----> a**cd


    • 2
      Ch4rIes  commented on Sept. 11, 2020, 11:45 p.m.

      Yes, It can be


    • 4
      mitssov_88  commented on Aug. 16, 2019, 12:50 p.m.

      I can't get more than 9 points and idk what it could be other than this


  • 2
    Kirito  commented on Aug. 24, 2017, 10:53 p.m.

    This is a reminder that spam is not appreciated. Please read the comment rules and guidelines before posting, lest you be banned.


    • -3
      DA_BIG_MO  commented on Dec. 30, 2018, 10:41 p.m.

      how is that spam? He's just asking a question.


      • 7
        Kirito  commented on Jan. 8, 2019, 7:43 p.m.

        You should look at the time stamps more carefully before commenting. That was in reference to comments cleaned up over a year ago.