This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
files:python3:alhpabet [2018/09/14 16:32] jguerin removed |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Kattis: Prime Sieve ====== | ||
- | ((Note: This page is a stub.)) | ||
- | ===== Python3 Source ===== | ||
- | <file python alphabet.py> | ||
- | # Modified from CLRS3e | ||
- | def LCS(x,y): | ||
- | m, n = len(x), len(y) | ||
- | C = [[0] * (n + 1) for i in range(m+1)] | ||
- | for i in range(1, m+1): | ||
- | for j in range(1, n+1): | ||
- | if x[i-1] == y[j-1]: | ||
- | C[i][j] = C[i-1][j-1] + 1 | ||
- | else: | ||
- | C[i][j] = max(C[i][j-1], | ||
- | return C[-1][-1] | ||
- | |||
- | a = list(input()) | ||
- | b = [' | ||
- | ' | ||
- | |||
- | al, bl = len(a), len(b) | ||
- | print(26 - LCS(a, b)) | ||
- | </ | ||
- | |||
- | ===== Solution Explanation ===== | ||
- | |||
- | ==== Potential " | ||
- | |||
- | ==== Finding the Solution ==== |