문자열 다루기 기본 Python def solution(s): if s.isdigit(): if len(s) in(4, 6): return True return False Go import "strconv" func solution(s string) bool { if _, err := strconv.Atoi(s); err == nil { if len(s) == 4 || len(s) == 6 { return true } } return false } 프로그래머스/LEVEL 1 2021.10.10
Go 두 정수 사이의 합 Go func solution(a int, b int) int64 { total := 0 if a > b { a, b = b, a } for i := a; i 프로그래머스/LEVEL 1 2021.10.04
6주차_복서 정렬하기 Go import ( "strings" "sort" ) type Person struct { number int weights int rates float64 winWeights int } func solution(weights []int, head2head []string) []int { people := make([]Person, 0) for i := 0; i < len(weights); i++ { winRates, winWeights := calculateRates(strings.Split(head2head[i], ""), weights, weights[i]) people = append(people, Person{i+1, weights[i], winRates, winWeights}) } sort... 프로그래머스/LEVEL 1 2021.10.04
4주차_직업군 추천하기 Go import ( "strings" ) func solution(table []string, languages []string, preference []int) string { var jobName string var score int = 0 for i := 0; i < len(table); i++ { langMap := make(map[string]int) nowJobScore := 0 langScoreArr := strings.Split(table[i], " ") for j := 1; j < len(langScoreArr); j++ { langMap[langScoreArr[j]] = len(langScoreArr) - j } for k := 0; k < len(languages); k++ { if.. 프로그래머스/LEVEL 1 2021.09.26
없는 숫자 더하기 Java class Solution { public int solution(int[] numbers) { int answer = 0; for (int i = 1; i < 10; i++) { answer += i; } for (int i = 0; i < numbers.length; i++) { answer -= numbers[i]; } return answer; } } Python def solution(numbers): total = sum([i for i in range(0, 10)]) for num in numbers: total -= num return total Go func solution(numbers []int) int { total := 0 for i := 0; i < 10; i ++ { .. 프로그래머스/LEVEL 1 2021.09.19
2주차_상호평가 Python def solution(scores): answer = '' for studentNum in range(len(scores)): myScore = scores[studentNum][studentNum] score = [i[studentNum] for i in scores] score.remove(myScore) if max(score) >= myScore and min(score) = 90: return 'A' elif score >= 80: return 'B' elif score >= 70: return 'C' elif score >= 50: return 'D' return 'F' 프로그래머스/LEVEL 1 2021.09.19
서울에서 김서방 찾기 Java Python def solution(seoul): return "김서방은 {}에 있다".format(seoul.index("Kim1")) Go import ( "strconv" ) func solution(seoul []string) string { for i, name := range seoul { if name == "Kim" { return "김서방은 "+strconv.Itoa(i)+"에 있다" } } return "" } 프로그래머스/LEVEL 1 2021.09.19
1주차_부족한 금액 계산하기 Java class Solution { public long solution(int price, int money, int count) { long answer = 0; for (int i = 1; i = 0) { return answer - money; } else { return 0; } } } Python def solution(price, money, count): answer = 0 total = sum([i * price for i in range(1, count + 1)]) answer = total - money return answer if answer >= 0 else 0 Go func solution(price int, money int, count int) int64 { total .. 프로그래머스/LEVEL 1 2021.09.19
Go K번째수 import ( "sort" ) func solution(array []int, commands [][]int) []int { result := make([]int, len(commands)) for i := 0; i < len(commands); i++ { arr := make([]int, len(array)) copy(arr, array) arr = arr[commands[i][0] - 1 : commands[i][1]] sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j]}) result[i] = arr[commands[i][2] -1] } return result } 프로그래머스/LEVEL 1 2021.08.17
약수의 개수와 덧셈 Java class Solution { public int solution(int left, int right) { int answer = 0; for(int number = left; number 프로그래머스/LEVEL 1 2021.06.13