일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- progamming
- 코린이
- 렛츠톡 첫 화면
- Uniting Worlds
- 신세지다
- Polite
- Swift
- Playground
- Making Your Own Portals
- crank up and down
- obliged
- Grammarly
- 컴터 연결
- 인앱 결제
- feel torn
- collect the total
- Connect and Solve
- Playgrounds
- BASIC
- SwiftUI
- Generalizing a Funcetion
- 코딩
- Learning
- coding
- 2대 연결
- 맥
- 구글이 좋아하는 강한 SEO 작성 방법
- 기초
- 해당 비즈니스 및 사이트명을 포함할 수 있도록 페이지 텍스트를 편집하세요 - wix.com
- allege
- Today
- Total
IT
day 5 - algorithms 본문
A algorithm is a set of rules and instructions you use solve the problem. For example, a navigation app uses an algorithm to figure out the fastest path to where you want to go.
the skill you are adding now is the process of writing and tweaking code so you can use it in different situations.
this puzzle has many different solutions, so trust your instincts and try different ideas until one works. A good way to begin is to think through (or write down) how you want to solve the puzzle, and then translate your thought into codes.
solution)
func navigateAroundWall() {
if isBlockedRight {
moveForward()
} else {
turnRight()
moveForward()
}
}
while !isOnClosedSwitch {
navigateAroundWall()
if isOnGem {
collectGem()
turnLeft()
turnLeft()
}
}
toggleSwitch()
comments ) it is not easy work especially, at the end of this process.
Quest 2
func navigateAroundWall() {
if isBlockedRight && isBlocked {
turnLeft()
moveForward()
} else if isBlockedRight {
moveForward()
} else {
turnRight()
moveForward()
}
}
while !isOnClosedSwitch {
navigateAroundWall()
if isOnGem {
collectGem()
turnLeft()
turnLeft()
}
}
toggleSwitch()
Quest 3
Solution>
func navigateAroundWall() {
if isBlockedRight && isBlocked{
turnLeft()
moveForward()
} else if isBlockedRight{
moveForward()
} else {
turnRight()
moveForward()
}
}
while !isOnGem {
navigateAroundWall()
}
collectGem()
Quest 4
my solution >
func navigate() {
if isOnClosedSwitch && !isBlocked {
toggleSwitch()
turnRight()
moveForward()
} else if isOnClosedSwitch && isBlocked {
toggleSwitch()
turnLeft()
moveForward()
} else {
moveForward()
}
}
while !isOnGem {
navigate()
}
collectGem()
comment> figure out the pattern. this is the first thing I have to do.
Quest 5
func navigate() {
if isBlocked && isOnGem {
turnRight()
collectGem()
moveForward()
collectGem()
} else if isBlocked && isBlockedRight {
turnLeft()
moveForward()
if isOnClosedSwitch {
turnLeft()
toggleSwitch()
moveForward()
toggleSwitch()
moveForward()
}
} else if isBlocked && isBlockedLeft {
turnRight()
} else {
moveForward()
}
}
while !isOnOpenSwitch{
navigate()
}
turnLeft()
just what I did. it was not easy