Test/Coding Tests
-
func solution(_ n:Int) -> Int { var result:Int = 0 var arr :[Int] = [] while arr.count != n { result += 1 if (result % 3 != 0 && !String(result).contains("3")) { arr.append(result) } } return result } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 출처 [Swift] 코딩테스트 연습! Lv0. 저주의 숫자 3 /* 저주의 숫자 3 - 3x 마을 사람들은 3을 저주의 숫자라고 생각하기 때문에 3의 배수..
[Programmers] 저주의 숫자 3func solution(_ n:Int) -> Int { var result:Int = 0 var arr :[Int] = [] while arr.count != n { result += 1 if (result % 3 != 0 && !String(result).contains("3")) { arr.append(result) } } return result } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 출처 [Swift] 코딩테스트 연습! Lv0. 저주의 숫자 3 /* 저주의 숫자 3 - 3x 마을 사람들은 3을 저주의 숫자라고 생각하기 때문에 3의 배수..
2023.11.24 -
func solution(_ board:[[Int]]) -> Int { var copy = board for i in 0...board.count-1 { for j in 0...board.count-1 { if board[i][j] == 1 { if i != 0 && j != 0 { if copy[i-1][j-1] != 1 { copy[i-1][j-1] = 2 } } if i != 0 { if copy[i-1][j] != 1 { copy[i-1][j] = 2 } } if i != 0 && j+1 < board.count { if copy[i-1][j+1] != 1 { copy[i-1][j+1] = 2 } } if j != 0 { if copy[i][j-1] != 1 { copy[i][j-1] = 2 } ..
[Programmers] 안전지대func solution(_ board:[[Int]]) -> Int { var copy = board for i in 0...board.count-1 { for j in 0...board.count-1 { if board[i][j] == 1 { if i != 0 && j != 0 { if copy[i-1][j-1] != 1 { copy[i-1][j-1] = 2 } } if i != 0 { if copy[i-1][j] != 1 { copy[i-1][j] = 2 } } if i != 0 && j+1 < board.count { if copy[i-1][j+1] != 1 { copy[i-1][j+1] = 2 } } if j != 0 { if copy[i][j-1] != 1 { copy[i][j-1] = 2 } ..
2023.11.23 -
func solution(_ my_string:String) -> Int { return my_string.split(whereSeparator: { !$0.isNumber }) .reduce(0) { $0 + Int($1)! } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 참고 [프로그래머스] 숨어있는 숫자의 덧셈(2)(Swift) 코드 회고 어떻게 풀지 감이 안와 다른 사람의 코드를 보고 이해를 하였다 reduce라는 고차함수는 데이터를 합쳐주기 위해 사용하는 함수이다 map, filter, reduce 같은 고차함수들을 공부해야겠다 velog.io
[Programmers] 숨어있는 숫자의 덧셈 (2)func solution(_ my_string:String) -> Int { return my_string.split(whereSeparator: { !$0.isNumber }) .reduce(0) { $0 + Int($1)! } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 참고 [프로그래머스] 숨어있는 숫자의 덧셈(2)(Swift) 코드 회고 어떻게 풀지 감이 안와 다른 사람의 코드를 보고 이해를 하였다 reduce라는 고차함수는 데이터를 합쳐주기 위해 사용하는 함수이다 map, filter, reduce 같은 고차함수들을 공부해야겠다 velog.io
2023.11.21 -
var sorted: [Int] = numbers.sorted() var a: Int = sorted[0]*sorted[1] var b: Int = sorted[numbers.count-1]*sorted[numbers.count-2] return a > b ? a : b 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
[Programmers] 최대값 만들기(2)var sorted: [Int] = numbers.sorted() var a: Int = sorted[0]*sorted[1] var b: Int = sorted[numbers.count-1]*sorted[numbers.count-2] return a > b ? a : b 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
2023.11.21 -
func solution(_ dots:[[Int]]) -> Int { var x = dots[0][0] - dots[1][0] != 0 ? dots[0][0] - dots[1][0] : (dots[0][0] - dots[2][0] != 0 ? dots[0][0] - dots[2][0] : dots[0][0] - dots[3][0]) var y = dots[0][1] - dots[1][1] != 0 ? dots[0][1] - dots[1][1] : (dots[0][1] - dots[2][1] != 0 ? dots[0][1] - dots[2][1] : dots[0][1] - dots[3][1]) return abs(x)*abs(y) } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그..
[Programmers] 직사각형 넓이 구하기func solution(_ dots:[[Int]]) -> Int { var x = dots[0][0] - dots[1][0] != 0 ? dots[0][0] - dots[1][0] : (dots[0][0] - dots[2][0] != 0 ? dots[0][0] - dots[2][0] : dots[0][0] - dots[3][0]) var y = dots[0][1] - dots[1][1] != 0 ? dots[0][1] - dots[1][1] : (dots[0][1] - dots[2][1] != 0 ? dots[0][1] - dots[2][1] : dots[0][1] - dots[3][1]) return abs(x)*abs(y) } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그..
2023.11.20 -
func solution(_ my_str:String, _ n:Int) -> [String] { var arr: [String] = [] var result = "" for i in my_str{ result += String(i) if result.count == n{ arr.append(result) result = "" } } if !result.isEmpty{ arr.append(result) } return arr } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
[Programmers] 잘라서 배열로 저장하기func solution(_ my_str:String, _ n:Int) -> [String] { var arr: [String] = [] var result = "" for i in my_str{ result += String(i) if result.count == n{ arr.append(result) result = "" } } if !result.isEmpty{ arr.append(result) } return arr } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
2023.11.17