1. ## Re: Programming challenges

Oh, I wasn't aware of these specifications. *Anyway, I don't really care since I wasn't part of the contest and that I am doing it for fun.
The assignments were seperate from the contest. *We didn't look at any code during the contest. *I was just making a point on coding style. *I am trying to root out as much bad coding style in this world as I can. This is often the first step to debugging.

2. ## Re: Programming challenges

OK. Anyway, I'm working on Snaggy's list right now. It looks much tougher.

3. ## Re: Programming challenges

going to atempt the postfix calc now, the only way I know how: PHP

I don't realy hold out much hope, but it'll be fun (and yes Lovechild, I have a flowchart :P)

4. ## Re: Programming challenges

Heh! I took me 2 minutes to solve a problem from 1996 (the n! one)
Code:
```#!/usr/bin/env python

def fact(number):
total = 1
for i in xrange(1, number+1):
total *= i

def count(number):
return len(str(number))

if __name__ == '__main__':
num = None
while num != 0:
num = input(&quot;Enter a number: &quot;)
print count(fact(num))```

5. ## Re: Programming challenges

Leap year is done too:

Code:
```#!/usr/bin/env python

import time

def leap(year):
if year % 400 == 0:
return &quot;%d is a leap year&quot; % year
elif year % 100 == 0:
return &quot;%d is not a leap year&quot; % year
elif year % 4 == 0:
return &quot;%d is a leap year&quot; % year
else:
return &quot;%d is not a leap year&quot; % year

if __name__ == '__main__':
current_year = int(time.strftime(&quot;%Y&quot;))
year = None

while year != current_year:
year = input(&quot;Enter a year: &quot;)
print leap(year)```

6. ## Re: Programming challenges

The barred entry program:
Code:
```#!/usr/bin/env python

if __name__ == '__main__':
entries = [None]*8
for i in xrange(8):
entries[i] = input(&quot;Enter #%d: &quot; % (i+1))

for entry in entries:
print &quot;W&quot;*entry```

7. ## Re: Programming challenges

Bounding primes:

Code:
```#!/usr/bin/env python

import math, sys

def isPrime(n, sqroot):
*for x in xrange(2, sqroot+1):
* *if n % x == 0:
* * *return 0
*return 1

def find_lower(n):
*test = n-1
*is_prime = 0
*while not is_prime:
* *if isPrime(test, math.sqrt(test)):
* * *is_prime = 1
* * *break
* *test -= 1

*return test

def find_higher(n):
*test = n+1
*is_prime = 0
*while not is_prime:
* *if isPrime(test, math.sqrt(test)):
* * *is_prime = 1
* * *break
* *test += 1

*return test

if __name__ == '__main__':
*number = input(&quot;Enter a number: &quot;)

*low = find_lower(number)
*high = find_higher(number)
*print &quot;%d is bounded by the prime numbers %d and %d.&quot; % (number, low, high)```
I'm on fire, am I not? ;D

8. ## Re: Programming challenges

1999, squares problem:

Code:
```#!/usr/bin/env python

def squares(size):
number = 0
for i in xrange(1, size+1):
number += i*i

return number

if __name__ == '__main__':
size = None
while size != 0:
size = input(&quot;Enter board size: &quot;)
if size == 0: break
print &quot;A %dx%d board contains %d squares of any size&quot; % (size, size, squares(size))```

9. ## Re: Programming challenges

Vince, you're a machine!

I'm still ironing out bugs from 1 + 2 &gt;

10. ## Re: Programming challenges

You guys ought know that these high schoolers have only five hours to solve as many problems as they can. *Last year, we presented them with eight problems total, and one team (they can have teams of up to three persons each team) solved all eight problems in the alotted time.

Now, I go to an intercollegiate contest (the ACM Intercollegiate Programming Contest to be precise) and these are relatively simple in comparison.

This past year, my team took fifth place in our region. Here is a link where you guys will be able to see our standings (the UW-Oshokosh Binary Trees.) You'd be able to see the problems if that page wasn't screwed up.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•