You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// BUG: this code contains an error -- fails to read last three characters of string
for (int i = 0; i < geneStr.length() - 3; i += 3) {
codons.add(new Codon(geneStr.substring(i, i + 3)));
}
// Here is an example of a corrected version:
final int len = geneStr.length();
final int partitionSize = 3;
for (int i = 0; i < len; i += partitionSize) {
codons.add(new Codon(geneStr.substring(i, Math.min(len, i + partitionSize))));
}
// Test case that fails with original implementation
Codon ttt = new Codon("TTT");
System.out.println(myGene.linearContains(ttt)); // true
System.out.println(myGene.binaryContains(ttt)); // true
Note: I would recommend to only update this code on GitHub, as clearly this is being used to read in sample input data for the algorithm.
The text was updated successfully, but these errors were encountered:
Listing 2.4 on page 29:
Note: I would recommend to only update this code on GitHub, as clearly this is being used to read in sample input data for the algorithm.
The text was updated successfully, but these errors were encountered: