15 lines
491 B
Mojo
15 lines
491 B
Mojo
# origin: Programming+ exercise count-base (was translations.mojo, by course staff)
|
|
# status: unverified; Stage 1 verifies it on the pinned compiler
|
|
# probe: does the course's hand-written count_base compile and agree with the pseudo?
|
|
# expect-stdout: 3
|
|
def count_base(b: String, t: String) -> Int:
|
|
var total = 0
|
|
for i in range(t.count_codepoints()):
|
|
if String(t[codepoint=i]) == b:
|
|
total += 1
|
|
return total
|
|
|
|
|
|
def main():
|
|
print(count_base("A", "GATTACA"))
|