-
Notifications
You must be signed in to change notification settings - Fork 0
홍세영 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Hongse0
wants to merge
8
commits into
main
Choose a base branch
from
Hongse0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
홍세영 #3
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a2c027a
짝수와 홀수
Hongse0 6a6cfa9
자릿수 더하기
Hongse0 0f083e6
문자열 내 p와 y의 개수
Hongse0 95a9938
나머지가 1이 되는 수 찾기
Hongse0 3dcf628
문자열 다루기 기본
Hongse0 bc798ff
하샤드 수
Hongse0 9b7829f
서울에서 김서방 찾기
Hongse0 78c971d
콜라츠 추측
Hongse0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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개수 세고 리턴해준다 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 없음"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringBuilder를 사용하셨군요 👍