Exemple #1
0
func TestExistsKLenSubsetSumsToAtMostT(t *testing.T) {
	if false == number.ExistsKLenSubsetSumsToAtMostT([]float64{4.2, 2.5, 5.1, 3.4}, 2, 6.0) {
		t.Fatalf("2.5 and 3.4 should sum to at most 6.0")
	}

	if false == number.ExistsKLenSubsetSumsToAtMostT([]float64{4.2, 2.5, 5.1, 3.4}, 3, 10.5) {
		t.Fatalf("2.5, 3.4 and 4.2 should sum to at most 10.5")
	}
}
Exemple #2
0
func BenchmarkExistsKLenSubsetSumsToAtMostT(b *testing.B) {
	for i := 0; i < b.N; i++ {
		number.ExistsKLenSubsetSumsToAtMostT([]float64{4.2, 2.5, 5.1, 3.4}, 2, 6.0)
	}
}