Notice
Recent Posts
Recent Comments
Link
«   2026/09   »
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
Tags
more
Archives
Today
Total
관리 메뉴

언리얼 공부 블로그

코드카타 개인정보 수집 유효 기간, 숫자 야구 게임 본문

카테고리 없음

코드카타 개인정보 수집 유효 기간, 숫자 야구 게임

maypawn 2025. 9. 3. 16:57

개인정보 수집 유효 기간

 

오늘 날짜를 기준으로 유효기간이 지나 파기해야할 개인정보의 번호를 찾고 오름차순 정렬하기

 

terms 배열 순회해 key value를 map에 저장

반복문 for 루프로 privacies 배열 순회

 

#include <string>
#include <vector>
#include <map>
#include <sstream>

using namespace std;

// 날짜 문자열 헬퍼 함수 (YYYY.MM.DD)
int dateToDays(string date_str) {
    stringstream ss(date_str);
    string year_s, month_s, day_s;
    // '.' 을 기준으로 문자열 파싱
    getline(ss, year_s, '.');
    getline(ss, month_s, '.');
    getline(ss, day_s, '.');
    
    int year = stoi(year_s);
    int month = stoi(month_s);
    int day = stoi(day_s);
    // 모든 달은 28일 이라고 가정하기
    return (year * 12 * 28) + (month * 28) + day;
}

vector<int> solution(string today, vector<string> terms, vector<string> privacies) {
    vector<int> answer;
    
    // terms 의 key value 를 map 에 저장
    map<string, int> termsMap;
    for (const auto& term_str : terms) {
        stringstream ss(term_str);
        string type;
        int month;
        ss >> type >> month;
        termsMap[type] = month;
    }
    // 오늘 날짜를 총 일수로 전환
    int today_days = dateToDays(today);
    
    // for 루프로 privacies 순회
    for (int i = 0; i < privacies.size(); ++i) {
        const string& privacy_str = privacies[i];
        // 수집 일자와 약관 종류 파싱
        stringstream ss(privacy_str);
        string collection_date_str;
        string term_type;
        ss >> collection_date_str >> term_type;
        // 수집일자 총 일수로 변환
        int collection_days = dateToDays(collection_date_str);
        // 약관 유효기간 일수로 변환
        int term_duration_months = termsMap[term_type];
        int term_duration_days = term_duration_months * 28;
        // 파기 시작일
        // collection_days + term_duration_days - 1; 보관 가능한 마지막 날
        int expiration_days = collection_days + term_duration_days;
        
        if (today_days >= expiration_days) {
            answer.push_back(i + 1); // 개인정보 번호는 1부터 시작하니 i + 1;
        }
    }
    
    
    return answer;
}

 


채팅 기능을 이용한 숫자 야구 게임

 

서버를 이용해서 여러 플레이어들이 채팅 기능을 통해 3자리 숫자를 맞추면 되는 게임.

서버가 생성한 랜덤의 3자리 숫자를 각 플레이어들은 3번의 기회 동안 맞추면 승리한다. 

 

기능 구현 스크린샷

텍스트 입력 시 로그에 출력되며 플레이어 이름/ 횟수/ 숫자 순으로 출력된다.

 

게임에 접속 시 서버 공지로 접속 했음, 승리를 출력한다.