CPTTRN1 - Character Patterns (Act 1)

Using two characters: . (dot) and * (asterisk) print a chessboard-like pattern. The first character printed should be * (asterisk).


You are given t < 100 - the number of test cases and for each of the test cases two positive integers: l - the number of lines and c - the number of columns in the pattern (l, c < 100).


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.


3 1
4 4
2 5




hide comments
vicc255: 2018-03-17 19:12:09

I thought the question was wrong but it's correct.See odd and even similarity between row no. and column no.
Good luck.

jairaj_sahgal: 2018-03-10 15:18:23

I love it

secret_santa1: 2017-12-20 15:57:16

Approach-1)Draw a chessboard and enter the given values i.e. fill the chessboard with "." and "*"(say 4*4 chessboard)
2)Observe the position of all the asterisk (or dots) and figure out the pattern.
3)Hint: Odd/even positions.
Note-All given input & output are correct.

vinay11vishu: 2017-11-13 20:08:34

I am able to get the pattern correctly, but with my own input. Logic seems to be right but i am missing something with their inputs. Can you mail me your solution at karmavinayvkv@gmail.com.. Would be great help..

vshantam: 2017-11-12 10:40:24

The idea i implemented was to run two for loops and when (i %2==0 and j%2==0) or (i%2!=0 and j%2!=0) then print '*' or else print '.' where i and j depends on input on each line . works for me perfectly .

Last edit: 2017-11-12 10:42:33
vinay11vishu: 2017-10-29 11:17:16

Can anybody explain me how the input should be given to this program ??

Last edit: 2017-10-29 12:35:27
imtiaz_mehedi: 2017-08-30 19:35:31

i have done it..it shows the right output but here it said it's wrong

Last edit: 2017-08-30 19:35:57
deepk_keshri: 2017-08-21 19:48:42

if line no. is odd,odd position have * and if line is even ,even position will '*'

mesakh123: 2017-08-09 08:38:43

there is two conditions and two sub conditions
1.if odd number lines:
a. if odd number word(character)position
b.if even number word(character)position
2.if even number lines:
a. if odd number word(character)position
b.if even number word(character)position

that's how i solve the problem

Last edit: 2017-08-09 08:39:46
dungtungmtp: 2017-04-06 20:37:30

ex1 and ex2 i can't know

Added by:kuszi
Time limit:0.25s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64