Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Programming challenges - Page 2
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Programming challenges

  1. #11

    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. #12
    Guest

    Re: Programming challenges

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

  3. #13

    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. #14
    Guest

    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
    
     return total
    
    
    def count(number):
     return len(str(number))
    
    if __name__ == '__main__':
     num = None
     while num != 0:
      num = input("Enter a number: ")
      print count(fact(num))

  5. #15
    Guest

    Re: Programming challenges

    Leap year is done too:

    Code:
    #!/usr/bin/env python
    
    import time
    
    def leap(year):
     if year % 400 == 0:
      return "%d is a leap year" % year
     elif year % 100 == 0:
      return "%d is not a leap year" % year
     elif year % 4 == 0:
      return "%d is a leap year" % year
     else:
      return "%d is not a leap year" % year
    
    
    if __name__ == '__main__':
     current_year = int(time.strftime("%Y"))
     year = None
    
     while year != current_year:
      year = input("Enter a year: ")
      print leap(year)

  6. #16
    Guest

    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("Enter #%d: " % (i+1))
    
     for entry in entries:
      print "W"*entry

  7. #17
    Guest

    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("Enter a number: ")
    
     *low = find_lower(number)
     *high = find_higher(number)
     *print "%d is bounded by the prime numbers %d and %d." % (number, low, high)
    I'm on fire, am I not? ;D

  8. #18
    Guest

    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("Enter board size: ")
      if size == 0: break
      print "A %dx%d board contains %d squares of any size" % (size, size, squares(size))

  9. #19

    Re: Programming challenges

    Vince, you're a machine!

    I'm still ironing out bugs from 1 + 2 >

  10. #20

    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.

Similar Threads

  1. Need Help with Network Programming
    By omidkamangar in forum Programming
    Replies: 1
    Last Post: 05-01-2006, 03:23 PM
  2. Microsoft Search Engine Challenges Google
    By genesis in forum Windows - General Topics
    Replies: 10
    Last Post: 02-04-2005, 09:21 PM
  3. Programming
    By imported_n00b in forum Announcements and Suggestions
    Replies: 12
    Last Post: 09-17-2004, 06:35 PM
  4. Programming
    By Asbenson in forum General Chat
    Replies: 34
    Last Post: 06-19-2004, 04:54 AM
  5. Programming Challenges
    By ndogg in forum Programming
    Replies: 1
    Last Post: 12-12-2001, 12:27 PM

Bookmarks

Posting Permissions

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