Initial commit
Test (in pplus-core) / in-core (push) Failing after 28m44s

This commit is contained in:
alexm committed 2026-11-12 22:23:48 -05:00
commit 568474d52f
1591 files changed
+528213

No files matched your search

@@ -0,0 +1,25 @@
def needleman_wunsch_score(s: String, t: String, match_: Int, mismatch: Int, gap: Int) -> Int:
var n = s.count_codepoints()
var m = t.count_codepoints()
var d = List[List[Int]]()
for i in range(n + 1):
var row = List[Int]()
for j in range(m + 1):
row.append(0)
d.append(row^)
for i in range(n + 1):
d[i][0] = i * gap
for j in range(1, m + 1):
d[0][j] = j * gap
for i in range(1, n + 1):
for j in range(1, m + 1):
var score = mismatch
if String(s[codepoint=i - 1]) == String(t[codepoint=j - 1]):
score = match_
var best = d[i - 1][j - 1] + score
if d[i - 1][j] + gap > best:
best = d[i - 1][j] + gap
if d[i][j - 1] + gap > best:
best = d[i][j - 1] + gap
d[i][j] = best
return d[n][m]
@@ -0,0 +1,12 @@
def needleman_wunsch_score(s, t, match, mismatch, gap):
n, m = len(s), len(t)
d = [[0] * (m + 1) for _ in range(n + 1)]
for i in range(n + 1):
d[i][0] = i * gap
for j in range(1, m + 1):
d[0][j] = j * gap
for i in range(1, n + 1):
for j in range(1, m + 1):
diagonal = d[i - 1][j - 1] + (match if s[i - 1] == t[j - 1] else mismatch)
d[i][j] = max(diagonal, d[i - 1][j] + gap, d[i][j - 1] + gap)
return d[n][m]
@@ -0,0 +1,10 @@
def needleman_wunsch_score(s, t, match, mismatch, gap):
m = len(t)
prev = [j * gap for j in range(m + 1)]
for i in range(1, len(s) + 1):
cur = [i * gap] + [0] * m
for j in range(1, m + 1):
diagonal = prev[j - 1] + (match if s[i - 1] == t[j - 1] else mismatch)
cur[j] = max(diagonal, prev[j] + gap, cur[j - 1] + gap)
prev = cur
return prev[m]