๐ข ๋ณธ ํฌ์คํ ์ ํ์ฉ๋๋ ๊ธฐ๋ณธ ๋ฌธ์ ๋ฐ ์๋ฃ ์ถ์ฒ๋ HackerRank ์์ ๋ฐํ๋๋ค.
https://www.hackerrank.com
โ ๋ฌธ์
https://www.hackerrank.com/challenges/draw-the-triangle-2/problem?isFullScreen=true
Draw The Triangle 2 | HackerRank
Draw the triangle pattern using asterisks.
www.hackerrank.com
P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5):
*
* *
* * *
* * * *
* * * * *
Write a query to print the pattern P(20).
โ ํ์ด
SET @NUM = 0;
SELECT REPEAT('* ', @NUM := @NUM +1)
FROM information_schema.tables
WHERE @NUM <= 19;
Draw Triangle 1์์ ํ์ฉํ๋ REPEAT ํจ์์ Information_schema DB๋ฅผ ํ์ฉํด์ ํ์๋ค.
์ฃผ์ํ ์ ์ ์กฐ๊ฑด์ ์ @NUM์ SELECT์ ์์ 1์ด ๋ํด์ง๋๊ฑธ ์๊ฐํด์ ํจํด 20๊ฐ๊น์ง *์ ์ฐ์ผ๋ ค๋ฉด @NUM์ 19๊น์ง๋ก ์ ํ์์ผ์ค์ผ ํ๋ ๊ฒ.
'Growth ๐ณ > Practice ๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Hacker Rank] SQL Project Planning (0) | 2022.09.20 |
---|---|
[Hacker Rank] Occupations (0) | 2022.09.20 |
[Hacker Rank] Draw The Triangle 1 (0) | 2022.09.13 |
[๊ณผ์ ] Pythob2022 #03 ์ฐ์ต๋ฌธ์ (0) | 2022.08.27 |
[Hacker Rank] Placement (0) | 2022.08.27 |