260119 TIL - Unreal C++ 8일차
2026. 1. 19. 20:51ㆍ언리얼 7기 본캠프
오늘 코드카타는 지문이 눈에 바로 안들어오고 좀 복잡한 케이스여서, 지문을 침착하게 읽고 요구사항을 파악한 뒤 코드로 작성하는 연습을 했음
결과적으로 둘 다 풀긴 했는데, 하나는 너무 불필요한 반복이 많은 느낌. 정제할 방법을 고민해봐야 할 것 같음
//성격유형 문제. 이러면 케이스를 유동적으로 늘릴 수 없다는 문제가 있음...
string solution(vector<string> survey, vector<int> choices) {
string answer = "";
vector<int> score = {-3,-2,-1,0,1,2,3};
vector<char> type = {'R','T','C','F','J','M','A','N'};
vector<int> typescore(8,0);
for(int i = 0; i < survey.size(); i++){
if(survey[i] == "RT"){
if(choices[i] == 0) continue;
if(choices[i] < 0) typescore[0] += score[choices[i]-1];
else typescore[1] += score[choices[i]-1];
continue;
}
if(survey[i] == "TR"){
if(choices[i] == 0) continue;
if(choices[i] < 0) typescore[1] += score[choices[i]-1];
else typescore[0] += score[choices[i]-1];
continue;
}
if(survey[i] == "FC"){
if(choices[i] == 0) continue;
if(choices[i] < 0) typescore[2] += score[choices[i]-1];
else typescore[3] += score[choices[i]-1];
continue;
}
if(survey[i] == "CF"){
if(choices[i] == 0) continue;
if(choices[i] < 0) typescore[3] += score[choices[i]-1];
else typescore[2] += score[choices[i]-1];
continue;
}
if(survey[i] == "MJ"){
if(choices[i] == 0) continue;
if(choices[i] < 0) typescore[4] += score[choices[i]-1];
else typescore[5] += score[choices[i]-1];
continue;
}
if(survey[i] == "JM"){
if(choices[i] == 0) continue;
if(choices[i] < 0) typescore[5] += score[choices[i]-1];
else typescore[4] += score[choices[i]-1];
continue;
}
if(survey[i] == "AN"){
if(choices[i] == 0) continue;
if(choices[i] < 0) typescore[6] += score[choices[i]-1];
else typescore[7] += score[choices[i]-1];
continue;
}
if(survey[i] == "NA"){
if(choices[i] == 0) continue;
if(choices[i] < 0) typescore[7] += score[choices[i]-1];
else typescore[6] += score[choices[i]-1];
continue;
}
}
if (typescore[0]>typescore[1]) answer+='R';
else if (typescore[0]<typescore[1]) answer+='T';
else answer+='R';
if (typescore[2]>typescore[3]) answer+='F';
else if (typescore[2]<typescore[3]) answer+='C';
else answer+='C';
if (typescore[4]>typescore[5]) answer+='M';
else if (typescore[4]<typescore[5]) answer+='J';
else answer+='J';
if (typescore[6]>typescore[7]) answer+='A';
else if (typescore[6]<typescore[7]) answer+='N';
else answer+='A';
return answer;
}
//바탕화면 문제. 얼핏 봤을때 '2차원벡터 필요한 문제 아닌가?'
//라는 생각을 하긴 했는데 굳이 그럴 필요가 없었음
vector<int> solution(vector<string> wallpaper) {
vector<int> answer;
int lux = -1;
int luy = -1;
int rdx = -1;
int rdy = -1;
for(int i = 0; i < wallpaper.size(); i++){
for(int j = 0; j < wallpaper[i].length(); j++){
if(wallpaper[i][j] == '.') continue;
if(wallpaper[i][j] == '#'){
if(lux == -1) lux = i;
else if(lux > i) lux = i;
if(luy == -1) luy = j;
else if(luy > j) luy = j;
if(rdx == -1) rdx = i+1;
else if(rdx < i+1) rdx = i+1;
if(rdy == -1) rdy = j+1;
else if(rdy < j+1) rdy = j+1;
}
}
}
answer = {lux, luy, rdx, rdy};
return answer;
}
이후 오늘 처음 진행된 챌린지반 강의에선 룰렛(?)을 통해 언리얼에서 사용하는 GameplayTags에 대해서 배웠음
캐릭터의 상태를 나타내는 bool이 너무 많아지면 관리하기 힘들것같다는 생각을 이전부터 어렴풋이 하기는 했었는데, 그것을 언리얼의 방식대로 해결하는게 GameplayTags였음. 이건 잘 기억해뒀다가 나중에 게임 만들때 사용하면 정말 편하겠다는 생각이 들었음
이후 강의는 주말 포함해서 오늘 2강 전체를 다 들었음. 캐릭터를 이용해서 이동을 C++로 구현하는 방식이었는데, 과제는 Pawn 클래스로 이동을 구현하는거라 추가적인 공부가 좀 더 필요할것으로 보임. 이번과제는 힘 좀 빼고 열심히 구현해봐야겠음. 도전과제까지 목표로 화이팅~
'언리얼 7기 본캠프' 카테고리의 다른 글
| 260121 TIL - Unreal C++ 10일차 (0) | 2026.01.21 |
|---|---|
| 260120 TIL - Unreal C++ 9일차 (1) | 2026.01.20 |
| 260116 TIL - Unreal C++ 7일차, 6번 과제 제출 (0) | 2026.01.16 |
| 260115 TIL - Unreal C++ 6일차 (1) | 2026.01.15 |
| 260114 TIL - Unreal C++ 5일차 (0) | 2026.01.14 |