Last active
September 17, 2022 12:24
-
-
Save Jawschamp/f541f742a2227dfb49ab5557c3cbe9e9 to your computer and use it in GitHub Desktop.
Revisions
-
Jawschamp revised this gist
Sep 17, 2022 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,6 @@ def char_pos_parser(parse_string: str, pattern: str): char_array = [] found_pat_array = [] pos_array = [] for i in enumerate(parse_string): char_array.append(i) for chars in char_array: @@ -16,4 +15,4 @@ def char_pos_parser(parse_string: str, pattern: str): for pos in pos_array: for pat in found_pat_array: char_dict[pos] = pat return f"Found: '{pattern}' from: '{parse_string}' at: positions: {char_dict.keys()}" -
Jawschamp revised this gist
Sep 17, 2022 . 1 changed file with 17 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,19 @@ def char_pos_parser(parse_string: str, pattern: str): char_dict = {} char_array = [] found_pat_array = [] pos_array = [] count = 0 for i in enumerate(parse_string): char_array.append(i) for chars in char_array: char_dict[chars[0]] = chars[1] for key, value in char_dict.items(): if value == pattern: found_pat_array.append(value) pos_array.append(key) char_dict.clear() for pos in pos_array: for pat in found_pat_array: char_dict[pos] = pat print(f"Found '{pattern}' at: positions: {char_dict.keys()}") -
Jawschamp revised this gist
Sep 16, 2022 . 1 changed file with 5 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,11 @@ def char_pos_parser(parse_string: str, pattern: str): array_data = [] dict_ = {} for i in enumerate(parse_string): array_data.append(i) for data in array_data: if data[-1] == pattern: pos = int(data[0]) + 1 char = data[1] print(f"pos: {pos}, char: {char}, occurences: {len(dict_) + 1}") dict_[pos] = char -
Jawschamp revised this gist
Aug 31, 2022 . 1 changed file with 13 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ def char_pos(string: str, change_point: str): array_data = [] dict_ = {} for i in enumerate(string): array_data.append(i) for data in array_data: if data[-1] == change_point: pos = int(data[0]) + 1 print(pos) char = data[1] print(True, pos, char) dict_[pos] = char return dict_ -
Jawschamp created this gist
Aug 31, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ sample_string = "Kassidy" array_data = [] dict_ = {} for i in enumerate(sample_string): array_data.append(i) for data in array_data: if data[-1] == "s": pos = int(data[0]) + 1 print(pos) char = data[1] print(True, pos, char) dict_[pos] = char print(dict_)