두 수를 입력받아 두 수의 최대공약수와 최소공배수를 반환하는 함수, solution을 완성해 보세요. 배열의 맨 앞에 최대공약수, 그다음 최소공배수를 넣어 반환하면 됩니다. 예를 들어 두 수 3, 12의 최대공약수는 3, 최소공배수는 12이므로 solution(3, 12)는 [3, 12]를 반환해야 합니다.
| n | m |
|---|---|
| 3 | 12 |
| 2 | 5 |
public static void Main()
{
int n = 12;
int m = 30;
Solution solution = new Solution();
solution.solution(n, m);
}
public class Solution
{
public int[] solution(int n, int m)
{
// 최대공약수 겹치는 약수 중 소수를 곱한 값
// 12 = 1 2 3 4 6 12
// 30 = 1 2 3 5 6 10 15 30
// 12와 30의 최대 공약수는 2 * 3 = 6;
// 최소공배수 둘의 배수 중 겹치는 값중 가장 작은 값
// 12 = 24 36 48 60
// 30 = 60
// 12와 30의 최소공배수는 60;
List<int> listn = new List<int>();
List<int> listm = new List<int>();
for (int i = 1; i <= n; i++)
{
if (n % i == 0)
{
listn.Add(i);
}
}
for (int j = 1; j <= m; j++)
{
if (m % j == 0)
{
listm.Add(j);
}
}
int[] answer = new int[6];
return answer;
}
}
우선 입력 값의 약수를 리스트에 저장하는 것까진 하였으니 그 이후에는 로직을 생각하다가 팀프로젝트가 시급하여 멈추었다.. 내일 뿌실 예정
구현한 내용




Dotween을 활용하여 스토리 대사가 입력하듯 작성되게 하였습니다.
레벨에 따라 스토리가 해금되는 방식입니다.
핵심 스크립트
using DG.Tweening;
private Text text;
private Sequence sequence;
[SerializeField] private Button btn1;
[SerializeField] private Button btn2;
[SerializeField] private Button endBtn;
void Start()
{
text = GetComponent<Text>();
btn1.gameObject.SetActive(true);
OnPlay();
}
void OnPlay()
{
sequence.Play();
}
public void Line1()
{
sequence.Append(text.DOText("첫 번째 스토리 입니다. ", 2f).From(""));
btn1.gameObject.SetActive(false);
btn2.gameObject.SetActive(true);
}
public void EndScene(StoryLinePopup storyLinePopup)
{
storyLinePopup.storyLineIndex++;
TextBackGround.SetActive(false);
}
전체적으로 스토리 씬에 버튼 컴포넌트를 추가하였고 클릭 시 다음 대사로 넘어가는 방식으로 설계하였습니다.
public int storyLineIndex;
public void OnPopup()
{
popup.SetActive(true);
if (storyLineIndex == 1)
{
storyLine1.SetActive(true);
}
else if (storyLineIndex == 2 && enhancementSystem.currentLevel >= 5)
{
storyLine2.SetActive(true);
}
else if (storyLineIndex == 3 && enhancementSystem.currentLevel >= 10)
{
storyLine3.SetActive(true);
}
else if (storyLineIndex == 4 && enhancementSystem.currentLevel >= 15)
{
storyLine4.SetActive(true);
}
}
public void DisablePopup()
{
popup.SetActive(false);
if (storyLineIndex == 1)
{
storyLine1.SetActive(false);
}
else if (storyLineIndex == 2 && enhancementSystem.currentLevel >= 5)
{
storyLine2.SetActive(false);
}
else if (storyLineIndex == 3 && enhancementSystem.currentLevel >= 10)
{
storyLine3.SetActive(false);
}
else if (storyLineIndex == 4 && enhancementSystem.currentLevel >= 15)
{
storyLine4.SetActive(false);
}
}
storyLineIndex를 활용하여 스토리가 끝나면 버튼이 비활성화 되고 다음 스토리의 버튼이 활성화 되게 구현하였습니다.
enhancementSystem.currentLevel를 참조하여 레벨에 따라 스토리 진행 버튼을 활성, 비활성화 되게 구현하였습니다.
스토리 작성에 너무너무너무너무 많은 시간이 소요되었다.. 뒤늦게 쫒기 듯이 구현을 해버려서 부족한 점이 한 두가지가 아니다. 심지어 그렇게 고생해서 작성한 스크립트는 요약하여 넣을 시간이 부족하여 텅 빈 채로 제출하고 말았다. 선택과 집중을 잘했어야 했는데 새로운 프로젝트를 시작할 때마다 참 어렵게 느껴진다. 이를 경험 삼아 다음에는 실수하지 않으리.