If you aren't already in the know, these ten problems are from the 2008 Winter Scripting games.
For each problem, I'm going to quickly sum up the interesting (interesting TO ME) bits of each problem, then I'm going to post the full source.
Event 6: Prime Time
Event: calculate primes up to 200. Solution: boring brute-force method.
#As simple as possible, calculation of primes. This
#routine is inefficient.
function Is-Prime ($n)
if ($n -le 1)
$largestPossibleCoefficient = [int]([Math]::Floor($n/2))
for ($i = 2; $i -le $largestPossibleCoefficient; $i++)
if ( ($n/$i) -eq ([Math]::Floor($n/$i)) )
$range = 2..200
foreach ($candidatePrime in $range)
if (Is-Prime $candidatePrime)
2008 Winter Scripting Game Events: Index
- Introduction: TOTAL DOMINATION!
- Event 1: Could I Get Your Phone Number?
- Event 2: Skating on Thin Ice
- Event 3: Instant (Runoff) Winner
- Event 4: Image is Everything
- Event 5: You Call That a Password?
- Event 6: Prime Time
- Event 7: Play Ball!
- Event 8: Making Beautiful Music
- Event 9: You're Twisting My Words
- Event 10: Blackjack!