diff options
| author | drclaw1394 <drclaw@mac.com> | 2019-07-31 16:41:20 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-31 16:41:20 +1000 |
| commit | fd602cb30546cf8e27c913cf22ccd72ffa2c8c00 (patch) | |
| tree | aa8c4ef405055daafaa57f0117f02a6362ec27b9 /challenge-018/orestis-zekai/python/ch-1.py | |
| parent | 308d2c5a19d93acf77a9c65e0751044ed0230ae0 (diff) | |
| parent | 1dbcabd8e08dd98a40fe42ee3ce63e5755cdaaef (diff) | |
| download | perlweeklychallenge-club-fd602cb30546cf8e27c913cf22ccd72ffa2c8c00.tar.gz perlweeklychallenge-club-fd602cb30546cf8e27c913cf22ccd72ffa2c8c00.tar.bz2 perlweeklychallenge-club-fd602cb30546cf8e27c913cf22ccd72ffa2c8c00.zip | |
Merge pull request #18 from manwar/master
Update for w19
Diffstat (limited to 'challenge-018/orestis-zekai/python/ch-1.py')
| -rw-r--r-- | challenge-018/orestis-zekai/python/ch-1.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-018/orestis-zekai/python/ch-1.py b/challenge-018/orestis-zekai/python/ch-1.py new file mode 100644 index 0000000000..e997db9e74 --- /dev/null +++ b/challenge-018/orestis-zekai/python/ch-1.py @@ -0,0 +1,18 @@ +# Longest common substring
+
+string1 = "ABABC"
+string2 = "BABCA"
+
+max_substring = ""
+max_length = -1
+
+
+for i in range(0, len(string1)+1):
+ for j in range(0, len(string1)+1):
+ if (string1[i:j] in string2) and len(string1[i:j]) > max_length:
+ max_length = len(string1[i:j])
+ max_substring = string1[i:j]
+
+
+print('The longest substring is: ' + max_substring)
+print('The length of the longest substring is: ' + str(max_length))
\ No newline at end of file |
