commit
401084bab3
265 files changed
+69224
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
|
||||
|
||||
# How many positions of T hold the base B, with its specification.
|
||||
def count_base(b: String, t: String) -> Int:
|
||||
# ENSURE RESULT == LENGTH({ K IN [0, LENGTH(T)) : T[K] == B })
|
||||
var n: Int
|
||||
var total: Int
|
||||
n = t.count_codepoints()
|
||||
total = 0
|
||||
# INVARIANT Total == LENGTH({ K IN [0, I) : T[K] == B })
|
||||
for i in range(n):
|
||||
if String(t[codepoint=i]) == b:
|
||||
total = total + 1
|
||||
return total
|
||||
|
||||
|
||||
def main():
|
||||
print(count_base("A", "GATTACA"))
|
||||
Reference in new issue
Block a user