7 kyu

Complete The Pattern #2

2,309 of 7,400DivyanshBatham

Description:

Task:

You have to write a function pattern which returns the following Pattern (See Pattern & Examples) upto n number of rows.

  • Note: Returning the pattern is not the same as Printing the pattern.

Rules/Note:

  • If n < 1 then it should return "" i.e. empty string.
  • There are no whitespaces in the pattern.

Pattern:

(n)(n-1)(n-2)...4321
(n)(n-1)(n-2)...432
(n)(n-1)(n-2)...43
(n)(n-1)(n-2)...4
...............
..............
(n)(n-1)(n-2)
(n)(n-1)
(n)

Examples:

  • pattern(4):

    4321
    432
    43
    4
    
  • pattern(11):

    1110987654321
    111098765432
    11109876543
    1110987654
    111098765
    11109876
    1110987
    111098
    11109
    1110
    11
    
  • Hint: Use \n in string to jump to next line

List of all my katas

ASCII Art
Puzzles

Stats:

CreatedJun 6, 2015
PublishedJun 6, 2015
Warriors Trained15216
Total Skips1429
Total Code Submissions33101
Total Times Completed7400
JavaScript Completions2309
Ruby Completions496
Python Completions2285
C# Completions1076
Haskell Completions201
Java Completions1744
C++ Completions613
CFML Completions9
Julia Completions14
Total Stars145
% of votes with a positive feedback rating90% of 876
Total "Very Satisfied" Votes719
Total "Somewhat Satisfied" Votes132
Total "Not Satisfied" Votes25
Ad
Contributors
  • DivyanshBatham Avatar
  • dnolan Avatar
  • Azuaron Avatar
  • parabola949 Avatar
  • Beast Avatar
  • Unnamed Avatar
  • GiacomoSorbi Avatar
  • sharifahmad Avatar
  • Voile Avatar
  • bdw429s Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • solitude Avatar
  • saudiGuy Avatar
Ad