Gift Wrap

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

We almost overlooked one thing — Princess Asseylum needs to give her guests gifts! You have to help her wrap the gifts now! A wrapped gift can be represented as an M \times M square matrix of lowercase letters. The very center of the gift should be a, and each other layer from inside out should have b, c, etc.

Input Specification

The first and only line of input will have the number of layers of the gift, N\ (1 \le N \le 26).

Output Specification

You should output an M \times M matrix, the gift after it is wrapped.

Sample Input 1

2

Sample Output 1

bbb
bab
bbb

Sample Input 2

3

Sample Output 2

ccccc
cbbbc
cbabc
cbbbc
ccccc

Comments


  • -1
    BMP  commented on Jan. 1, 2015, 4:46 p.m.

    So the letters increase with alphabetical order?


  • 0
    kobortor  commented on Jan. 1, 2015, 12:32 p.m.

    What do we do if N is even?

    Not sure if we do this:

    cccc cabc cccc

    ^looks ugly


    • 0
      kobortor  commented on Jan. 1, 2015, 12:33 p.m.

      my formatting screwed up

      cccc

      cabc

      cccc


      • 0
        FatalEagle  commented on Jan. 1, 2015, 12:41 p.m. edited

        Added as a sample case.

        Input

        2

        Output

        bbb
        bab
        bbb

        • 0
          kobortor  commented on Jan. 1, 2015, 12:52 p.m.

          Oh never mind I thought N was the diameter