Sha256: 3d7aa71c88876c392fbc9ea93aeca31494b56be6b821c8c6f3ee59d8ad2a5764

Contents?: true

Size: 754 Bytes

Versions: 258

Compression:

Stored size: 754 Bytes

Contents

using System;
using System.Collections.Generic;

public class DNA
{
    public IDictionary<char, int> NucleotideCounts { get; private set; }

    public DNA(string sequence)
    {
        InitializeNucleotideCounts(sequence);
    }

    private void InitializeNucleotideCounts(string sequence)
    {
        NucleotideCounts = new Dictionary<char, int> { { 'A', 0 }, { 'T', 0 }, { 'C', 0 }, { 'G', 0 } };
        foreach (var s in sequence)
            NucleotideCounts[s] += 1;
    }

    public int Count(char nucleotide)
    {
        int count;
        if (!NucleotideCounts.TryGetValue(nucleotide, out count))
            throw new InvalidNucleotideException();
        return count;
    }
}

public class InvalidNucleotideException : Exception { }

Version data entries

258 entries across 258 versions & 1 rubygems

Version Path
trackler-2.2.1.40 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.39 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.38 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.37 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.36 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.35 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.34 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.33 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.32 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.31 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.30 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.29 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.28 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.27 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.26 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.25 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.24 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.23 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.22 tracks/csharp/exercises/nucleotide-count/Example.cs
trackler-2.2.1.21 tracks/csharp/exercises/nucleotide-count/Example.cs