Implement ChromosomeToCycle solved by 291

Sept. 7, 2015, 4:12 p.m. by Rosalind Team

The following pseudocode bypasses the intermediate step of assigning “head” and “tail” nodes in order to transform a single circular chromosome Chromosome = (Chromosome1, . . . , Chromosomen) into a cycle represented as a sequence of integers Nodes = (Nodes1, . . . , Nodes2n).

ChromosomeToCycle(Chromosome)
     for j ← 1 to |Chromosome|
          i ← Chromosomej
          if i > 0
               Node2j−1 ←2i−1
               Node2j ← 2i
          else
               Node2j−1 ← -2i
               Node2j ←-2i−1
     return Nodes

Chromosome To Cycle Problem

Solve the Chromosome To Cycle Problem.

Given: A chromosome Chromosome containing n synteny blocks.

Return: The sequence Nodes of integers between 1 and 2n resulting from applying ChromosomeToCycle to Chromosome.

Sample Dataset

(+1 -2 -3 +4)

Sample Output

(1 2 4 3 6 5 7 8)

Extra Dataset

Please login to solve this problem.