"If you do nothing, nothing will happen."

프로그래밍 62

[Hackerrank] Left Rotation

2019-05-27 글쓴이 TED HONG [Hackerrank] Left Rotation 배열 a 중에 특정한 숫자 n을 지정한 횟수 d 만큼 왼쪽으로 로테이션 시키는 문제 class Solution { static void Main(string[] args) { string[] nd = Console.ReadLine().Split(' '); int n = Convert.ToInt32(nd[0]); int d = Convert.ToInt32(nd[1]); int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), aTemp => Convert.ToInt32(aTemp)) ; int[] result = GetRotateArray(n, d, a); Console..

프로그래밍 2023.02.20

[HackerRank] Sherlock and Anagrams

2019-05-22 글쓴이 TED HONG [HackerRank] Sherlock and Anagrams 문자열내의 Anagram 쌍이 몇개인지 찾는 문제 단어를 잘라서 Lowercase 로 변환, 정렬 후 Dictionary 에 (단어, 갯수) 로 넣어서 계산하는 방식도 될 거 같은데 일단 무식한 방법으로 풀어봤다. 3중for문이라 인풋값에 긴 문자열이 들어오면 타임아웃이 뜬다;;; static int sherlockAndAnagrams(string s) { int result = 0; for (int i = 1; i < s.Length + 1; i++) //i 는 단어의 길이 점점 늘어남 { List words = new List(); for (int j = 0; j < s.Length - (i -1..

프로그래밍 2023.02.20

[HackerRank] New Year Chaos

2019-05-22 글쓴이 TED HONG [HackerRank] New Year Chaos 줄을 서있는데 뒷사람이 앞사람에게 뇌물을 주고 자리를 바꿀 수 있음 한 사람당 2회 가능. 주어진 순서가 되려면 몇번 뇌물이 오고갔는가? 헷갈리네. ㅠ static void minimumBribes(int[] q) { const int bribePower = 2; bool isChaotic = false; int n = q.Length; for (int i = 0; i bribePower) { Console.WriteLine("Too chaotic"); isChaotic = true; break; } } int bribeCount = 0; if (isChaotic == false) { for (int i = 0;..

프로그래밍 2023.02.20

[Hackerrank] 2D Array – DS

2019-05-20 글쓴이 TED HONG [Hackerrank] 2D Array – DS 2중 배열안에서 모래시계 모양의 패턴을 찾아 해당 좌표의 값을 모두 더했을 때 가장 큰 값을 찾는 문제 음수 비교가 필요한 경우가 있으므로 결과값 변수를 int.MinValue로 초기화 한다. static int hourglassSum(int[][] arr) { int result = int.MinValue; int row = arr.Length; for (int i = 0; i < row -2; i++) { int col = arr[i].Length; for (int j = 0; j < col -2; j++) { int sum = arr[i][j] + arr[i][j + 1] + arr[i][j + 2]; sum..

프로그래밍 2023.02.20

[Hackerrank] Repeated String

2019-05-20 글쓴이 TED HONG [Hackerrank] Repeated String 인풋값은 두가지 반복 할 문자열, 문자열의 총 길이. 문자열의 총 길이만큼 문자열을 반복한 후에 전체 문자열에 포함된 a 의 갯수를 구하는 문제. static long repeatedString(string s, long n) { long result = 0; long strLength = s.Length; var cntStr = new System.Text.RegularExpressions.Regex("a"); long aCount = cntStr.Matches(s).Count; long q = n / strLength; long r = n % strLength; result = q * aCount; if(r..

프로그래밍 2023.02.20

[Unity] Application.systemLanguage -> ISO 639-1 변환

2018-07-30 글쓴이 TED HONG [Unity] Application.systemLanguage -> ISO 639-1 변환 Application.systemLanguage -> ISO 639-1 변환하는 함수입니다. public static string GetLocalCode() { switch(Application.systemLanguage) { case SystemLanguage.Afrikaans: return "af"; case SystemLanguage.Arabic: return "ar"; case SystemLanguage.Basque: return "eu"; case SystemLanguage.Belarusian: return "be"; case SystemLanguage.Bulga..

프로그래밍 2023.02.20

[Unity3D] UGUI 아틀라스에서 Sprite 파일 분리하기

2018-03-28 글쓴이 TED HONG [Unity3D] UGUI 아틀라스에서 Sprite 파일 분리하기 이미 합쳐져 있는 UGUI용 Atlas File 에서 Sprite 를 분리하는 방법 Atlas 의 Texture로 부터 Sprite 영역만큼 Pixel 값을 가져와 새로운 Texture에 입히고 파일로 저장하면 됩니다. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class AtlasLoader { public Dictionary spriteDic = new Dictionary(); public AtlasLoader() { } public AtlasLoad..

프로그래밍 2023.02.20