Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/hamming/.meta/src/reference/kotlin/Hamming.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Hamming {

fun compute(leftStrand: String, rightStrand: String): Int {
require(leftStrand.length == rightStrand.length, {"left and right strands must be of equal length."})
require(leftStrand.length == rightStrand.length, {"left and right strands must be of equal length"})

val commonPairs = leftStrand.zip(rightStrand)
return commonPairs.count { it.first != it.second }
Expand Down
2 changes: 1 addition & 1 deletion exercises/hamming/.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.3.0
71 changes: 11 additions & 60 deletions exercises/hamming/src/test/kotlin/HammingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,98 +11,49 @@ class HammingTest {
var expectedException: ExpectedException = ExpectedException.none()

@Test
fun noDistanceBetweenEmptyStrands() {
fun `empty strands`() {
assertEquals(0, Hamming.compute("", ""))
}

@Ignore
@Test
fun noDistanceBetweenShortIdenticalStrands() {
fun `single letter identical strands`() {
assertEquals(0, Hamming.compute("A", "A"))
}

@Ignore
@Test
fun noDistanceBetweenLongIdenticalStrands() {
assertEquals(0, Hamming.compute("GGACTGA", "GGACTGA"))
fun `single letter different strands`() {
assertEquals(1, Hamming.compute("G", "T"))
}

@Ignore
@Test
fun completeDistanceInSingleNucleotideStrand() {
assertEquals(1, Hamming.compute("A", "G"))
fun `long identical strands`() {
assertEquals(0, Hamming.compute("GGACTGAAATCTG", "GGACTGAAATCTG"))
}

@Ignore
@Test
fun completeDistanceInSmallStrand() {
assertEquals(2, Hamming.compute("AG", "CT"))
}

@Ignore
@Test
fun smallDistanceInSmallStrand() {
assertEquals(1, Hamming.compute("AT", "CT"))
}

@Ignore
@Test
fun smallDistanceInMediumStrand() {
assertEquals(1, Hamming.compute("GGACG", "GGTCG"))
}

@Ignore
@Test
fun smallDistanceInLongStrand() {
assertEquals(2, Hamming.compute("ACCAGGG", "ACTATGG"))
}

@Ignore
@Test
fun nonUniqueCharacterInFirstStrand() {
assertEquals(1, Hamming.compute("AAG", "AAA"))
}

@Ignore
@Test
fun nonUniqueCharacterInSecondStrand() {
assertEquals(1, Hamming.compute("AAA", "AAG"))
}

@Ignore
@Test
fun sameNucleotidesInDifferentPositions() {
assertEquals(2, Hamming.compute("TAG", "GAT"))
}

@Ignore
@Test
fun largeDistanceInPermutedStrand() {
assertEquals(4, Hamming.compute("GATACA", "GCATAA"))
}

@Ignore
@Test
fun largeDistanceInOffByOneStrand() {
fun `long different strands`() {
assertEquals(9, Hamming.compute("GGACGGATTCTG", "AGGACGGATTCT"))
}

@Ignore
@Test
fun validatesFirstStrandNotLonger() {
fun `disallow first strand longer`() {
expectedException.expect(IllegalArgumentException::class.java)
expectedException.expectMessage("left and right strands must be of equal length.")
expectedException.expectMessage("left and right strands must be of equal length")

Hamming.compute("AATG", "AAA")
}

@Ignore
@Test
fun validatesSecondStrandNotLonger() {
fun `disallow second strand longer`() {
expectedException.expect(IllegalArgumentException::class.java)
expectedException.expectMessage("left and right strands must be of equal length.")
expectedException.expectMessage("left and right strands must be of equal length")

Hamming.compute("ATA", "AGTG")
}

}