Skip to content

Commit 7c80765

Browse files
committed
#8 - 서울에서 김서방 찾기 문제 풀이
1 parent 5fa685d commit 7c80765

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

ProgrammersLevel1/ProgrammersLevel1.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
33DFAE3C2898036B0075DD46 /* 신규 아이디 추천.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33DFAE3B2898036A0075DD46 /* 신규 아이디 추천.swift */; };
1414
33DFAE3E28980C360075DD46 /* 키패드 누르기.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33DFAE3D28980C360075DD46 /* 키패드 누르기.swift */; };
1515
33DFAE40289814930075DD46 /* 가운데 글자 가져오기.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33DFAE3F289814930075DD46 /* 가운데 글자 가져오기.swift */; };
16+
33DFAE42289823800075DD46 /* 서울에서 김서방 찾기.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33DFAE41289823800075DD46 /* 서울에서 김서방 찾기.swift */; };
1617
/* End PBXBuildFile section */
1718

1819
/* Begin PBXCopyFilesBuildPhase section */
@@ -35,6 +36,7 @@
3536
33DFAE3B2898036A0075DD46 /* 신규 아이디 추천.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "신규 아이디 추천.swift"; sourceTree = "<group>"; };
3637
33DFAE3D28980C360075DD46 /* 키패드 누르기.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "키패드 누르기.swift"; sourceTree = "<group>"; };
3738
33DFAE3F289814930075DD46 /* 가운데 글자 가져오기.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "가운데 글자 가져오기.swift"; sourceTree = "<group>"; };
39+
33DFAE41289823800075DD46 /* 서울에서 김서방 찾기.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "서울에서 김서방 찾기.swift"; sourceTree = "<group>"; };
3840
/* End PBXFileReference section */
3941

4042
/* Begin PBXFrameworksBuildPhase section */
@@ -72,6 +74,7 @@
7274
3341498F2897E853008BB719 /* main.swift */,
7375
33DFAE3D28980C360075DD46 /* 키패드 누르기.swift */,
7476
33DFAE3F289814930075DD46 /* 가운데 글자 가져오기.swift */,
77+
33DFAE41289823800075DD46 /* 서울에서 김서방 찾기.swift */,
7578
);
7679
path = ProgrammersLevel1;
7780
sourceTree = "<group>";
@@ -143,6 +146,7 @@
143146
isa = PBXSourcesBuildPhase;
144147
buildActionMask = 2147483647;
145148
files = (
149+
33DFAE42289823800075DD46 /* 서울에서 김서방 찾기.swift in Sources */,
146150
33DFAE3C2898036B0075DD46 /* 신규 아이디 추천.swift in Sources */,
147151
33DFAE3E28980C360075DD46 /* 키패드 누르기.swift in Sources */,
148152
334149902897E853008BB719 /* main.swift in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// 서울에서 김서방 찾기.swift
3+
// ProgrammersLevel1
4+
//
5+
// Created by hwangJi on 2022/08/02.
6+
//
7+
8+
import Foundation
9+
10+
func solution(_ seoul:[String]) -> String {
11+
var kimLocation: Int = 0
12+
13+
for (index, i) in seoul.enumerated() {
14+
if i == "Kim" {
15+
kimLocation = index
16+
break
17+
}
18+
}
19+
20+
return "김서방은 \(kimLocation)에 있다"
21+
}
22+
23+
func solution2(_ seoul:[String]) -> String {
24+
return "김서방은 \(seoul.firstIndex(of: "Kim")!)에 있다"
25+
}

0 commit comments

Comments
 (0)