DEV Community 👩‍💻👨‍💻

Discussion on: Daily Challenge #175 - Complementary DNA

Collapse
ryanbeckett profile image
Ryan Beckett • Edited on

Swift:


func DNA_strand( _ dna: String) -> String {
  let swapTable = [("A", "T"), ("T", "A"), ("C", "G"), ("G", "C")]

  return dna.map { char in
    swapTable.map { (key, value) in
      String(char) == key ? value as String : ""
    }.joined()
  }.joined()

}

I'm trying to complete these everyday for 30 days (hopefully more) - feedback more that welcome here please, thank you! Github PR