Initial commit
Build, test, deploy / site (push) Failing after 15m13s

This commit is contained in:
alexm committed 2026-11-12 22:24:02 -05:00
commit e092cb029c
252 files changed
+35037

No files matched your search

@@ -0,0 +1,33 @@
// CALL: MATCH("ATT", "GATTACA")
// STOPS: index
// One bound is wrong. Every position where pattern P occurs exactly in text T.
FUNCTION MATCH(P : STRING, T : STRING) RETURNS LIST OF INTEGER
// Set up
DECLARE N : INTEGER
DECLARE M : INTEGER
DECLARE Matched : BOOL
DECLARE Answer : LIST OF INTEGER
N <- LENGTH(T)
M <- LENGTH(P)
// Visit each legal start
FOR I <- 0 TO N
// Test: does the pattern match here?
Matched <- TRUE
FOR J <- 0 TO M
IF T[I + J] != P[J] THEN
Matched <- FALSE
BREAK
ENDIF
NEXT J
// Update
IF Matched THEN
APPEND(Answer, I)
ENDIF
NEXT I
RETURN Answer
ENDFUNCTION