Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisLitvin committed Jun 14, 2018
1 parent 548413a commit 4528471
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Rabin-Karp/Rabin-Karp.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//: Taking our rabin-karp algorithm for a walk

// last checked with Xcode 9.0b4
// last checked with Xcode 9.4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
Expand Down Expand Up @@ -30,8 +30,8 @@ extension Character {
// Find first position of pattern in the text using Rabin Karp algorithm
public func search(text: String, pattern: String) -> Int {
// convert to array of ints
let patternArray = pattern.flatMap { $0.asInt }
let textArray = text.flatMap { $0.asInt }
let patternArray = pattern.compactMap { $0.asInt }
let textArray = text.compactMap { $0.asInt }

if textArray.count < patternArray.count {
return -1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

0 comments on commit 4528471

Please sign in to comment.