Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/main/java/org/example/Collatz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.example;

public class Collatz {
public int solution(long num) {
int cnt =1;
if(num == 1){
return 0;
}
while(cnt<=500){
if(num%2==0){
num /=2;
}else{
num *= 3;
num += 1;
}
if(num ==1){
return cnt;
}
cnt ++;
}

return -1;
}
}
13 changes: 13 additions & 0 deletions src/main/java/org/example/sol2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.example;

public class sol2 {
public int solution(int n) {
int answer = 0;
while(n>0){
answer += (n%10);
n /= 10;
}

return answer;
}
}
23 changes: 23 additions & 0 deletions src/main/java/org/example/sol3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.example;

public class sol3 {
boolean solution(String s) {
int pcnt =0;
int ycnt =0;
String small = s.toLowerCase();
for(char c: small.toCharArray()){
if(c=='p'){
pcnt++;
}else if(c=='y'){
ycnt++;
}
}
if(pcnt==ycnt){
return true;
}else{
return false;
}
}
}

// s문자열 다 소문자로 바꾸고 foreach로 p와 y개수 세고 리턴해준다
14 changes: 14 additions & 0 deletions src/main/java/org/example/sol4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.example;

public class sol4 {
public int solution(int n) {
int answer = 0;
for(int i =1; i<n; i++){
if(n%i==1){
answer = i;
break;
}
}
return answer;
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/example/sol5.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.example;

public class sol5 {
public boolean solution(String s) {
boolean answer = true;
if(s.length()==4||s.length()==6){
for(char c: s.toCharArray()){
if((int)c>=97&&(int)c<=122 || (int)c>=65 && (int)c<=90){
answer = false;
}
}
}else{
answer =false;
}
return answer;
}
}
20 changes: 20 additions & 0 deletions src/main/java/org/example/sol6.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.example;

public class sol6 {
public boolean solution(int x) {
int n = x;
int j =10;
int sum = 0;
while(n >0){
int i=0;
i = n%j;
n /=j;
sum += i;
}
if(x % sum ==0){
return true;
}else{
return false;
}
}
}
14 changes: 14 additions & 0 deletions src/main/java/org/example/sol7.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.example;

public class sol7 {
public String solution(String[] seoul) {
String location;
for(int i=0; i<seoul.length; i++){
if(seoul[i].equals("Kim")){
location = Integer.toString(i);
return "김서방은 "+location+"에 있다";
}
}
return "kim 없음";
}
}
17 changes: 10 additions & 7 deletions src/main/java/org/example/solution1.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package org.example;

public class solution1 {
public double solution(int[] arr) {
double answer = 0;
double tot =0;
for(int i: arr){
tot += i;
public String solution(int num) {

StringBuilder sb = new StringBuilder();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringBuilder를 사용하셨군요 👍

if(num%2 ==0){
sb.append("Even");
}else{
sb.append("Odd");
}
answer = tot/(arr.length);
return answer;
return sb.toString();
}
}

// 스트링 빌더를 만들어서 num을 2로 나누었을 때 짝수라면 even추가 홀수라면 odd를 스트링 빌더에 추가함.


// 주석에 쓸 내용 : 자신이 이 문제를 어떻게 풀었는지 쓰기, 어려워서 못 풀었으면 어떤 부분이 어려웠는지 남기기.
// solution1에 첫문제 풀고 다음날 부터 솔루션2,3,4.. 클래스 만들어서 풀고 커밋하기
Expand Down