Every downstream tool in genomics — from base-calling QC to variant callers — starts with the
same primitive: knowing the base composition of a sequence. Nucleotide counting is also the first
check a bioinformatician runs against a FASTA file to sanity-test it, which is why it's the
"Hello World" of computational biology. It forces you to treat a string as a biological object
rather than just characters.
Statement
Given a single-stranded DNA sequence composed only of the characters A, C, G and T, count
how many times each nucleotide occurs.
Print four integers separated by single spaces, in the fixed order A C G T, on one line.
Input — read from standard input
Variable
Type
Description
s
line 1
str
The DNA sequence to count bases in
1 <= len(s) <= 1000, uppercase A, C, G, T only
These variables are already read for you in the starter code on the right.
Output
str
four space-separated counts in the order A C G T, on one line
A 70-character sequence; each base counted in one linear pass.
Sample 2
Input
ACGT
Expected Output
1 1 1 1
Perfectly balanced — one of each base.
Submit also runs your code against 4 hidden test cases.
Hidden inputs are never shown — if one fails you'll get its number and a description of the
mismatch, not the data.
Constraints
1 <= length(s) <= 1000
s contains only uppercase A, C, G, T — no N, no lowercase, no internal whitespace