Skip to content

Commit

Permalink
Updated number to be prime; and Swift 4 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Barbour committed May 8, 2018
1 parent 0fdd98c commit 444b993
Showing 1 changed file with 3 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
Expand Up @@ -8,7 +8,7 @@ print("Hello, Swift 4!")
import UIKit

struct Constants {
static let hashMultiplier = 69069
static let hashMultiplier = 69061
}

precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence }
Expand All @@ -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

0 comments on commit 444b993

Please sign in to comment.