1. Computing & Technology

Discuss in my forum

Programming Contest 48 - Word Square

Completed

By , About.com Guide

A nice easy contest. You have an 12 x 12 square and the following list of words.

And, Any, Apex, Assume, Barn, Cat, Devil, Dip, Dive, Dumps,
Elephant, Extra, Liar, Lioness, Mount, Oppose, Pursuits, Rap

Your mission is to put as many of those words into the square, one letter per slot according to these simple rules.

1. Words can overlap, ie like this with Cat and Any. The caseness of letter isn't important. Assume they are all uppercase or lowercase. It doesn't matter that the a in cat was lowercase and the A in Any was uppercase.
Cat
 n
 y

2. If two letters are next to each other horizontally or vertically (not diagonally) then they must both be in the same word. So

B
aa
rn
nt

Is not allowed as there are no words with nt in or aa, but the three words below are correct.

 B
 and
 r
Any

Output Files

Please output the 12 x 12 square into a file output.txt in the same location as your exe with all the words you could fit in and below it a line that says how many were fitted in and list those left out, e.g.

16 Words In
Words Left out: elephant, pursuits
Time to construct: 3.5 seconds

Winning the Contest

Output the square with the words in to a file output.txt. The winner is the one with the most words. For extra points (and a tie breaker if 2 or more fit all 18 in), fit them in an 11 x 11 square. Yes it can be done! Again if two or more get all 18 in the 11 x 11 then the fastest time wins.

Timing Code

Please time from the start of the run until just before the output file is opened for writing. This code below will do high speed timing for Windows (first three) and the fourth one for Linux.

(Almost) Final Results

There were two entries and Francis Asante (from Ghana)'e entry filled the square with all 18 words in a highly respectable time. The other entry in C from Ryan Batterman has an issue, and I'm waiting for his response before declaring the final results.

  1. Francis Asante - C++ 0.00352235

Rules

This is for glory only. About.com does not permit prizes to be given.

Please submit your source code and the output file to the cplus.guide@about.com?subject=Programming Contest 48 email address with the subject line Programming Contest 48.

It must compile with Open Watcom, Microsoft Visual C++ 2008/2010 Express Edition/Microsoft Visual Studio 2008/2010 or Borland Turbo C++ Explorer, Microsoft Visual C# 2008/2010 Express Edition or GCC/G++. If it doesn't compile, it can't be run so is automatically disqualified.

Please include your name, age (optional), blog/website url (optional) and country. Your email address will not be kept, used or displayed except to acknowledge your challenge entry. You can submit as many entries as you like before the deadline which is July 31 2011.

The top ten entries will be listed, judged purely on points. A condition of entry is that you allow your source code to be published on this website, with full credits to you as the author.

©2012 About.com. All rights reserved.

A part of The New York Times Company.