DWITE

DWITE solution code

DWITE is an online programming contest based in Ontario, Canada. It is a practice contest with 5 rounds in a year, all held before other real contests. (For example, ECOO and CCC begin in March.) Its official web site is http://www.dwite.ca/.

My solutions are in Java, requiring version 5.0 or above. Using an editor with syntax highlighting is highly recommended.

Trivia: DWITE stands for Do While If Then Else.

Problems and solutions

Contest date Problem Solution Comments
2004-10#1Area of CircleTrivial.
#224 Hour ClockTrivial.
#3The Tallest in the ClassStraightforward: Sorting.
#4CD-ROM FilesSubset sum problem (dynamic programming).
#5Super Long SumsTrivial, using java.math.BigInteger.
2004-11#1Credit Card Check DigitTrivial.
#2SquarelandTrivial.
#3FactoringRational zeros of polynomials.
#4For LoopsDijkstra’s shunting yard algorithm.
#5Wind ChillTrivial.
2004-12#1Prime FactorizationRecursion, primality testing.
#2Squareland IIStraightforward. Can be sped up from O(n4) to O(n2) by dynamic programming, though.
#3ReflectionsTrivial: Trigonometry.
#4Waring’s Prime Number ConjectureBrute force search with help from the Sieve of Eratosthenes.
#5Hidden GeographyTrivial: String processing and searching.
2005-01#1DWITE Golf TournamentStraightforward: Sorting.
#2MinesweeperStraightforward.
#3Harshad NumbersStraightforward, using brute force search.
#4Zeller’s CongruenceTrivial: Follow the given algorithm.
#5Different Bases MultiplicationTrivial.
2005-02#1Bretschneider’s FormulaTrivial.
#2SnakesFlood fill and neighbour count.
#3Simple Continued FractionsTrivial.
#4Matrix Chain ProductMatrix chain multiplication (dynamic programming).
#5Tsunami SpeedTrivial.
2005-10#1OdometersMine runs in O(n2) time, where n is the number of digits. The O(10n) solution is straightforward.
#2The Game of LifeStraightforward.
#3Sum ’Em UpTrivial, and the sum can be written in closed form.
#4MinesweeperFlood fill (recursion).
#5Five Digit DivisibilityBrute force search through all permutations.
2005-11#1Quadrilateral CentroidTrivial, arithmetic mean.
#2Variations on the Game of LifeStraightforward.
#3Cinquain PoetryTrivial.
#4Stacking BlocksSubset sum problem (dynamic programming).
#5Base64 EncodingStraightforward.
2005-12#1SemiprimesStraightforward.
#2The MazeBreadth-first search, and the problem is plagiarized from DWITE 2003-10 #5.
#3Reducing FractionsStraightforward: GCD algorithm.
#4Now I Know My ABC’sTrivial: Histogram.
#5How Many SumsSubset sum problem (dynamic programming).
2006-01#1Filling The ConeTrivial: Algebra.
#2ScrabbleStraightforward but long.
#3London KnightsStraightforward: Sorting. It screams for the use of SQL, though.
#4Equivalent AmountsTrivial. Convert to common unit, then convert from common unit.
#5Distance Between TownsDijkstra’s algorithm.
2006-02#1Points on a LineTrivial. Mine doesn’t use the division operation.
#2Floppy Disk 3½-inch High DensitySubset sum problem (dynamic programming).
#3UPC Check DigitTrivial.
#4Connect-4Straightforward.
#5Prime PalindromesStraightforward: Brute force search, Sieve of Eratosthenes.
2006-10#1Pete’s Printing PressTrivial, but the data table is large.
#2Body Mass IndexTrivial.
#3Basketball Statistics IIStraightforward: Sorting.
#4Count SquaresStraightforward. Can be sped up from O(n5/2) to O(n3/2) using dynamic programming, where n is the number of cells.
#5Bad Input IITrivial if you have access to a bignum library.
2006-11#113375P34|<Trivial.
#2Lottery Ticket CheckerTrivial.
#3Linear Binomial ProductsStraightforward.
#4Money PrizeDynamic programming.
#5Goldbach’s Weak ConjectureRecursion, Sieve of Eratosthenes.
2006-12#1Jimmy’s Lost His MarblesSubset sum problem (dynamic programming).
#2Ulam Spiral WalkwayStraightforward.
#3Circular PrimesStraightforward.
#4The Ubiquitous 196Straightforward.
#5Caesar’s CipherTrivial.
2007-01#1Filling The ConeTrivial: Algebra. Plagiarized from DWITE 2006-01 #1.
#2MinesweeperStraightforward. Plagiarized from DWITE 2005-01 #2.
#3Elapsed Time in SecondsDate calculation.
#4Number TheoryTrivial if you know about the partition function.
#5Dutch SolitaireStraightforward. Know how to use data structure libraries!

Links

Last modified: 2008-04-29-Tue
Created: 2007-04-20-Fri