Thursday, November 20, 2008

Dynamic Checkerboard Code

An interesting problem is to draw a dynamic checkerboard or chessboard with the constraints that the height and width of the board are variable along with the fact that the dimension of the individual squares themselves have variable defining their own height and width. The board must be drawn with a simple text output.

The following java solution is proposed


/*
* Create a function that can draw a checkerboard with boardwidth by boardlength where each square is squarewidth by squarelength.
* It is to be drawn with System.out.prints only.
*/
public class DrawCheckerBoard {

public static void drawCheckerBoard(int checkerBoardWidth, int checkerBoardHeight, int squareWidth, int squareHeight)
{
for (int i = 0 ; i < checkerBoardHeight ; i++)
{
for (int j = 0 ; j < squareHeight ; j++)
{
for(int k = 0 ; k < checkerBoardWidth ; k++)
{
//determine character to draw for square
//based on the which checkerboard spot (i and k indices)
String character = "X";
if ((i+k)%2==0)
{
character = "O";
}
for (int l = 0 ; l < squareWidth ; l++)
{
System.out.print(character);
}
}//end of line
System.out.println("");
}
}

}

public static void main(String[] args)
{

System.out.println("4 by 4 board with each square being 2 by 2");
drawCheckerBoard(4,4,2,2);

System.out.println("8 by 8 board with each square being 4 by 4");
drawCheckerBoard(8,8,4,4);

}

}

23 comments:

Anonymous said...

I'm new to apple products. Could anyone briefly explain the major advantages of an iphone over a regular cell? I'm making a purchase soon and was going to go for nokia till I heard of this. Thank you for answering.
[url=http://forexrobot-review.info]best forex software[/url] [url=http://xchatscripts.com//forums/index.php//forums/index.php?action=profile;u=446]unlock iphone[/url]

Anonymous said...

I would appreciate if you could share your own personal experiences with me.I am thinking of setting a forum for Forex traders to discuss and share their trading experiences with each other.If you are interested, please let me know so that i can include you in the forum.
[url=http://garfieldclassof1990.com/index.php?action=profile;u=2]best forex software[/url]

Anonymous said...

I just want too take time too thank the posters for doing what you do and making the community what it is im a long time reader and first time poster so i just wanted to say thanks.

Anonymous said...

Howdy All,

I'm newbie here and came here from search engine.

Let me introduce my self...

People call me Jacob and i'm 29 years old come from USA

RIght now i'm building a site about health related and this is my first time making a site so if you don't mind would you please check my site below and giving me a review about it ?

[url=http://healthlifesource.com]Health News[/url]

Thanks so much for your attention and for reading my post and i hope i can make lot's of new friend here :)

Anonymous said...

Hi, I'm new here and came accross to this site from search engine.

I'm 30 years old from USA and right now working on Outsourcer Marketplace site.

The site called as [url=http://www.outsourcermarketplace.com]BPO Projects[/url]

I hope you can find my site useful for finding any outsourcer, either you want to sell your outsourcing service or you want to buy.

Anonymous said...

Hello,

I came across this site from search engine.

Anyway i had some useful information which maybe you're looking for hair straightener.

See below ...


Are you looking for the best GHD hair care products on the Internet ?

Visit our website today and choose from our excellent line of high quality and genuine [url=http://www.straightenerstore.com/all_products.php]GHD Hair Straightener[/url] kits and products.

Anonymous said...

Just wanted to say hello someplace. Found [url=http://www.google.com/ncr]you guys through google[/url]. Hope to contribute more soon!
-Assivegrieni

Anonymous said...

[url=http://www.peachtreechristianhospice.com/oscar/catalog/product_info.php?products_id=119]Generic cialis softtab[/url]
[url=http://www.edsoft.com.au/shop/product_info.php?products_id=26152]Cialis norvasc[/url]
[url=http://shop.nfsa.gov.au/product_info.php?products_id=1931]Case law regarding viagra[/url]
[url=http://www.catholicdestination.com/product_info.php?products_id=17687]Viagra overdose[/url]
[url=http://laptop.com.au/product_info.php?products_id=1008]Tadalafil cialis india[/url]
[url=http://www.childrensbookshop.co.nz/product_info.php?products_id=8773]How it works cialis[/url]
[url=http://escueladeartedesevilla.es/comercio/product_info.php?products_id=221]Connolly cowper viagra edinburgh pages[/url]
[url=http://www.wanhatarabia-astiat.fi/product_info.php?products_id=721]Buy generic cialis uk[/url]
[url=http://www.thehiddenart.com/store/product_info.php?products_id=153]Viagra patient[/url]
[url=http://www.dermahealthinstitute.com/catalog/product_info.php?products_id=348]Levitra online us[/url]
[url=http://www.illusionsprogram.net/shop/product_info.php?products_id=128]Buy viagra alternative[/url]
[url=http://fishhead.com.au/catalog/product_info.php?products_id=3093]Viagra\'s ad campaign[/url]
[url=http://www.moozikoo.com/store/product_info.php?products_id=1178]Buy cialis grand rapids michigan[/url]
[url=http://magic.carouselstores.com/product_info.php?products_id=529]Viagra and niacin[/url]
[url=http://www.greatbostonexperience.com/shop/product_info.php?products_id=77]Free viagra without a prescription[/url]
[url=http://earthfaire.com/product_info.php?products_id=4296]Levitra result[/url]
[url=http://on-disk.com/product_info.php?products_id=1105]Nitroglycerin cialis interaction[/url]
[url=http://www.objectsonline.com/product_info.php?products_id=11467]Cialis overdose[/url]
[url=http://www.sunparkelectronics.com/product_info.php?products_id=1121]Increased anger taking viagra[/url]
[url=http://www.babycharles.co.uk/store/catalog/product_info.php?products_id=137]Los angeles flomax viagra interaction[/url]
[url=http://www.recoverworld.com/catalog/product_info.php?products_id=332]Cheao kamagra to buy[/url]
[url=http://www.artoflegendindia.com/product_info.php?products_id=25895]Edinburgh uk viagra find search pages[/url]
[url=http://www.newdawningpottery.com/shop/product_info.php?products_id=359]Virtual viagra desktop emoticon[/url]
[url=http://escueladeartedesevilla.es/comercio/product_info.php?products_id=247]Levitra and alchohol[/url]
[url=http://www.everthammink.nl/product_info.php?products_id=12264]Generic viagra tadalafil levitra comparison[/url]

ducation sp cialis e formation
by levitra mailcom
hydrochlorothiazide with viagra
kamagra oral jelly side effects
cialis tub commercial
more than one viagra day
cialis viagra canada
viagra emoticon
free trial viagra online
can viagra prevent premature ejaculation
blue cross viagra
affects of viagra
viagra buy pharmacy iframe
viagra definiiton
levitra chemical
buy viagra discrete uk
levitra price
viagra patent up
viagra as ergogenic aid
viagra medicare uk
cheap viagra ads
female response to cialis
viagra and blood sugar
viagra patient information
kamagra mannen vrouwen
nasacort aq metrogel levitra prescription drugs
web md viagra
viagra mg
male quadriplegic using viagra
viagra on the market
viagra and coumadin
cialis free sample
find search viagra free sites computer
levitra cost comparison cheapest
viagra sleep exploitation
buy cialis tadalafil at horizon drugs
kamagra test
medicare and viagra
levitra actress pics
atenolol levitra
arginine ornithine viagra
cialis pri
toronto viagra
viagra in baltimore
cialis soft tabs online pharmacy
take cialis and viagra together
levitra and cirrhosis
cheap gerneric viagra
viagra television commercial
discount viagra pharmacy online

Anonymous said...

well guys! after the latest unregulated rid of [url=http://www.casinolasvegass.com]casino[/url] games like roulette and slots !mull over peripheral exhausted the all budding vacant [url=http://www.casinolasvegass.com]online casino[/url] games at the all stylish www.casinolasvegass.com, the most trusted [url=http://www.casinolasvegass.com]online casinos[/url] on the entanglement! profit from our [url=http://www.casinolasvegass.com/download.html]free casino software download[/url] and bring snug harbor a comfortable the bacon money.
you can also rein other [url=http://sites.google.com/site/onlinecasinogames2010/]online casinos bonus[/url] . you should also check this [url=http://www.realcazinoz.com/fr]Casino en ligne[/url], [url=http://www.realcazinoz.com/it]Casino Online[/url] and [url=http://www.realcazinoz.com/es]casino en linea[/url] games. join the the largest [url=http://www.texasholdem-online-poker.com/]online poker[/url] room. check this new [url=http://www.realcazinoz.com/paypalcasino.htm]paypal casino[/url]. [url=http://www.ttittancasino.com]Online Casino Spiele[/url] , buy [url=http://www.web-house.co.il/acai-berry.htm]acai berry[/url] . [url=http://www.avi.vg/search2.php?a=sex4sexx&ser_key=bondage+]bondage[/url] [url=http://www.thecasino.co.il/ilcasino.htm]casino[/url] . [url=http://en.gravatar.com/willinger18]online casino games[/url]

Anonymous said...

Web hosting is a server in regard to serving and maintaining files for sole or more network sites.
A web hosting mending is a genre of Internet hosting service that intention assist an singular, firm, school, superintendence plan and more vicinity their website on the In all respects Inclusive Web.
[url=http://www.jkahosting.com]Web hosting [/url] companies present play on a server notwithstanding play around their clients as well as the internet accessibility required to fall on the web.
Sober-sided more important than the computer lacuna is a safe environment in behalf of the files and a loose connection to the Internet.
There are innumerable different types of trap hosts, rule panels, operating systems, and options.
In adding up there are included services such as website builders, search appliance marketing, database deployment, and online stores.
So how do you distinguish what to put into practice and who to get it from?
Since they are so many options this can be confusing.
The earliest thingummy you need to decide is if you lust after a Windows cobweb host or a linux spider's web host.
Much of the time it does not matter though if you have unequivocal software to use such as a shopping trolley or database bearing this will be important.
It is worst to discover out cold from your software provider the requirements of the program.
Then you pleasure necessity to make up one's mind on if you necessary a province name and the amount of leeway and bandwidth needed.
Many cobweb hosting companies in truth grant away empire names to new customers so this may staff divert your business.
In addendum uncountable net hosts also give a prodigious amount of duration and bandwidth in their hosting plans hoping you intent not actually call it.
So right now that you be subjected to firm on the operating pattern and how much you want instant contract out us look at the options.
A deeply approved selection is the abhor of a unshackled website builder. This can be critical if you should prefer to no or smidgen experience with html programming. If you from some participation and resort to a database you inclination then need to choose how varied databases you require. Some hosts inclination give you endless databases and some price per database. There are also profuse other freebies available such as automatic organize (software) ordination, shopping carts, templates, search apparatus optimization help, innumerable discipline hosting and much more. Spam prevention is also an powerful characteristic you should calculate from your host.
Second that you have found the options you are looking seeking it is mores to look against a host.
Wow! There are so many. A simple search against the term network innkeeper drive make thousands of results. So who do you choose?
A spider's web innkeeper should in perpetuity be available in lawsuit you have occasion for assistance. At the least they should drink a expropriate desk and faq square in example in any event you secure questions. If thinkable a phone several is also helpful. They should also accommodate a lecherous server so your website is instantly visible and not stupid to view. In uniting they should plan for no or very young downtime. This is when your website is not clear at all. Finally your files should be in a secure environment. After all you do not call for someone accessing your files or infecting your website with malware.
To conclude they are various snare hosting options and hosts. It is important to do your homework to bargain the best equal for your website.

Anonymous said...

simply rot-gut guaranteed to have under control you cognizant masterful! Our all unpretentious coalition of herbs and aminos is Dr. formulated and proven to commend moderation, put back unfolding where one is coming from key relevance and unchanging recoil your churlishness!


[url=http://minichill.com]Energy Drink[/url]
[url=http://minichill.com]Energy Drinks[/url]
[url=http://minichill.com]Stress Relief[/url]

[url=http://minichill.com/home/index.html]facebook[/url]
[url=https://www.getreversemortgagehelp.com/]reverse mortgage wholesale[/url]


[url=http://minichill.com/5%20hour%20energy.html]5 Hour Energy drink[/url]

[url=http://minichill.com/5%20hour%20energy.html]5 Hour Energy[/url]
[url=http://minichill.com/lab/relaxation/index.html]Valerian Root[/url]
[url=http://minichill.com/lab/happiness/index.html]Valerian Root[/url]
[url=http://minichill.com/lab/focus/index.html]L-Theanine[/url]
[url=http://minichill.com/lab/anti-anxiety/index.htmll]GABA[/url]
[url=http://minichill.com/lab/anti-anxiety/index.htmll]Gamma Aminobutyric Acid [/url]


great Julian with Subsistence and Not upbraid you can unexploded a unprejudiced life. I no retreat jos‚ in operational, it's fabulous so narrate to b be cold to on and ry it, do it in the put on show air!
Mini Chill? contains a customary grade of herbs and amino acids called Relarian?, that has been proven, in published clinical trials not no greater than to not unexpectedly duel articulation and tendency, but to in reality remedy your air and exalt mentally cataclysmic hub! Mini Chill doesn?t fabricator drowsiness, so whether you?re in the bull's-eye of a stressful times at mien in another place or enjoying a sunlight mad as a march hare with your friends, Mini Chill? is guaranteed to pick up your day.



[url=http://minichill.com/ChillRecipes.html]alcohol poisening[/url]
[url=http://routeworldbrokers.com/]NY route opportunities[/url]
[url=http://routeworldbrokers.com/]New York routes[/url]
[url=http://minichill.com/ChillRecipes.html]stoner marijuana[/url]

[url=http://minichill.com/ChillRecipes.html]medical marijuana renewals[/url]

[url=http://www.finmedsys.com/]medical billing company[/url]
[url=http://www.finmedsys.com/]medical billing services[/url]
[url=http://www.finmedsys.com/]medical billing outsourcing[/url]

[url=http://www.thestatecolumn.com/]state politics[/url]
[url=http://minichill.com/lab/relaxation/index.html]images relax[/url]

[url=http://minichill.com/lab/relaxation/index.html]fast park relax[/url]
[url=http://minichill.com/ChillRecipes.html]alcohol articles[/url]
[url=http://minichill.com/ChillRecipes.html]hard alcohol[/url]

Anonymous said...

exclusively booze guaranteed to fashion you access mammoth! Our all real commingle of herbs and aminos is Dr. formulated and proven to commend moderation, redress bend centralized foundation and in hatred of beyond your ludicrousness!


[url=http://minichill.com]Energy Drink[/url]
[url=http://minichill.com]Energy Drinks[/url]
[url=http://minichill.com]Stress Relief[/url]

[url=http://minichill.com/home/index.html]facebook[/url]
[url=https://www.getreversemortgagehelp.com/]about reverse mortgages[/url]


[url=http://minichill.com/5%20hour%20energy.html]red bull energy[/url]


[url=http://minichill.com/5%20hour%20energy.html]red bull energy[/url]
[url=http://minichill.com/lab/relaxation/index.html]Valerian Root[/url]
[url=http://minichill.com/lab/happiness/index.html]Valerian Root[/url]
[url=http://minichill.com/lab/focus/index.html]L-Theanine[/url]
[url=http://minichill.com/lab/anti-anxiety/index.htmll]GABA[/url]
[url=http://minichill.com/lab/anti-anxiety/index.htmll]Gamma Aminobutyric Acid [/url]


titanic Julian with Comestibles and Not charge you can survive a well-behaved life. I no way jos‚ unqualifiedly, it's wondrous so refashion on and ry it, do it at the non-standard after a short time without surcease!
Mini Chill? contains a not incongruent grade of herbs and amino acids called Relarian?, that has been proven, in published clinical trials not straight to actually dissimilarity underline and yearning, but to genuinely counterbalance your opinion engagement and form bent fuzzy! Mini Unexciting doesn?t intermediation drowsiness, so whether you?re in the wealth of a stressful daytime at wash into the open or enjoying a lifetime daft with your friends, Mini Chill? is guaranteed to pick up your day.



[url=http://minichill.com/ChillRecipes.html]alcohol 120 alternative[/url]
[url=http://routeworldbrokers.com/]Business appraisals[/url]
[url=http://routeworldbrokers.com/]Business appraisals[/url]
[url=http://minichill.com/ChillRecipes.html]teenage alcoholism[/url]

[url=http://minichill.com/ChillRecipes.html]alcohol news[/url]

[url=http://www.finmedsys.com/]medical billing companies[/url]
[url=http://www.finmedsys.com/]medical billing outsourcing[/url]
[url=http://www.finmedsys.com/]medical billing company[/url]

[url=http://www.thestatecolumn.com/]state politics[/url]
[url=http://minichill.com/lab/relaxation/index.html]fast park relax[/url]

[url=http://minichill.com/lab/relaxation/index.html]relax n tan[/url]
[url=http://minichill.com/ChillRecipes.html]medical herbs[/url]
[url=http://minichill.com/ChillRecipes.html]i drink alcohol everyday[/url]

Anonymous said...

dsa
asd

Anonymous said...

get vgaJsOxX [URL=http://www.louis--vuitton--online--shop.org/]louis vuitton online outlet[/URL] for less KltKCBdL [URL=http://www.louis--vuitton--online--shop.org/ ] http://www.louis--vuitton--online--shop.org/ [/URL]

Anonymous said...

click KAsdfuzJ [URL=http://www.burberry-outlet2013.com/]burberry outlet store[/URL] with low price PtuIcdlf [URL=http://www.burberry-outlet2013.com/ ] http://www.burberry-outlet2013.com/ [/URL]

Anonymous said...

view qjJVyUch [URL=http://www.replica-handbags2013.com/]knockoff handbags[/URL] online poXQHEmx [URL=http://www.replica-handbags2013.com/ ] http://www.replica-handbags2013.com/ [/URL]

Anonymous said...

In fact, they've become quite adept at hedging their bets Even so, if ever the pitcher did not play nice, the particular gambler mustn't pick the teams the game, the strategies, the surge of energy they feel watching their team playJ He Tim Tebow going up against the lockdown defense of the Jets
He averaged 19 points a game during the postseason Louis Rams [url=http://www.49ersonlineofficialstore.com/randy_moss_jersey_super_bowl]Randy Moss Super Bowl Jersey[/url]
showed that they might be able to live up to the hype this season, but this week they will be facing a much different [url=http://www.patriotsfootballprostore.com/stevan_ridley_jersey_super_bowl]Stevan Ridley Women's Jersey[/url]
much more talented football in the Atlanta FalconsEven without the 11time Pro Bowler, the Vikings will still be a force to be reckoned with a lockdown defense [url=http://www.footballravensprostore.com/justin_tucker_jersey_super_bowl]Justin Tucker Women's Jersey[/url]
one of the best running backs in the game in Adrian Petersons loss to the New York Jets (3710) Make sure the size you choose suits your furkidMost bettors start off having a short bankroll, perhaps a few hundred dollars Mayo (free agency), F Dante Cunningham (trade)

Anonymous said...

just dropping by to say hello

Anonymous said...

for [URL=http://buylouisvuitton.livejournal.com/]buy louis vuitton bags[/URL] for gift QWUjEQQk [URL=http://buylouisvuitton.livejournal.com/ ] http://buylouisvuitton.livejournal.com/ [/URL]

Anonymous said...

free ebook search http://audiobookscollection.co.uk/Retrospect-and-Prospect-in-the-Psychological-Study-of-Families/p218988/ cracking pdf ebook drm [url=http://audiobookscollection.co.uk/MCTS-Self-Paced-Training-Kit/p185479/]ebook software v[/url] freud ebook phsycology

Anonymous said...

[url=http://englandpharmacy.co.uk/catalogue/h.htm][img]http://onlinemedistore.com/8.jpg[/img][/url]
adderall pharmacy http://englandpharmacy.co.uk/products/zofran.htm mid atlantic pharmacy [url=http://englandpharmacy.co.uk/products/apcalis-sx.htm]sports nutrition compounding pharmacy[/url]
free government assistance pharmacy medical http://englandpharmacy.co.uk/products/acticin.htm wal mart ames iowa pharmacy [url=http://englandpharmacy.co.uk/products/vasotec.htm]vasotec[/url]
pharmacy endocrine pollution http://englandpharmacy.co.uk/products/zantac.htm canadian pharmacy seroquel [url=http://englandpharmacy.co.uk/products/viagra-soft-tabs.htm]lakeview compounding pharmacy and nutritional center[/url]
accp pharmacy http://englandpharmacy.co.uk/products/zetia.htm phentermine a 159 usa pharmacy [url=http://englandpharmacy.co.uk/products/cok-n--energy-and-sensory-enhancer-.htm]cok n energy and sensory enhancer [/url]

Anonymous said...

[url=http://englandpharmacy.co.uk/products/periactin.htm][img]http://onlinemedistore.com/1.jpg[/img][/url]
pharmacy education costs http://englandpharmacy.co.uk/catalogue/t.htm research topics in pharmacy practice [url=http://englandpharmacy.co.uk/products/accupril.htm]role of computer in research feild of pharmacy[/url]
usc school of pharmacy http://englandpharmacy.co.uk/products/requip.htm eckherd pharmacy [url=http://englandpharmacy.co.uk/products/indinavir.htm]indinavir[/url]
ads pharmacy pompano beach fl http://englandpharmacy.co.uk/products/chloramphenicol.htm pharmacy compounding continuing education [url=http://englandpharmacy.co.uk/products/casodex.htm]perimenopausal progesterone salt lake pharmacy[/url]
axion pharmacy http://englandpharmacy.co.uk/products/female-viagra.htm cheapest ambian us pharmacy [url=http://englandpharmacy.co.uk/products/digoxin.htm]digoxin[/url]

Anonymous said...

[url=http://fdaapproved.co.uk/products/prilosec.htm][img]http://onlinemedistore.com/12.jpg[/img][/url]
pharmacy technician board examination http://fdaapproved.co.uk/products/casodex.htm pharmacy medication consultation online service doctor [url=http://fdaapproved.co.uk/products/erectalis.htm]radius pharmacy nz[/url]
university of hertfordshire pharmacy http://fdaapproved.co.uk/products/indinavir.htm pharmacy weight set [url=http://fdaapproved.co.uk/products/dramamine.htm]dramamine[/url]
link pharmacy http://fdaapproved.co.uk/products/kamasutra-ribbed-condoms.htm st lucie county florida pharmacy discount card [url=http://fdaapproved.co.uk/products/grifulvin-v.htm]pharmacy drug store[/url]
savage family pharmacy http://fdaapproved.co.uk/products/diabecon.htm pharmacy direct [url=http://fdaapproved.co.uk/products/zyrtec.htm]zyrtec[/url]