728x90
SMALL

using System;

public class Solution {
    public int solution(int n) {
        int temp = 1;
        int answer = 1;
        int i =0;
        
        for(i=1;i<10;i++)
        {
            temp *= i+1;
            if(temp <= n)
            {
                answer++;   
            }
        }
        return answer;
    }
}

 

/////

 

using System;

public class Solution {
    public int solution(int n) {
        int temp = 1;
        int answer = 0;
        int i = 1;
        
        while(temp <= n)
        {
            temp *= i+1;
            answer++;
            i++;
        }
        
        return answer;
    }
}

 

파이썬

////

 

from math import factorial

def solution(n):
    k = 10
    while n < factorial(k):
        k -= 1
    return k

///////////

def solution(n):
    answer = 1
    factorial = 1
    while factorial <= n:
        answer += 1
        factorial = factorial * answer
    answer -= 1
    return answer

 

자바

////

 

class Solution {
    public int solution(int n) {
        int answer = 1;
        int factorial = 1;

        while(n >= factorial) 
        {
            answer ++;
            factorial *= answer;
        }
        return answer -1 ;
    }

}

 

728x90

설정

트랙백

댓글

728x90
SMALL

C#

 

 

 

using System;
using System.Linq;

public class Solution {
    public string solution(string my_string) {
        
        string answer = string.Concat(my_string.Distinct());
        return answer;
    }
}

 

 

 

 

파이썬

///

 

 

 

def solution(my_string):
    answer = ''
    for i in my_string:
        if i not in answer:
            answer+=i
    return answer

 

 

////

 

 

 

def solution(my_string):
    return ''.join(dict.fromkeys(my_string))

 

 

 

자바

/////

 

 

import java.util.*;
import java.util.stream.Collectors;

class Solution {
    public String solution(String myString) {
        return Arrays.stream(myString.split("")).distinct().collect(Collectors.joining());
    }
}

 

 

//////

 

 

import java.util.*;
class Solution {
    public String solution(String my_string) {
        String[] answer = my_string.split("");
        Set<String> set = new LinkedHashSet<String>(Arrays.asList(answer));

        return String.join("", set);
    }
}

 

728x90

설정

트랙백

댓글

728x90
SMALL

using System;

public class Solution {
    public int solution(int n) {
        int answer = 0;
        int index = 0;
        for(int j=1;j<=n;j++)
        {
            for(int i=1;i<=j;i++)
            {
                if(j%i==0)
                {
                    index++;
                }
            }
            if(index >=3)
            {
                answer++;
            }
            index =0;
        }
            
        return answer;
    }
}

 

/////

 

using System;

public class Solution {
    public int solution(int n) {
        int answer = 0;
        
        if(n<4)
            return 0;
        
        for(int i= 4;i<=n;i++)
        {
            for(int j = 2;j<i;j++)
            {
                if(i%j==0)
                {
                    answer++;
                    break;
                }

            }
        }
        return answer;
    }
}

 

// 1과 자신이 아닌 경우의 약수 하나만 있으면 되니까 이렇게 짜도 된다.

 

파이썬

////

def solution(n):
    output = 0
    for i in range(4, n + 1):
        for j in range(2, int(i ** 0.5) + 1):
            if i % j == 0:
                output += 1
                break
    return output

/////

 

def get_divisors(n):
    return list(filter(lambda v: n % v ==0, range(1, n+1)))

def solution(n):
    return len(list(filter(lambda v: len(get_divisors(v)) >= 3, range(1, n+1))))

 

자바

/////

 

import java.util.stream.IntStream;

class Solution {
    public int solution(int n) {
        return (int) IntStream.rangeClosed(1, n).filter(i -> (int) IntStream.rangeClosed(1, i).filter(i2 -> i % i2 == 0).count() > 2).count();
    }
}

 

//////

 

class Solution {
    public int solution(int n) {
        int answer = 0;

        for (int i = 1; i <= n; i++) 
        {
            int cnt = 0;
            
            for (int j = 1; j <= i; j++) 
            {
                if (i % j == 0) cnt++;
            }
            
            if (cnt >= 3) answer++;
        }

        return answer;
    }
}

 

728x90

설정

트랙백

댓글

728x90
SMALL

using System;
using System.Linq;

public class Solution {
    public string solution(string my_string) {
        
        string answer = my_string.ToLower();
        //소문자로 바꾸기
        char[] chars = answer.ToCharArray();

/// char(문자)로 된 어레이로 만들고 어레이 소팅.
        Array.Sort(chars);
        return new String(chars);    
    }
}

 

////

 

using System;
using System.Linq;

public class Solution {
    public string solution(string my_string) {
        string answer = string.Concat(my_string.ToLower().OrderBy(x => x));

        return answer;
    }
}

 

파이썬

 

def solution(my_string):
    return ''.join(sorted(my_string.lower()))

////

def solution(my_string):
    answer = "".join(sorted(list(my_string.lower())))
    return answer

/////

def solution(my_string):
    answer=[]
    for i in my_string:
        answer.append(i.lower())
    return "".join(sorted(answer))

 

자바

 

import java.util.*;
class Solution {
    public String solution(String my_string) {
        char[] c = my_string.toLowerCase().toCharArray();
        Arrays.sort(c);
        return new String(c);
    }
}

 

////

 

import java.util.*;

class Solution {
    public String solution(String my_string) {
        String answer = "";
        String[] word = my_string.toLowerCase().split("");
        Arrays.sort(word);
        
        for(int i = 0 ; i <word.length ; i++)
        {
            answer += word[i];
        }

        return answer;
    }
}

 

728x90

설정

트랙백

댓글

728x90
SMALL

using System;

public class Solution {
    public int solution(int order) {
        int answer = 0;
        int length = order.ToString().Length;

//order의 string 상의 길이를 추출한다.
        
        for(int i=1;i<=length;i++)
        {
            if(order%10 == 3 || order%10 == 6 || order%10 == 9)
            {
                answer++;
            }
            order = order/10;
        }
        //나머지가 3,6,9인 경우를 추출하여 answer++해준다.
        return answer;
    }
}

 

파이썬

/////

def solution(order):
    answer = 0
    order = str(order)
    return order.count('3') + order.count('6') + order.count('9')

////

def solution(order):
    answer = len([1 for ch in str(order) if ch in "369"])
    return answer

/////

def solution(order):
    return sum(map(lambda x: str(order).count(str(x)), [3, 6, 9]))

 

자바

////

 

class Solution {
    public int solution(int order) {
        int answer = 0;
        int count = 0;
        while(order != 0)
        {
            if(order % 10 == 3 || order % 10 == 6 || order % 10 == 9)
            {
                count++;
            }
             order = order/10;
        }
        answer = count;
        return answer;
    }
}

 

 

728x90

설정

트랙백

댓글

728x90
SMALL

using System;

public class Solution {
    public int solution(int num, int k) {
        
        int answer = num.ToString().IndexOf(k.ToString())+1;
        // string형으로 한 k가 있는 위치를 IndexOf로 반환하게 한다.
        return answer == 0 ? -1 : answer;
    }
}

 

///

파이썬

////

def solution(num, k):
    for i, n in enumerate(str(num)):
        if str(k) == n:
            return i + 1
    return -1

////

def solution(num, k):
    answer = (str(num).find(str(k))+1)
    if answer == 0:
        answer = -1
    return answer

 

자바

/////

class Solution {
    public int solution(int num, int k) {
        String numStr = String.valueOf(num);
        String kStr = String.valueOf(k);

        int answer = numStr.indexOf(kStr);
        return answer < 0 ? -1 : answer + 1 ;
    }
}

 

/////

class Solution {
    public int solution(int num, int k) 
    {
        return ("-" + num).indexOf(String.valueOf(k));
    }
}
728x90

설정

트랙백

댓글

728x90
SMALL

using System;

public class Solution {
    public string solution(string my_string, int num1, int num2) {
        string answer = "";
        char[] arr = my_string.ToCharArray();
        char temp;
        
        temp = arr[num2];
        arr[num2] = arr[num1];
        arr[num1] = temp;
        
        answer = string.Concat(arr);
        return answer;
    }
}

 

파이썬

////

 

def solution(my_string, num1, num2):
    s = list(my_string)
    s[num1],s[num2] = s[num2],s[num1]
    return ''.join(s)

 

자바

 

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

class Solution {
    public String solution(String myString, int num1, int num2) {
        List<String> list = Arrays.stream(myString.split("")).collect(Collectors.toList());

        Collections.swap(list, num1, num2);
        return String.join("", list);
    }
}

 

 

자바

 

 

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

class Solution {
    public String solution(String myString, int num1, int num2) {
        List<String> list = Arrays.stream(myString.split("")).collect(Collectors.toList());

        Collections.swap(list, num1, num2);
        return String.join("", list);
    }
}

 

 

class Solution {
    public String solution(String my_string, int num1, int num2) {
        String answer = "";

        char[] ch = my_string.toCharArray();

        ch[num1] = my_string.charAt(num2);
        ch[num2] = my_string.charAt(num1);

        answer = String.valueOf(ch);
        return answer;
    }
}
728x90

설정

트랙백

댓글

728x90
SMALL

using System;

public class Solution {
    public int solution(int n) {
        int answer = 0;
        //n과 6의 최소공배수를 찾아서 6으로 나누면 된다.
        for(int i=1;i<=n;i++)
        {
            if(n%i==0 && 6%i==0)
            {
                answer = i;
            }
        }
        answer = n*6/answer;
        return answer/6; //피자의 판 수를 구하니까 6으로 나눈다.
    }
}

 

파이썬

 

import math

def solution(n):
    return (n * 6) // math.gcd(n, 6) // 6

 

def solution(n):
    answer = 1
    while 6 * answer % n:
        answer += 1
    return answer

 

자바

//////

class Solution {
    public int solution(int n) {
        int answer = 1;

        while(true)
        {
            if(6*answer%n==0) 
              break;
            answer++;
        }

        return answer;
    }
}
728x90

설정

트랙백

댓글