SQL/MySQL

[MySQL/HackerRank] Draw The Triangle 1

NLP Developer 2023. 8. 29. 13:50
728x90
반응형

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

 

Draw The Triangle 1 | 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).

Code

SET @NUMBER = 21;
SELECT REPEAT('* ',@NUMBER := @NUMBER - 1)
FROM INFORMATION_SCHEMA.TABLES
LIMIT 20;

 

728x90
반응형