about | help | code help+videos | done | prefs |
In data analytics, it is very common for data to come to us in a dirty form, with errors related to how it was transcribed or downloaded. Since we know any sequence of dna must consist of the four bases 'a', 'g', 't', 'c', any other letters appearing in dna must be a mistake. Write a function clean(dna) that returns a new DNA string in which every character that is not an A, C, G, or T is replaced with an N. For example, clean('goat') should return the string 'gnat'. You can assume dna is all lowercase, but don't assume anything about the nature of the wrong characters (e.g. they could even have been accidentally transcribed as numbers). clean('') → '' clean('agct7ttczttctgactgcaacgggcaatatgtctctxtgtggattaaaaaaagagtgtcygatagcagcttctgaactggttacctgcc') → 'agctnttcnttctgactgcaacgggcaatatgtctctntgtggattaaaaaaagagtgtcngatagcagcttctgaactggttacctgcc' clean('gtgagtaaattaaaattttnttgacttaggtcactaaptactttaaccaatataggbatagcgcacagacagataaaaattacagagtac') → 'gtgagtaaattaaaattttnttgacttaggtcactaantactttaaccaatataggnatagcgcacagacagataaaaattacagagtac' ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy