SWIFT
-
๋์ผ์ฑ๊ณผ ๋๋ฑ์ฑCS(ComputerScience) 2021. 7. 21. 19:42
์๋ ํ์ธ์. ๊ทธ๋ฆฐ์ ๋๋ค๐ข ์ด๋ฒ ํฌ์คํ ์์๋ ๋์ผ์ฑ๊ณผ ๋๋ฑ์ฑ์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค๐๐ป ๋์ผ์ฑ๊ณผ ๋๋ฑ์ฑ ๊ทธ๋ฅ ์์๋ณด๊ธฐ์ ๋ปํ์ด๋ถํฐ ๋๋ฆ๋๋ก ์ถ์ธกํด๋ณผ๊น์? ๋์ผ์ฑ์ A์ B๊ฐ ์ ๋ถ ๊ฐ์ ์ฆ ๋์ผํ ๋ ์ฐ์ธ๋ค๊ณ ๋ณด์ด๊ณ , ๋๋ฑ์ฑ์ A์ B๊ฐ ์์ ํ ๊ฐ์ง ์์ง๋ง ๊ฐ์ ๋ถ๋ถ๋ค์ด ์์ด ๋๋ฑํ๊ฒ ๋ณผ ์ ์๋ค? ๋ผ๊ณ ๋๊ปด์ง๋๋ค. ๊ทธ๋ผ ์กฐ๊ธ ๋ ์์ธํ ๊ฐ์ฒด์งํฅ์ ์๊ฐํ๋ฉฐ ์์๋ณด๊ฒ ์ต๋๋ค. ๊ฐ์ฒด์งํฅ์์๋ ๋๊ฐ์ A์ B ๊ฐ์ฒด๊ฐ ์๋ค๊ณ ๊ฐ์ ํฉ์๋ค! ๊ทธ๋ผ A์ B์ ๊ฐ์ฒด๋ ์๋ก ๋ค๋ฅธ ์ฃผ์๊ฐ์ ๊ฐ์ต๋๋ค. ์ด ๊ฒฝ์ฐ์๋ A์ B๊ฐ ๊ฐ์ ์ฃผ์๊ฐ์ ๊ฐ๋ฅดํค๊ธฐ ์๊ธฐ์ ์์ ํ ๊ฐ๋ค๊ณ ํ ์ ์์ต๋๋ค. ์ฆ ์์ ๊ฐ๋ ์ผ๋ก ๋์ผ์ฑ๊ณผ ๋๋ฑ์ฑ์ ๊ฐ๋ตํ ์ ๋ฆฌํด๋ณด๊ฒ ์ต๋๋ค. - ๋์ผ์ฑ: A์ B์ ๊ฐ์ฒด๊ฐ ์์ ํ ๊ฐ์ ๊ฒฝ์ฐ๋ฅผ ์๋ฏธ - ๋๋ฑ์ฑ: A์ B์ ๊ฐ์ฒด๊ฐ ..
-
FlogRiverOne ์๊ณ ๋ฆฌ์ฆAlgorithm 2021. 7. 18. 10:45
์๋ ๋ฌธ์ ๋ ์ฝ๋๋ฆฌํฐ์์ ์ ๊ณตํ๋ FlogRiverOne์ ๋ฌธ์ ์ ๋๋ค๐ง๐ป๐ป ๋ฌธ์ ์ ์ A small frog wants to get to the other side of a river. The frog is initially located on one bank of the river (position 0) and wants to get to the opposite bank (position X+1). Leaves fall from a tree onto the surface of the river. You are given an array A consisting of N integers representing the falling leaves. A[K] represents the position wher..
-
Composable Architecture๋ก ๋๋ค ํต์ ๊ตฌํํ๊ธฐTCA 2021. 7. 17. 15:32
์๋ ํ์ธ์. ๊ทธ๋ฆฐ์ ๋๋ค๐ข ์ด๋ฒ ํฌ์คํ ์์๋ Composable Architecture์ผ๋ก ๋๋คํ ํต์ ์ ๊ตฌํํด๋ณด๊ฒ ์ต๋๋ค๐ง๐ป๐ป ๋ทฐ๋ SwiftUI๋ฅผ ํตํด ๊ฐ๋จํ ๊ตฌํํ์์ต๋๋ค. ์ฐ์ ๊ฐ๋ตํ ๊ธฐ๋ฅ์ ์ค๋ช ๋๋ฆฌ๊ฒ ์ต๋๋ค. Composable Architecture๋ฅผ ์ด์ฉํ์ฌ ๋ทฐ์ ์ํ๋ฅผ ์ด๋ฒคํธ ํ๋ฆ์ ๋ฐ๋ผ ๋ค๋ฃฐ ์ ์๋ ์์ฃผ ๊ฐ๋จํ ์์ ๋ก ํต์ ์ GET์ ID ์ธ๋ฑ์ค๋ฅผ ๋๊ฒจ ํต์ ํ ๋ ํด๋น ์ธ๋ฑ์ค๋ฅผ ๋๋คํ๊ฒ ๋ฝ๊ณ ํต์ ๋ฐ ํ์ฑํ ํ ID์ ํ์ดํ์ UI์ 3์ด๋ง๋ค ์๋ ๊ฐฑ์ ๋๋๋ก ๋ทฐ๋ฅผ ์ ๋ฐ์ดํธ ํ๋ ๊ธฐ๋ฅ์ ๊ฐ์ง๋๋ค๐ง๐ป๐ป ๋ํ ์๋/์๋ ๋ณ๊ฒฝ ๋ฒํผ์ ๋์ด ํด๋น ์กฐ๊ฑด์ ๋ฐ๋ผ ํต์ ๋๋๋ก ๊ตฌํํฉ๋๋ค. (์ด์ ์ ReactorKit์ผ๋ก ๋๋ค ํต์ ์ ๊ตฌํํ ์คํ๊ณผ ๋์ผํฉ๋๋ค.) ์ฌ๊ธฐ ํฌ์คํ ์์๋ ํ์ ํ์ผ์ ๋ํ ๊ตฌํ๋ค๋ง..
-
์๊ฐ๋ณต์ก๋๋ฅผ ๊ณ ๋ คํ ์๊ณ ๋ฆฌ์ฆ (3)Algorithm 2021. 7. 11. 13:50
์๋ ๋ฌธ์ ๋ ์ฝ๋๋ฆฌํฐ์์ ์ ๊ณตํ๋ TapeEquilibrium์ ๋ฌธ์ ์ ๋๋ค๐ง๐ป๐ป ๋ฌธ์ ์ ์ A non-empty array A consisting of N integers is given. Array A represents numbers on a tape. Any integer P, such that 0 < P < N, splits this tape into two non-empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1]. The difference between the two parts is the value of: |(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + ..
-
ReactorKit์ผ๋ก ๋๋ค ํต์ ๊ตฌํํ๊ธฐiOS 2021. 7. 10. 09:30
์๋ ํ์ธ์. ๊ทธ๋ฆฐ์ ๋๋ค๐ข ์ด๋ฒ ํฌ์คํ ์์๋ ReactorKit์ผ๋ก ๋๋คํ ํต์ ์ ๊ตฌํํด๋ณด๊ฒ ์ต๋๋ค๐ง๐ป๐ป ์ฐ์ ๊ฐ๋ตํ ๊ธฐ๋ฅ์ ์ค๋ช ๋๋ฆฌ๊ฒ ์ต๋๋ค. ReactorKit์ ์ด์ฉํ์ฌ ๋ฆฌ์กํฐ๋ฅผ ๋ค๋ฃฐ ์ ์๋ ์์ฃผ ๊ฐ๋จํ ์์ ๋ก ํต์ ์ GET์ ID ์ธ๋ฑ์ค๋ฅผ ๋๊ฒจ ํต์ ํ ๋ ํด๋น ์ธ๋ฑ์ค๋ฅผ ๋๋คํ๊ฒ ๋ฝ๊ณ ํต์ ๋ฐ ํ์ฑํ ํ ID์ ํ์ดํ์ UI์ 3์ด๋ง๋ค ์๋ ๊ฐฑ์ ๋๋๋ก ๋ทฐ๋ฅผ ์ ๋ฐ์ดํธ ํ๋ ๊ธฐ๋ฅ์ ๊ฐ์ง๋๋ค๐ง๐ป๐ป ์ฌ๊ธฐ ํฌ์คํ ์์๋ ํ์ ํ์ผ์ ๋ํ ๊ตฌํ๋ค๋ง ๊ฐ๋จํ ์๊ฐํ๊ณ ์๋ ์ Git ๋ ํฌ ์ฃผ์๋ฅผ ๋จ๊ฒจ๋๊ฒ ์ต๋๋ค! ๋ ์ฐธ๊ณ ํ์ค ๋ถ๋ค์ Git์ ์ฐธ๊ณ ํด์ฃผ์ธ์๐๐ป 1. Model 1) JSON ๊ตฌ์กฐ์ฒด - ํต์ ํ JSON ๋ฐ์ดํฐ๋ฅผ ํ์ฑํ ๊ตฌ์กฐ์ฒด๋ฅผ ์์ฑํฉ๋๋ค. import Foundation struct RandomInfo:..
-
์๊ฐ๋ณต์ก๋๋ฅผ ๊ณ ๋ คํ ์๊ณ ๋ฆฌ์ฆ (2)Algorithm 2021. 7. 7. 21:56
์๋ ๋ฌธ์ ๋ ์ฝ๋๋ฆฌํฐ์์ ์ ๊ณตํ๋ permMissingElem์ ๋ฌธ์ ์ ๋๋ค๐ง๐ป๐ป ๋ฌธ์ ์ ์ An array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing. Write a function: public func solution(_ A : inout [Int]) -> Int that, given an array A, returns the value of the missing element. For example, given array A such that: A[0] = 2 A[1] = 3..
-
ReactorKit์ผ๋ก ๊ณ์ฐ๊ธฐ ๊ตฌํํ๊ธฐSwift 2021. 7. 5. 21:48
์๋ ํ์ธ์. ๊ทธ๋ฆฐ์ ๋๋ค๐ข ์ด๋ฒ ํฌ์คํ ์์๋ ReactorKit์ผ๋ก ๊ณ์ฐ๊ธฐ๋ฅผ ๊ตฌํํด๋ณด๊ฒ ์ต๋๋ค๐ง๐ป๐ป ์ฐ์ ์ด๋ฒ ๊ณ์ฐ๊ธฐ ํ๋ก์ ํธ ๊ฐ์ ๊ฒฝ์ฐ์๋ ReactorKit์ผ๋ก ์ด๋์ ๋ ์ ํํ๋ ๋ฆฌ์กํธ MVVM ์ํคํ ์ณ ํจํด์ ๋ฐ๋ฆ ๋๋ค. ์ฌ๊ธฐ ํฌ์คํ ์์๋ ํ์ ํ์ผ์ ๋ํ ๊ตฌํ๋ค๋ง ๊ฐ๋จํ ์๊ฐํ๊ณ ์๋ ์ Git ๋ ํฌ ์ฃผ์๋ฅผ ๋จ๊ฒจ๋๊ฒ ์ต๋๋ค! ๋ ์ฐธ๊ณ ํ์ค ๋ถ๋ค์ Git์ ์ฐธ๊ณ ํด์ฃผ์ธ์๐๐ป 1. View - ๋ทฐ๋ ์ฐ์ ์คํ ๋ฆฌ๋ณด๋๋ก UI์์ ๋ฐฐ์น์ ์คํ ๋ ์ด์์์ ์ ์ฉํ์ต๋๋ค. - ๊ทธ ํ ViewController์์ ReactorKit์ ์ํฌํธํ๊ณ ์คํ ๋ฆฌ๋ณด๋๋ทฐ๋ฅผ ์ฑํํ์ฌ ๋ฆฌ์กํธ์ ๋ฐ์ธ๋ฉ๋ ์ ์๊ฒ ๊ตฌํํ์์ต๋๋ค. import UIKit import ReactorKit import RxCocoa class CalculatorV..
-
์๊ฐ๋ณต์ก๋๋ฅผ ๊ณ ๋ คํ ์๊ณ ๋ฆฌ์ฆAlgorithm 2021. 6. 30. 12:30
์๋ ๋ฌธ์ ๋ ์ฝ๋๋ฆฌํฐ์์ ์ ๊ณตํ๋ FlogJmp์ ๋ฌธ์ ์ ๋๋ค๐ง๐ป๐ป ๋ฌธ์ ์ ์ A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must perform to reach its target. Write a function: class Solution { public int solution(in..