Skip to content

Commit 892c1d4

Browse files
committed
Fix off-by-one error
1 parent 53adbc8 commit 892c1d4

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

K-Means/KMeans.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func reservoirSample<T>(samples: [T], k: Int) -> [T] {
8585
}
8686

8787
// Randomly replace elements from remaining pool
88-
for i in (k+1)..<samples.count {
88+
for i in k..<samples.count {
8989
let j = Int(arc4random_uniform(UInt32(i + 1)))
9090
if j < k {
9191
result[j] = samples[i]

K-Means/Tests/Tests.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
isa = PBXProject;
8686
attributes = {
8787
LastSwiftUpdateCheck = 0720;
88-
LastUpgradeCheck = 0720;
88+
LastUpgradeCheck = 0730;
8989
TargetAttributes = {
9090
B80894DF1C852D100018730E = {
9191
CreatedOnToolsVersion = 7.2.1;
@@ -136,6 +136,8 @@
136136
B80894D91C852CDC0018730E /* Debug */ = {
137137
isa = XCBuildConfiguration;
138138
buildSettings = {
139+
ENABLE_TESTABILITY = YES;
140+
ONLY_ACTIVE_ARCH = YES;
139141
};
140142
name = Debug;
141143
};

K-Means/Tests/Tests.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0730"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

0 commit comments

Comments
 (0)