입력받은 텍스트는 반복적인 순서로 SOS가 되어야 한다.
SOS의 순서가 아닌 문자의 를 찾을 것.
해결방법.
문자마다 3으로 나눈 나머지로 나머지가 0일때 S, 1일때O 2일때 S를 비교했다.
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
class Solution
{
// Complete the marsExploration function below.
static int marsExploration(string s)
{
int count = 0;
char[] tmp = s.ToArray<Char>();
for (int i = 0; i < tmp.Length; i++)
{
int share = i % 3;
char c = tmp[i];
if ((share == 0 || share == 2) && c == 'S')
continue;
else if (share == 1 && c == 'O')
continue;
count += 1;
}
return count;
}
static void Main(string[] args)
{
TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
string s = Console.ReadLine();
int result = marsExploration(s);
textWriter.WriteLine(result);
textWriter.Flush();
textWriter.Close();
}
}
190305
회고 : 쓰기 싫은 코드였는데 밀린문제 처리중 ㅠㅠ 나중에 다시봐야징