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: **** *\.* *.\* **** *./* */.* **** *\.* *.\* **** ********* *\*/*\*/* ********* */*\*/*\* ********* *\*/*\*/* ********* */*\*/*\* ********* **************** *\.*./*\.*./*\.* *.\*/.*.\*/.*.\* **************** *./*\.*./*\.*./* */.*.\*/.*.\*/.* ****************
hide comments
|
rushikeshkoli:
2017-09-02 09:25:36
That was hard for me!!! |
|
radvein:
2017-08-27 13:13:56
(i+j)%((s+1)*2)==0 for / |
|
neelesh_25:
2017-01-15 12:02:20
This was a very tricky question.But here is the catch:
|
|
Lara:
2016-10-11 02:52:14
Using python3 and getting runtime error. Not sure why, it works on my computer and on ideone. Any ideas? |
|
gaurav_1791:
2016-09-25 20:13:47
thanks sirmokona, 0 == (k-j) % (2*s[i]+2) this is for slash |
|
onursurme:
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. |
|
swarathesh60:
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)) ? "/" : "."
|
|
maverick21:
2016-06-19 09:14:08
Hint guys:
|
|
arpitsharma:
2016-05-22 21:35:00
I couldn't get the 2nd output :/ very tough! |
|
Dennis Slater:
2016-04-29 20:08:11
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.
|
Added by: | kuszi |
Date: | 2012-09-04 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |