Baseline: tree as shared

This commit is contained in:
alexm committed 2026-10-05 03:03:38 +00:00
commit 31f2fb8a5a
1679 files changed
+1024562

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
// CALL: COUNT_BASE('A', "GATTACA")
// EXPECT: COUNT_BASE returned 3
// How many positions of T hold the base B.
FUNCTION COUNT_BASE(B : CHAR, T : STRING) RETURNS INTEGER
// Set up
DECLARE N : INTEGER
DECLARE Total : INTEGER
N <- LENGTH(T)
Total <- 0
// Visit each position
FOR I <- 0 TO N
// Test this position
IF T[I] == B THEN
// Update the running total
Total <- Total + 1
ENDIF
NEXT I
// Report
RETURN Total
ENDFUNCTION