250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 일시정지
- 플레이어 방향전환
- Scrooling
- raycasting
- Hp바
- 스크롤링
- Transform
- Object Pooling
- rigidbody
- raycast
- rotation
- 유니티
- 2D슈팅게임
- 패럴렉스
- Prefabs
- Object Poling
- Blend Type
- Animation State Machine
- 플레이어 이동
- 오브젝트 풀링
- Unity
- apk
- Parallax
- joystick
- LayerMark
- Vector3
- 프리팹
- Hpbar
- Ainimation Blending
- CSharp #자료구조
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.1 성격 유형 검사하기 본문
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/118666
1. 정답코드 및 핵심 아이디어, 유의사항
- 문제를 읽자마자 Dictionary를 떠올려야 함
- 어피치형과 네오형 점수를 뽑는 수식을 만들면 편하게 사용할 수 있음
using System;
using System.Collections.Generic;
using System.Text;
public class Solution
{
public string solution(string[] survey, int[] choices)
{
string answer = "";
Dictionary<char, int> dict = new Dictionary<char, int>
{
{'R', 0}, {'C', 0}, {'J', 0}, {'A', 0},
{'T', 0}, {'F', 0}, {'M', 0}, {'N', 0},
};
for (int i = 0; i < survey.Length; i++)
{
if (choices[i] < 4)
dict[survey[i][0]] += (choices[i] * 3) % 4;
else if (choices[i] > 4) // 뒤에 꺼
dict[survey[i][1]] += choices[i] - 4;
}
answer += (dict['R'] >= dict['T']) ? "R" : "T";
answer += (dict['C'] >= dict['F']) ? "C" : "F";
answer += (dict['J'] >= dict['M']) ? "J" : "M";
answer += (dict['A'] >= dict['N']) ? "A" : "N";
return answer;
}
}
728x90
'Programmers - C# > CodingTest Lv.1' 카테고리의 다른 글
[프로그래머스 C#] Lv.1 대충 만든 자판 (0) | 2023.08.30 |
---|---|
[프로그래머스 C#] Lv.1 둘만의 암호 (0) | 2023.08.23 |
[프로그래머스 C#] Lv.1 달리기 경주 (0) | 2023.08.20 |
[프로그래머스 C#] Lv.1 숫자 짝꿍 (0) | 2023.08.18 |
[프로그래머스 C#] Lv.1 공원 산책 (0) | 2023.08.18 |