Skip to content

Comments

[BE] ์ด์ฃผ์•  ๐Ÿ‘ฅ ์˜ค๋Š˜์˜ ์ง๊ฟ์€?#7

Open
leejuae wants to merge 2 commits intoLeets-Official:mainfrom
Leets3:main
Open

[BE] ์ด์ฃผ์•  ๐Ÿ‘ฅ ์˜ค๋Š˜์˜ ์ง๊ฟ์€?#7
leejuae wants to merge 2 commits intoLeets-Official:mainfrom
Leets3:main

Conversation

@leejuae
Copy link
Member

@leejuae leejuae commented Apr 10, 2024

๋ฏธ์…˜ ์‹คํ–‰ ๊ฒฐ๊ณผ

image

๊ธฐ๋Šฅ ๋ช…์„ธ์„œ

๊ธฐ๋Šฅ

์ฐธ์—ฌ์ž์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•  ์‹œ, ํŒ€์ด ๋žœ๋ค๋ฐฐ์ •๋จ.
๋‹ค์‹œ ๋žœ๋ค์œผ๋กœ ์ž…๋ ฅ์„ ๋ฐ›๊ธฐ ์›ํ•˜๋ฉด, y๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ธ์›์ด ์žฌ๋ฐฐ์—ด๋จ.
n์„ ์ž…๋ ฅ ์‹œ์— ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ

ERROR SATUS

์ฐธ์—ฌ์ž ์ด๋ฆ„ ์ž…๋ ฅ ์‹œ ์˜์–ด๊ฐ€ ์ž…๋ ฅ๋˜๋ฉด ์˜ค๋ฅ˜ ๋ฐœ์ƒ
์ตœ๋Œ€ ์ง์ˆ˜๊ฐ€ ์ž…๋ ฅ๋œ ์ธ์›๋ณด๋‹ค ๋งŽ์„ ์‹œ ์˜ค๋ฅ˜๋ฐœ์ƒ
y/n ์ด์™ธ์˜ ๋ฌธ์ž๊ฐ€ ์ž…๋ ฅ ์‹œ ์˜ค๋ฅ˜ ๋ฐœ์ƒ

@leejuae leejuae self-assigned this Apr 10, 2024
Copy link
Member

@taeseokyang taeseokyang left a comment

Choose a reason for hiding this comment

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

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค!!

ํ…์ŠคํŠธ ํ”„๋ฆฐํŠธ๋„ ๊ตฌํ˜„ ํ•ด์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

public void run() {
Scanner sc = new Scanner(System.in);
String members = sc.nextLine();
int ret = 1;
Copy link
Member

Choose a reason for hiding this comment

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

๋”ฑ ๋ณด๊ณ  ์˜๋ฏธ๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋„๋ก ๋ณ€์ˆ˜๋ช…์„ ์ ์–ด์ฃผ์‹œ๋ฉด ์ข‹์„๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!

}

// ๋ฌธ์ž์—ด๋กœ๋œ ๋ฉค๋ฒ„๋“ค์„ ๋ฆฌ์ŠคํŠธ๋กœ ๋ถ„๋ฆฌํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
public List<String> parseMembers(String members) {
Copy link
Member

Choose a reason for hiding this comment

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

return Arrays.asList(members.split(","));
์œ„ ์™€ ๊ฐ™์ด ์ž‘์„ฑํ•˜์‹œ๋ฉด ์‰ฝ๊ฒŒ ๋ถ„๋ฆฌ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

ChatGPT๋ฅผ ์ด์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ๋ถ™์—ฌ ๋„ฃ๊ณ  "๋” ์ข‹์€ ๋ฐฉ๋ฒ•์ด ์žˆ์„๊นŒ? ๋ฆฌํŒฉํ† ๋งํ•ด์ค˜' ์™€ ๊ฐ™์ด ์งˆ๋ฌธํ•˜์‹œ๋ฉด ์ข‹์€ ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

Copy link
Member Author

Choose a reason for hiding this comment

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

๊ทธ๋ ‡๊ฒŒ๋„ ์ง€ํ”ผํ‹ฐ๋ฅผ ์‚ฌ์šฉํ•ด๋ณผ ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”!! ์ฐธ๊ณ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค ใ…Žใ…Ž

printResult(generateRandomGroups(memArray, maximumGroupSize));

System.out.print("๋‹ค์‹œ ๊ตฌ์„ฑํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? (y or n): ");
String re = sc.nextLine();
Copy link
Member

Choose a reason for hiding this comment

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

์‰ฝ๊ฒŒ ์ดํ•ด ํ•  ์ˆ˜ ์žˆ๋Š” ๋ณ€์ˆ˜๋ช… ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

}

// ๋‹ค์‹œ ์ถ”์ฒจ์„ ์ง„ํ–‰ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
public int reGeneration(String re) {
Copy link
Member

Choose a reason for hiding this comment

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

ํ•จ์ˆ˜๋ช…์ด ํ•จ์ˆ˜์˜ ๊ธฐ๋Šฅ์„ ์ž˜ ์„ค๋ช…ํ•ด์ฃผ์ง€ ์•Š๋Š”๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

getRetryDecision() ๊ฐ™์€๊ฑด ์–ด๋–จ๊นŒ์š”?
'๋‹ค์‹œ ์ถ”์ฒจํ• ์ง€ ๋ง์ง€ ์ž…๋ ฅ ๋ฐ›๋Š” ํ•จ์ˆ˜ ์ด๋ฆ„ ๋ญ๋ผ๊ณ  ํ• ๊นŒ?' ๋ผ๊ณ  GPT์—๊ฒŒ ๋ฌผ์–ด๋ณธ ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค!

Copy link
Member

@ay-eonii ay-eonii left a comment

Choose a reason for hiding this comment

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

์ฒซ ๋ฏธ์…˜ ๊ณ ์ƒํ•˜์…จ์–ด์š”!

๋ฏธ์…˜ ์˜ˆ์‹œ์™€ ๋งค์šฐ ์œ ์‚ฌํ•˜๊ฒŒ ๊ตฌํ˜„ํ•ด์ฃผ์…จ๋„ค์š”๐Ÿ‘

int memberCount = memberNumber(memArray);
// ์ด๋ฆ„ ๊ฐœ์ˆ˜๋ณด๋‹ค ์ง ์ˆ˜๊ฐ€ ๋” ๋งŽ์œผ๋ฉด ์˜ˆ์™ธ๋ฐœ์ƒ
int maximumGroupSize = Integer.parseInt(sc.nextLine());
checkDataValidity(memberCount, maximumGroupSize);
Copy link
Member

Choose a reason for hiding this comment

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

ํ•˜๋‚˜์˜ ๋ฉ”์„œ๋“œ์— ์ ์ ˆํ•˜๊ฒŒ ์ฑ…์ž„์„ ๋ถ„๋ฆฌํ–ˆ๋„ค์š” ๐Ÿ‘


while (ret == 1){
// ๋žœ๋ค ์ง๊ถ ์ถ”์ฒœ
printResult(generateRandomGroups(memArray, maximumGroupSize));
Copy link
Member

Choose a reason for hiding this comment

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

ํ•ต์‹ฌ ๋กœ์ง์ด ์ˆจ์–ด์žˆ์–ด์š”~ ๐Ÿ˜ถโ€๐ŸŒซ๏ธ

Collections.shuffle(memberList);
List<List<String>> groups = new ArrayList<>();
for (int i = 0; i < memberList.size(); i += maximumGroupSize) {
groups.add(new ArrayList<>(memberList.subList(i, Math.min(i + maximumGroupSize, memberList.size()))));
Copy link
Member

Choose a reason for hiding this comment

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

๋‹ค๋ฅธ ์‚ฌ๋žŒ์ด ์‰ฝ๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก inline์œผ๋กœ ์‚ฌ์šฉํ•œ ๋กœ์ง์„ ์ง€์—ญ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด ๋ถ„๋ฆฌํ•ด๋ณด๋Š” ๊ฑด ์–ด๋–จ๊นŒ์š”?

Comment on lines +91 to +100
for (List<String> group : result) {
System.out.print("[ ");
for (int i = 0; i < group.size(); i++) {
System.out.print(group.get(i));
if (i < group.size() - 1) {
System.out.print(" | ");
}
}
System.out.println(" ]");
}
Copy link
Member

Choose a reason for hiding this comment

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

StringJoiner ๋˜๋Š” String.join()์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋ฉด ๋„์›€์ด ๋  ๊ฒƒ ๊ฐ™์•„์š” ๐Ÿ˜†


// ๋‹ค์‹œ ์ถ”์ฒจ์„ ์ง„ํ–‰ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
public int reGeneration(String re) {
if(Objects.equals(re, "n")) {
Copy link
Member

Choose a reason for hiding this comment

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

String์˜ equals๊ฐ€ ์•„๋‹ˆ๋ผ Objects์˜ equals๋ฅผ ์‚ฌ์šฉํ•œ ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ด์š”!

Copy link
Member Author

Choose a reason for hiding this comment

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

ํ•ด๋‹น๋ถ€๋ถ„ ์ œ๊ฐ€ String ํด๋ž˜์Šค์— ๋Œ€ํ•œ ์ดํ•ด๋„๊ฐ€ ๋ถ€์กฑํ•ด์„œ ๊ทธ๋žฌ๋˜๊ฑฐ ๊ฐ™์•„์š”!! String.equals(re, "n")์ด ๋งž๋Š” ๋ฌธ๋ฒ•์ด๋ผ ์ƒ๊ฐํ–ˆ๋Š”๋ฐ ๋‹ค์‹œ ์ฐพ์•„๋ณด๋‹ˆ re.equals("n")๋กœ ์ฒ˜๋ฆฌ๋ฅผ ํ–ˆ์–ด์•ผ ํ–ˆ๋„ค์š”..ใ…Žใ…Ž ๊ทธ๋ƒฅ ๋„˜์–ด๊ฐˆ๋ป” ํ–ˆ๋˜ ๋ถ€๋ถ„์ธ๋ฐ ๋•๋ถ„์— ๋‹ค์‹œ ์งš๊ณ  ๋„˜์–ด๊ฐˆ ์ˆ˜ ์žˆ์—ˆ์–ด์š”!

Copy link
Member

Choose a reason for hiding this comment

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

Object.equals()๋Š” ์ฃผ์†Œ๊ฐ’์„ ๋น„๊ตํ•˜๋Š”๋ฐ, String.equals()๋Š” ๋ฌธ์ž ํ•˜๋‚˜ํ•˜๋‚˜๋ฅผ ๋น„๊ตํ•ด์š”! ๊ฐ™์€ "n" ์ด๋”๋ผ๋„ Object.equals()๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด false๊ฐ€ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ๋Š”๊ฑฐ์ฃ ! ์ด๋Ÿฐ ๋ฌธ์ œ๊ฐ€ ์žˆ์–ด ๋ฌธ์ž์—ด์„ ๋น„๊ตํ• ๋•Œ๋Š” String.equals()๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ์ข‹์•„์š”!

์ถ”๊ฐ€์ ์œผ๋กœ, re.equals("n")์˜ ๊ฒฝ์šฐ re๊ฐ€ null์ด๋ผ๋ฉด ๋ฌธ์ œ๊ฐ€ ์žˆ์„ ๊ฑฐ ๊ฐ™์€๋ฐ์š”๐Ÿค”

Comment on lines 108 to 110
return 0;
} else if (Objects.equals(re, "y")) {
return 1;
Copy link
Member

Choose a reason for hiding this comment

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

0 ๋˜๋Š” 1์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋“ฏํ•œ๋ฐ boolean์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์€ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?

Copy link
Member Author

Choose a reason for hiding this comment

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

๊ทธ๋ ‡๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋Š”๊ฒƒ๋„ ์ข‹์„๊ฑฐ ๊ฐ™๋„ค์š”! bool ๋ฆฌํ„ด๋ณด๋‹จ 0,1 ๋ฆฌํ„ด์ด ์ข€ ๋” ์ต์ˆ™ํ•ด์„œ ์ด๋ ‡๊ฒŒ ์ฒ˜๋ฆฌํ–ˆ๋˜๊ฑฐ ๊ฐ™์•„์š” ใ…Žใ…Ž

@leejuae leejuae changed the title [BE] {์ด์ฃผ์• } {leets-mate-java-1} [BE] ์ด์ฃผ์•  ๐Ÿ‘ฅ ์˜ค๋Š˜์˜ ์ง๊ฟ์€? Apr 11, 2024
// ๋™์ž‘ ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
public void run() {
Scanner input = new Scanner(System.in); // Scanner ํด๋ž˜์Šค ์ƒ์„ฑ
int ret = 1; // loop ๋Œ๋ฆฌ๊ธฐ ์œ„ํ•œ ๋ณ€์ˆ˜ ์„ค์ •
Copy link
Member

Choose a reason for hiding this comment

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

boolean ํƒ€์ž…์œผ๋กœ ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•ด์ฃผ๋ฉด ์ข‹์•˜์„ ๊ฒƒ ๊ฐ™์•„์š”!

while(st.hasMoreTokens())
memArray.add(st.nextToken());

return memArray;
Copy link
Member

Choose a reason for hiding this comment

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

StringTokenizer๋„ ์ข‹์ง€๋งŒ, split()๋ฉ”์„œ๋“œ๋„ ํ˜„์žฌ ๋กœ์ง์—์„œ ์ƒ๋‹นํžˆ ๊ดœ์ฐฎ์•„ ๋ณด์ž…๋‹ˆ๋‹ค!


// ๋ฉค๋ฒ„ ๋ฌธ์ž์—ด์— ์˜์–ด๊ฐ€ ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์˜์–ด๊ฐ€ ์žˆ๋‹ค๋ฉด ์˜ˆ์™ธ ์ถœ๋ ฅ
public void checkHasNoEnglish(String members) {
if (!members.matches("[๊ฐ€-ํžฃ,]+")) {
Copy link
Member

Choose a reason for hiding this comment

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

๋ฉ”์„œ๋“œ๋ช…๊ณผ ๋ฉ”์„œ๋“œ๊ฐ€ ํ•˜๋Š” ํ–‰์œ„๊ฐ€ ์ผ์น˜ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants