Skip to content

Instantly share code, notes, and snippets.

@def-
Forked from c-guzman/counting_mutations.nim
Last active February 29, 2016 15:36
Show Gist options
  • Save def-/24b0e2e4371d50847cd8 to your computer and use it in GitHub Desktop.
Save def-/24b0e2e4371d50847cd8 to your computer and use it in GitHub Desktop.
# counting point mutations
# count all mutations where C != C, G !=G, A != A, and T != T
import algorithm
# define string variables
var s: string = "GAGCCTACTAACGGGAT"
var t: string = "CATCGTAATGACGGCCT"
# define count variable for number of mutations
var mutations: int = 0
# for loop if letter of string s does not match letter of string t increase mutation variable by 1
if s.len != t.len:
echo "Different lengths!"
for i in 0 .. min(s.high, t.high):
if s[i] != t[i]: # I'm not sure how to iterate over the individual letters of string t here, I tried t.mitems but that didn't work.
mutations.inc()
echo mutations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment