Skip to content

Instantly share code, notes, and snippets.

@otto-schnurr
Last active August 29, 2015 14:06
Show Gist options
  • Save otto-schnurr/a0d2b865c289154eaf31 to your computer and use it in GitHub Desktop.
Save otto-schnurr/a0d2b865c289154eaf31 to your computer and use it in GitHub Desktop.
A Swift solution for http://rosalind.info/problems/dna/.
#!/usr/bin/xcrun swift -F .
// FileInput module from https://github.com/otto-schnurr/FileInput-swift
import FileInput
let dna = input().nextLine()!
var count: [Character: Int] = ["A": 0, "C": 0, "G": 0, "T": 0];
for base in dna { count[base]? += 1 }
println(" ".join(map("ACGT") { toString(count[$0]!) }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment