Skip to content

Conversation

@chanani
Copy link

@chanani chanani commented Dec 25, 2025

์•ˆ๋…•ํ•˜์„ธ์š” ! 2๋‹จ๊ณ„ - ์‚ฌ๋‹ค๋ฆฌ(์ƒ์„ฑ) ๋ฆฌ๋ทฐ ์š”์ฒญ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ๐Ÿ™‡โ€โ™‚๏ธ

๊ณผ์ œ ์ง„ํ–‰ ๋‚ด์šฉ ์ •๋ฆฌ

  • ์ตœ๋Œ€ํ•œ ์ŠคํŠธ๋ฆผ์„ ์‚ฌ์šฉํ•˜๋ ค๊ณ ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์‚ฌ๋‹ค๋ฆฌ ์ƒ์„ฑ ๋ฉ”์„œ๋“œ์˜ ๋ณต์žก๋„๊ฐ€ ๋†’์•„ ์ŠคํŠธ๋ฆผ์œผ๋กœ ๋ณ€๊ฒฝํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๋žŒ๋‹ค๋ฅผ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„์„ ์•„์ง ์ฐพ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ ๋ณ€๊ฒฝ ์ „ ์šฐ์„  ๋ฆฌ๋ทฐ ์š”์ฒญ ๋“œ๋ฆฌ๋ ค๊ณ ํ•ฉ๋‹ˆ๋‹ค.
  • ์‚ฌ๋‹ค๋ฆฌ ์ •๋ณด๋ฅผ Lassers ๊ฐ์ฒด์—์„œ TreeMap์œผ๋กœ ๊ด€๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. Map์œผ๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ๊ณผ Ladder๊ฐ์ฒด์™€ ๊ฒฐ๊ณผ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๊ฐ์ฒด๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ ์ค‘ ์–ด๋–ค๊ฒŒ ํšจ์œจ์ ์ผ์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค !

Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

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

2๋‹จ๊ณ„ ๋ฏธ์…˜ ์ง„ํ–‰ํ•˜๋А๋ผ ์ˆ˜๊ณ ํ–ˆ์–ด์š”. ๐Ÿ‘
์š”๊ตฌ์‚ฌํ•ญ์˜ ๋ณต์žก๋„๊ฐ€ ๋†’์ง€ ์•Š์•„ ๋ฐ”๋กœ mergeํ•˜๋ ค๋‹ค ์ƒˆ๋กœ์šด ๊ฐ์ฒด๋ฅผ ๋„์ถœํ–ˆ์œผ๋ฉด ํ•˜๋Š” ํ”ผ๋“œ๋ฐฑ์ด ์žˆ์–ด ํ”ผ๋“œ๋ฐฑ ๋ฐ˜์˜ ํ›„ 3๋‹จ๊ณ„ ์ง„ํ–‰ํ•˜๋ฉด ์ข‹๊ฒ ๋„ค์š”.


import java.util.Objects;

public class Height {
Copy link
Contributor

Choose a reason for hiding this comment

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

๐Ÿ‘

private final Position row;
private final Position column;

public Ladder(int row, int column) {
Copy link
Contributor

Choose a reason for hiding this comment

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

๋ถ€์ƒ์„ฑ์ž ๐Ÿ‘

@@ -0,0 +1,41 @@
package nextstep.ladder.domain.ladder;

public class Ladder implements Comparable<Ladder> {
Copy link
Contributor

Choose a reason for hiding this comment

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

๊ฐ์ฒด ์ด๋ฆ„์ด Ladder์ด๋‹ค๋ณด๋‹ˆ ์‚ฌ๋‹ค๋ฆฌ ์ „์ฒด๋กœ ์ธ์‹ํ•  ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ์–ด ๋ณด์ž„
ํŠน์ • ์ง€์ ์„ ์˜๋ฏธํ•˜๋Š” ๊ฒƒ์œผ๋กœ Point์™€ ๊ฐ™์€ ์ด๋ฆ„์€ ์–ด๋–จ๊นŒ?
AI๋ฅผ ํ†ตํ•ด ํ”ผ๋“œ๋ฐฑ ๋ฐ›์•„๋ณธ ํ›„ ๋ฆฌํŒฉํ„ฐ๋งํ•ด๋ณธ๋‹ค.


private static final Random RANDOM = new Random();

public static TreeMap<Ladder, Boolean> createLadders(int width, int height) {
Copy link
Contributor

Choose a reason for hiding this comment

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

2์ค‘ for๋ฌธ์œผ๋กœ ๊ตฌํ˜„ํ•˜๊ธฐ ๋ณด๋‹ค Line๊ณผ ๊ฐ™์€ ์ƒˆ๋กœ์šด ๊ฐ์ฒด๋ฅผ ์ถ”๊ฐ€ํ•ด 2์ค‘ for๋ฌธ์„ ์ œ๊ฑฐํ•ด ๋ณด๋ฉด ์–ด๋–จ๊นŒ?

private static final Random RANDOM = new Random();

public static TreeMap<Ladder, Boolean> createLadders(int width, int height) {
TreeMap<Ladder, Boolean> map = new TreeMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

๋ณดํ†ต Map์˜ ๊ตฌํ˜„์ฒด๋กœ HashMap์„ ์‚ฌ์šฉํ•˜๋Š”๋ฐ TreeMap์„ ์“ด ์ด์œ ๋Š”?
์ด ๋กœ์ง์— HashMap๊ณผ TreeMap ์ค‘ ์–ด๋А ๊ตฌํ˜„์ฒด๊ฐ€ ์ ํ•ฉํ•œ์ง€๋ฅผ AI๋ฅผ ํ†ตํ•ด ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ›์•„๋ณด๊ณ  ์ ์šฉํ•ด ๋ณธ๋‹ค.
์ด๋Ÿฐ ๋ถ€๋ถ„์˜ ๊ถ๊ธˆ์ฆ์„ AI ๋„์›€์„ ๋ฐ›์•„ ํ•ด์†Œํ•˜๋Š” ๊ฒฝํ—˜์„ ์ด์–ด๊ฐˆ ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค.

Copy link
Author

Choose a reason for hiding this comment

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

HashMap์ด ์•„๋‹Œ TreeMap์„ ์‚ฌ์šฉํ•œ ์ด์œ ๋Š” ์ฝ˜์†”์— ์‚ฌ๋‹ค๋ฆฌ๋ฅผ ์ถœ๋ ฅํ•˜๊ธฐ ์œ„ํ•ด ์ˆœ์„œ๋ฅผ ๋ณด์žฅํ•˜๋ฉด์„œ ๊ด€๋ฆฌ๋˜๋ฉด ์ข‹๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐ๋˜์—ˆ๊ณ , HashMap์„ ์‚ฌ์šฉํ–ˆ์„ ๊ฒฝ์šฐ ์ฝ˜์†”์— ์ถœ๋ ฅ ์ „ ์ •๋ ฌ์„ ์ง„ํ–‰ํ•œ ๋’ค ์ถœ๋ ฅํ•ด์•ผ ๋œ๋‹ค๊ณ  ํŒ๋‹จ๋˜์–ด TreeMap์„ ์„ ํƒํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

AI์—๊ฒŒ ์งˆ๋ฌธํ•˜๋‹ˆ HashMap์ด ๊ฒฐ๊ณผ์ ์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ ํšจ์œจ์„ฑ ์ธก๋ฉด์—์„œ ๋” ์ข‹๋‹ค๋Š” ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์™”์Šต๋‹ˆ๋‹ค.

@chanani
Copy link
Author

chanani commented Dec 27, 2025

๋‚จ๊ฒจ์ฃผ์‹  ํ”ผ๋“œ๋ฐฑ์„ ์ˆ˜์ •ํ•˜๋˜ ์ค‘ ๋” ํšจ์œจ์ ์ธ ๋กœ์ง์„ ์ƒ๊ฐํ•ด ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
์ตœ์ดˆ Map์„ ํ†ตํ•ด key์—๋Š” ์ขŒํ‘œ, value์—๋Š” ๊ฒฐ๊ณผ ๊ฐ’์„ ์ €์žฅํ•˜์˜€๋Š”๋ฐ, Line ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๋‹ˆ ์‚ฌ๋‹ค๋ฆฌ์˜ ๊ฐ Line์— ๊ฒฐ๊ณผ ๊ฐ’๋งŒ ๊ด€๋ฆฌํ•ด๋„ ์ถฉ๋ถ„ํ•  ๊ฒƒ ๊ฐ™๋‹ค๊ณ  ํŒ๋‹จ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

  • ์‚ฌ๋‹ค๋ฆฌ ์ œ์ž‘ ์‹œ ๋žœ๋ค์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” ๊ฒฐ๊ณผ๊ฐ’์„ Interface๋กœ ๋ถ„๋ฆฌํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • ์ฝ˜์†”์— ๊ฒฐ๊ณผ๊ฐ’ ์ถœ๋ ฅ ๋กœ์ง ์ œ์ž‘ ์‹œ ์ตœ๋Œ€ํ•œ ํ•œ ๋ฉ”์„œ๋“œ์—์„œ๋Š” ํ•œ๊ฐœ์˜ ์—ญํ• ๋งŒ ํ•  ์ˆ˜ ์žˆ๋„๋ก ์—ญํ• ์„ ๋ถ„๋ฆฌํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • for๋ฌธ๋ณด๋‹ค๋Š” Stream์œผ๋กœ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

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

ํ”ผ๋“œ๋ฐฑ ๋ฐ˜์˜ ๐Ÿ‘
์ด๋ฒˆ ๋ฏธ์…˜์˜ ๋ฉ”์ธ์ด 3๋‹จ๊ณ„์ธ๋งŒํผ 3๋‹จ๊ณ„ ๋ฏธ์…˜ ๋„์ „ํ•ด ๋ณด์‹œ์ฃ .

@javajigi javajigi merged commit 349912a into next-step:chanani Dec 28, 2025
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.

2 participants