# 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"))