diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-09-02 11:08:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-02 11:08:44 +0100 |
| commit | 8162d93f3469587093f2c5a0d6e8cbdef9434e47 (patch) | |
| tree | be5db0f4e83e316b47fbcc702ebfa6979e8d395d /challenge-180/deadmarshal/python/ch1.py | |
| parent | 91d665102ab1b10f30b41bcf87195be8565053ae (diff) | |
| parent | 29b273fc146113e127bd1664dd8d198d4ad2dcbd (diff) | |
| download | perlweeklychallenge-club-8162d93f3469587093f2c5a0d6e8cbdef9434e47.tar.gz perlweeklychallenge-club-8162d93f3469587093f2c5a0d6e8cbdef9434e47.tar.bz2 perlweeklychallenge-club-8162d93f3469587093f2c5a0d6e8cbdef9434e47.zip | |
Merge pull request #6683 from deadmarshal/challenge180
challenge180
Diffstat (limited to 'challenge-180/deadmarshal/python/ch1.py')
| -rw-r--r-- | challenge-180/deadmarshal/python/ch1.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-180/deadmarshal/python/ch1.py b/challenge-180/deadmarshal/python/ch1.py new file mode 100644 index 0000000000..a006f46cb3 --- /dev/null +++ b/challenge-180/deadmarshal/python/ch1.py @@ -0,0 +1,20 @@ +import sys + +def first_unique_character(s): + freq = {} + for i in s: + if i not in freq: + freq[i] = 1 + else: + freq[i] += 1 + + for i in range(len(s)): + if(freq[s[i]] == 1): + return f"{i} as '{s[i]}' is the first unique character" + return -1 + +if(len(sys.argv) != 2): + sys.stderr.write("No arg(s) provided!\n") + sys.exit(1) + +print(first_unique_character(sys.argv[1])) |
