[hackerrank] 삼각형 그리기

2innnnn0·2022년 4월 18일

https://www.hackerrank.com/challenges/draw-the-triangle-1/problem?isFullScreen=true

(1)

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 @number = 21;
SELECT repeat('* ', @number := @number - 1) 
FROM information_schema.tables

(2)

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).
/*
Enter your query here.
*/

set @number = 0;
SELECT repeat('* ', @number := @number + 1) 
FROM information_schema.tables
WHERE @number < 20
profile
8년차 데이터분석가, 지금은 AI 자동화를 가르치고 만듭니다 · 데이터팝콘 대표

0개의 댓글