Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Flavio Silverio's challenge, this time it's working. #23

Merged
merged 4 commits into from
Feb 2, 2017
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
4 changes: 4 additions & 0 deletions CodeChallenge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
1B9E113F1E005A7C00B9FA5A /* Clock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B9E113E1E005A7C00B9FA5A /* Clock.swift */; };
1B9E11411E006A2B00B9FA5A /* BugKrushaClockEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B9E11401E006A2B00B9FA5A /* BugKrushaClockEntry.swift */; };
1B9E11461E006F0800B9FA5A /* ClockTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B9E11451E006F0800B9FA5A /* ClockTests.swift */; };
1BBAB4801E41D6190038BCB1 /* FlavioSilverioBulletMatchEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BBAB47F1E41D6190038BCB1 /* FlavioSilverioBulletMatchEntry.swift */; };
2EB83A801E03290400FAAB32 /* EthanSchatzline-ClockEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EB83A7F1E03290400FAAB32 /* EthanSchatzline-ClockEntry.swift */; };
3D00956F1E03200C004E631A /* BrandonShegaClockEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D00956E1E03200C004E631A /* BrandonShegaClockEntry.swift */; };
7B1BF2D01E3F9CFA00AEAC0E /* matthijsBulletMatchEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1BF2CF1E3F9CFA00AEAC0E /* matthijsBulletMatchEntry.swift */; };
Expand Down Expand Up @@ -69,6 +70,7 @@
1B9E113E1E005A7C00B9FA5A /* Clock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Clock.swift; sourceTree = "<group>"; };
1B9E11401E006A2B00B9FA5A /* BugKrushaClockEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BugKrushaClockEntry.swift; sourceTree = "<group>"; };
1B9E11451E006F0800B9FA5A /* ClockTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClockTests.swift; sourceTree = "<group>"; };
1BBAB47F1E41D6190038BCB1 /* FlavioSilverioBulletMatchEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FlavioSilverioBulletMatchEntry.swift; path = BulletMatch/Entries/FlavioSilverioBulletMatchEntry.swift; sourceTree = "<group>"; };
2EB83A7F1E03290400FAAB32 /* EthanSchatzline-ClockEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "EthanSchatzline-ClockEntry.swift"; sourceTree = "<group>"; };
3D00956E1E03200C004E631A /* BrandonShegaClockEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrandonShegaClockEntry.swift; sourceTree = "<group>"; };
7B1BF2CF1E3F9CFA00AEAC0E /* matthijsBulletMatchEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = matthijsBulletMatchEntry.swift; path = BulletMatch/Entries/matthijsBulletMatchEntry.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -142,6 +144,7 @@
957200A11E206A94006BB4D6 /* CodesmanBulletMatchEntry.swift */,
1B49C04F1E0850D90094121E /* BugKrushaBulletMatchEntry.swift */,
9572008D1E1F19F9006BB4D6 /* juliand665BulletMatchEntry.swift */,
1BBAB47F1E41D6190038BCB1 /* FlavioSilverioBulletMatchEntry.swift */,
7B1BF2CF1E3F9CFA00AEAC0E /* matthijsBulletMatchEntry.swift */,
);
name = Entries;
Expand Down Expand Up @@ -443,6 +446,7 @@
948986701BE5D28500D34976 /* ExampleCodeChallenge.swift in Sources */,
1B31586F1E02FC7E0052ACBD /* FlavioSilverioClockEntry.swift in Sources */,
9572009E1E206A5E006BB4D6 /* juliand665ClockEntry.swift in Sources */,
1BBAB4801E41D6190038BCB1 /* FlavioSilverioBulletMatchEntry.swift in Sources */,
944CFCDB1BE7310B00FD2E41 /* LongestSubstringWithoutRepeatingCharactersChallenge.swift in Sources */,
1B1F0A4E1BE7EA060030135C /* BugKrushaLetterCombinationsOfPhoneNumberEntry.swift in Sources */,
3D00956F1E03200C004E631A /* BrandonShegaClockEntry.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions CodeChallenge/Challenges/BulletMatch/BulletMatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ final class BulletChallenge: JSONBasedChallenge {
bugKrushaBulletMatchEntry,
codesmanBulletMatchEntry,
juliand665BulletMatchEntry,
FlavioSilverioBulletMatchEntry,
matthijsBulletMatchEntry
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// FlavioSilverioBulletMatchEntry.swift
// CodeChallenge
//
// Created by Flávio Silvério on 31/01/17.
// Copyright © 2017 iosdevelopers. All rights reserved.
//

import Foundation

let FlavioSilverioBulletMatchEntry = CodeChallengeEntry<BulletChallenge>(name: "flaviodsilverio") { input in

let bulletMarkings = input.0
var gunMarkings = input.1

for _ in 0...bulletMarkings.characters.count - 1 {

if bulletMarkings == gunMarkings {
return true
} else {

gunMarkings.characters.append(gunMarkings.remove(at: gunMarkings.startIndex))

//made this second one to try it, it's way slower than the previous one...
// gunMarkings.insert(gunMarkings.remove(
// at: gunMarkings.startIndex),
// at: gunMarkings.endIndex)
}

}

return false

}