From b6b448564c1d62f1d4c623b9bce5f8a9f8d8b652 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 18 Jan 2021 14:40:04 +0100 Subject: Python solution for week 95, part 1 --- challenge-096/abigail/python/ch-1.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 challenge-096/abigail/python/ch-1.py (limited to 'challenge-096/abigail/python') diff --git a/challenge-096/abigail/python/ch-1.py b/challenge-096/abigail/python/ch-1.py new file mode 100644 index 0000000000..ddc34e2633 --- /dev/null +++ b/challenge-096/abigail/python/ch-1.py @@ -0,0 +1,6 @@ +import fileinput + +for line in fileinput . input (): + words = line . strip () . split () + words . reverse () + print (" " . join (words)) -- cgit From b3fd5101407177b4d9a8e2d41b3e063269cee6ba Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 19 Jan 2021 13:42:51 +0100 Subject: Python solution for week 96, part 2. --- challenge-096/abigail/python/ch-2.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 challenge-096/abigail/python/ch-2.py (limited to 'challenge-096/abigail/python') diff --git a/challenge-096/abigail/python/ch-2.py b/challenge-096/abigail/python/ch-2.py new file mode 100644 index 0000000000..deaeff14cf --- /dev/null +++ b/challenge-096/abigail/python/ch-2.py @@ -0,0 +1,21 @@ +import fileinput + +def LevenshteinDistance (first, second): + n = len (first) + m = len (second) + distance = [] + for i in range (n + 1): + distance . append ([]) + for j in range (m + 1): + distance [i] . append (i + j if i == 0 or j == 0 else + min (distance [i - 1] [j] + 1, + distance [i] [j - 1] + 1, + distance [i - 1] [j - 1] + + (0 if first [i - 1] == + second [j - 1] else 1))) + return distance [n] [m] + + +for line in fileinput . input (): + words = line . strip () . split () + print LevenshteinDistance (words [0], words [1]) -- cgit