Checkerboard pattern

This is a discussion on Checkerboard pattern within the Tech Board forums, part of the Community Boards category; Hi, I have practice to write the checkerboard pattern like below using HLA programming language: xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    7

    Question Checkerboard pattern


    Hi,
    I have practice to write the checkerboard pattern like below using HLA
    programming language:

    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    xxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxooooooooxx xxxxxxoooooooo
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    ooooooooxxxxxxxxooooooooxxxxxxxxooooooooxxxxxxxxoo ooooooxxxxxxxx
    what is could produce is as below:
    ------------------------------------------
    Code:
    program chess;
    #include("stdlib.hhf");
    static
       s:char := 'x';
       e:char := 'o';
       z:int32;
    
       i:int32; //1st *
       j:int32; //1st _
       b:int32;
       t:int32;
    
       x:int32;
       y:int32;	
       a:int32;
       q:int32;
    
    begin chess;
    
    //main looping
     for (mov(0,z); z<4; add(1,z)) do
    
    //1st looping
      for(mov(0,t); t<4; add(1,t))do
    
        for(mov(0,j); j<4; add(1,j)) do
    
    	for(mov(0,i); i<8; add(1,i)) do
    	   stdout.put(s);
    	endfor;
    
    	for(mov(0,b); b<8; add(1,b)) do
    	    stdout.put(e);
    	endfor;
    
        endfor;
        stdout.newln();
    
      endfor;
    
    
    //2nd looping
      for(mov(0,q); q<4; add(1,q))do
    
        for(mov(0,y); y<4; add(1,y)) do
    
    	for(mov(0,x); x<8; add(1,x)) do
    	   stdout.put(e);
    	endfor;
    
    	for(mov(0,a); a<8; add(1,a)) do
    	    stdout.put(s);
    	endfor;
    
        endfor;
        stdout.newln();
    
       endfor;
    
    //end main for
     endfor;
    
    end chess;
    ---------------------------
    Is that my code could be use? The requirement is to use only
    5 FOr loops, 4 stdout.putcSize, and 2 stdout.newln.
    At here i have use up 9 FOR loop, 4 stdout.put, and 2 stdout.newln().

    Could any sensei pls give some lecturing at me. Pls advice. Thanks.

  2. #2
    Useless Apprentice ryan_germain's Avatar
    Join Date
    Jun 2004
    Posts
    76
    Im definetly no sensei but maybe you could do something like
    Code:
    for eight_squares_high
    
        for four_rows_per_square
    
            for four_xo_patterns
    
                for 8_x_wide
                    put an x
                endfor
    
                for 8_o_wide
                    put an o
                endfor
            
            endfor
        
            newline
    
        endfor
    
        interchange Xs and Os
    
    endfor
    There is not the slightest indication that [nuclear energy] will ever be obtainable. It would mean that the atom would have to be shattered at will.

    -Albert Einstein, 1932

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    123
    Or something like this (not especially efficient, but does the trick, also mainly algorithmic as I don't know the language you're using)....
    Code:
    c = 'x';
    for(mov(0,i); i<32; add(1,i)) do
    	for(mov(0,j); j<8; add(1,j)) do
    		for(mov(0,k); k<8; add(1,k)) do
    			stdout.put(c);
    		endfor;
    		if (c is an 'x') then make it an 'o' else make it an 'x'
    	endfor;
    	stdout.newln();
    	if ((i mod 4) != 0) then
    		if (c is an 'x') then make it an 'o' else make it an 'x'
    	endif;
    endfor;
    I think you can put a signature here.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    7

    Thanks

    Hi, thanks a lot. I like the idea.
    Have a nice day.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    He is using HLA or high level assembler.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visitor / Decorator Pattern
    By MarkZWEERS in forum C++ Programming
    Replies: 9
    Last Post: 05-16-2009, 11:53 AM
  2. Composite vs Decorator pattern?
    By cpjust in forum Tech Board
    Replies: 1
    Last Post: 04-22-2009, 11:33 AM
  3. Hmm.. Ai? Finding the pattern in number squences?
    By Zeusbwr in forum C++ Programming
    Replies: 8
    Last Post: 04-02-2005, 05:13 PM
  4. (pattern *) pat & pattern * pat
    By siubo in forum C Programming
    Replies: 1
    Last Post: 04-08-2003, 10:03 PM
  5. text pattern recognition
    By mtsmox in forum C++ Programming
    Replies: 5
    Last Post: 02-27-2002, 07:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21