CPTTRN5 - Character Patterns (Act 5)

Using two characters: . (dot) and * (asterisk) print a grid-like pattern. The grid will have l lines, c columns, and each square shaped element of the grid will have the height and width equal to s.

Moreover, each of the grid elements will have a diagonal. The diagonal of the first square in the first line of the grid is directed towards down and right corner - use the \ (backslash) character to print it; while the next diagonal will be directed towards upper right corner - use the / (slash) character to print it. Print the successive diagonals alternately (please consult the example below).

Input

You are given t - the number of test cases and for each of the test case three positive integers: l - the number of lines, c - the number of columns in the grid and s - the size of the single square shaped element.

Output

For each of the test cases output the requested pattern (please have a look at the example). Use one line break in between successive patterns.

Example

Input:
3
3 1 2
4 4 1
2 5 2

Output:
****
*\.*
*.\*
****
*./*
*/.*
****
*\.*
*.\*
****

*********
*\*/*\*/*
*********
*/*\*/*\*
*********
*\*/*\*/*
*********
*/*\*/*\*
*********

****************
*\.*./*\.*./*\.*
*.\*/.*.\*/.*.\*
****************
*./*\.*./*\.*./*
*/.*.\*/.*.\*/.*
****************

Added by:kuszi
Date:2012-09-04
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2017-09-02 09:25:36
That was hard for me!!!
2017-08-27 13:13:56
(i+j)%((s+1)*2)==0 for /
2017-01-15 12:02:20
This was a very tricky question.But here is the catch:
(i==j || ((i-j)%(s+1)==0 && ((i-j)/(s+1)%2==0))) for \ &
(i+j)%(s+1)==0 && ((i+j)/(s+1)%2==0) for /.
2016-10-11 02:52:14 Lara
Using python3 and getting runtime error. Not sure why, it works on my computer and on ideone. Any ideas?
2016-09-25 20:13:47
thanks sirmokona, 0 == (k-j) % (2*s[i]+2) this is for slash
2016-09-14 17:06:38
again, my solution works both on my pc and on ideone, but it is giving a runtime error here on spoj.
2016-08-04 17:14:58
(i%s==0||j%s==0)?"*":(i / s + j / s) % 2 == 0 ?((i % s == j % s) ? "\\" : "."):(i % s == s - (j % s)) ? "/" : "."
i'am literally one liner
2016-06-19 09:14:08
Hint guys:
1. First eliminate asterisks. Know where to print them and where others would go.
2. Then think about dots.
3. Then differentiate between slashes.
2016-05-22 21:35:00
I couldn't get the 2nd output :/ very tough!
2016-04-29 20:08:11 Dennis Slater
Accepted in C# in 0.02 secs. The directions and examples were very misleading to me. Read them carefully. The squares can be any size from 1 to whatever.

This is a 5 x 5 square. There are two different types of squares.

*******
*\xxxx*
*x\xxx*
*xx\xx*
*xxx\x*
*xxxx\*
*******

where x's = .'s Use @"/" to create printline.

Last edit: 2016-04-29 20:13:06
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.