Repository: TheAlgorithms/Python
Pull request: Match a pattern and String using backtracking
### Describe your change:

created a file with name match_word_pattern.py inside backtracking for Match a pattern and String using backtracking.

* [x] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?

### Checklist:
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is all my own work -- I have not plagiarized.
* [x] I know that pull requests will not be merged if they fail the automated tests.
* [x] This PR only changes one algorithm file.  To ease review, please open separate PRs for separate algorithms.
* [x] All new Python files are placed inside an existing directory.
* [x] All filenames are in all lowercase characters with no spaces or dashes.
* [x] All functions and variable names follow Python naming conventions.
* [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html).
* [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing.
* [ ] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
* [x] If this pull request resolves one or more open issues then the description above includes the issue number(s) with a [closing keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue): "Fixes #9844".


Problem statement:
Match a pattern and String using backtracking
### What would you like to share?

Given a string, find out if string follows a given pattern or not without using any regular expressions. We can solve this problem with the help of Backtracking. 

### Additional information

_No response_

Hints from issue discussion:
Please accept the issue with hacktober tag

Commit message: fix: issue #9844

Patch to review:
diff --git a/backtracking/match_word_pattern.py b/backtracking/match_word_pattern.py
new file mode 100644
index 000000000000..f0399ae55118
--- /dev/null
+++ b/backtracking/match_word_pattern.py
@@ -0,0 +1,54 @@
+def matchWordPattern(pattern :str, input_string: str) -> bool:
+    """
+    Determine if a given pattern matches a string using backtracking.
+
+    pattern: The pattern to match.
+    input_string: The string to match against the pattern.
+    return: True if the pattern matches the string, False otherwise.
+
+    >>> matchWordPattern("aba", "GraphTreesGraph")
+    True
+
+    >>> matchWordPattern("xyx", "PythonRubyPython")
+    True
+
+    >>> matchWordPattern("GG", "PythonJavaPython")
+    False
+    """
+    def backtrack(pattern_index, str_index):
+        if pattern_index == len(pattern) and str_index == len(input_string):
+            return True
+        if pattern_index == len(pattern) or str_index == len(input_string):
+            return False
+        
+        char = pattern[pattern_index]
+        
+        if char in pattern_map:
+            mapped_str = pattern_map[char]
+            if input_string.startswith(mapped_str, str_index):
+                return backtrack(pattern_index + 1, str_index + len(mapped_str))
+            else:
+                return False
+        
+        for end in range(str_index + 1, len(input_string) + 1):
+            substr = input_string[str_index:end]
+            if substr in str_map:
+                continue
+            
+            pattern_map[char] = substr
+            str_map[substr] = char
+            
+            if backtrack(pattern_index + 1, end):
+                return True
+            
+            del pattern_map[char]
+            del str_map[substr]
+        return False
+    
+    pattern_map = {}
+    str_map = {}
+    return backtrack(0, 0)
+
+if __name__ == "__main__":
+    import doctest
+    doctest.testmod()


Code review comments:
diff_hunk: @@ -0,0 +1,54 @@
+def matchWordPattern(pattern :str, input_string: str) -> bool:
path: backtracking/match_word_pattern.py
text: @user1:
Variable and function names should follow the [`snake_case`](https://en.wikipedia.org/wiki/Snake_case) naming convention. Please update the following name accordingly: `matchWordPattern`

diff_hunk: @@ -0,0 +1,54 @@
+def matchWordPattern(pattern :str, input_string: str) -> bool:
+    """
+    Determine if a given pattern matches a string using backtracking.
+
+    pattern: The pattern to match.
+    input_string: The string to match against the pattern.
+    return: True if the pattern matches the string, False otherwise.
+
+    >>> matchWordPattern("aba", "GraphTreesGraph")
+    True
+
+    >>> matchWordPattern("xyx", "PythonRubyPython")
+    True
+
+    >>> matchWordPattern("GG", "PythonJavaPython")
+    False
+    """
+    def backtrack(pattern_index, str_index):
path: backtracking/match_word_pattern.py
text: @user1:
As there is no test file in this pull request nor any test function or class in the file `backtracking/match_word_pattern.py`, please provide doctest for the function `backtrack`

Please provide return type hint for the function: `backtrack`. **If the function does not return a value, please provide the type hint as:** `def function() -> None:`

Please provide type hint for the parameter: `pattern_index`

Please provide type hint for the parameter: `str_index`