Page 1 of 9 123 ... LastLast
Results 1 to 10 of 85

Thread: Should we have a small programming challenge?

  1. #1
    Guest

    Should we have a small programming challenge?

    Should we? It's the kind of thing that's cool. I participate as long as the task is useless yet fun to do

  2. #2

    Re: Should we have a small programming challenge?

    hummm...
    i give it a shot. but i sucks at programming in anything besides C and i am not great with that. for the most part all i do is bang bits.

  3. #3
    Guest

    Re: Should we have a small programming challenge?

    It wouldn't be something hard... something like what I did here (see bottom of the page)

  4. #4

    Re: Should we have a small programming challenge?

    Sounds like a good idea, I wish I was better at coding, but I suppose it's things like this that make you better. Seeing how other people handle the same problem different ways would be interesting too.

    for the most part all i do is bang bits. *
    Sounds like my job discription.

  5. #5

    Re: Should we have a small programming challenge?

    I see now how Bradmont figured out how to put cows in my httpd.log file. Well actually I don't since no one answered that on the thread but still... I do think that a programming challenge would be interesting. It shouldn't be language specific though. Any programmer should be able to participate. Maybe it should be something that's easy to do, but it can be done at different levels. I can't explain very well so let me give an example. A few weeks back I remember someone wrote a program that would find the factorial of a number. The challenge could be to write such a program, which most programmers could do, and the one who's finishes fastest on a given computer wins. That's just an example though.

  6. #6
    Guest

    Re: Should we have a small programming challenge?

    How about a program to find every pair of factors for a gien number? And let's make the code catch as many user errors (bad input, id10t users, etc). *Do we post our code here?

    I just thought: Since some people will do it with compiled languages and others with interpreted, should we seperate the comparaisons in 2? *Shortest code will probably be interpreted, but fastest will be compiled.

  7. #7

    Re: Should we have a small programming challenge?

    That could be a decent challenge. And yes, we post our code here so someone can compare all of them. This isn't for a prize or anything so I don't see any reason to be paranoid about people cheating. And yes, you do have a point about the different languages. But again, this isn't a serious contest, so we could just have different goals to go for, like both speed and user interaction. There can be a winner for each of these goals. That's my idea at least.

  8. #8
    Guest

    Re: Should we have a small programming challenge?


    That could be a decent challenge. And yes, we post our code here so someone can compare all of them. This isn't for a prize or anything so I don't see any reason to be paranoid about people cheating. And yes, you do have a point about the different languages. But again, this isn't a serious contest, so we could just have different goals to go for, like both speed and user interaction. There can be a winner for each of these goals. That's my idea at least.
    Here's mine:

    Code:
    #!/usr/bin/env ruby
    
    # Make sure the user at least inputs something
    if ARGV.size < 1 then
     puts "Usage: factor.rb <integer>"
     exit
    end
    
    # Display an error message if the user input something else than an integer
    if not /^\s*(\d*)\s*$/ === ARGV[0] then
     puts "Error: You must input an integer"
     exit
    end
    
    # Our number to factor, when to stop factoring (the square root of the number
    # beyond that, it's the same but backwards) and the number of pair of factors
    # found
    target = ARGV[0].to_i
    limit = Math.sqrt(target)
    number_of_fact = 0
    
    # The actual factoring, for every number from 1 to limit, check whether
    # the division with target as no decimals, and if so, display both factors
    # and add 1 to the number of pair of factors found
    for i in 1 .. limit do
     if (target % i == 0) then
      puts "#{i} and #{target/i}"
      number_of_fact += 1
     end
    end
    
    # Display the number of factors found
    puts "#{number_of_fact} pairs of factors found!"

  9. #9

    Re: Should we have a small programming challenge?

    Not the most elegant or complete solution, but it's all you're going to get from me...

    Code:
    #!/usr/bin/env python
    
    number = input("Enter a number: ")
    used = []
    
    print "Factors: "
    
    if 2L**number % number == 2:
      print 1, number
    else:
      for f in range(1, number):
        if f not in used:
          if number % f == 0:
            f2 = number / f
            print f, f2
            used.append(f)
            used.append(f2)

  10. #10

    Re: Should we have a small programming challenge?

    I'll probably come up with something Friday. I would have today but I got busy with other things.

Similar Threads

  1. The Python Challenge
    By AljoshaNL in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 02-17-2006, 07:15 PM
  2. A Challenge for the GUI gifted
    By in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 01-02-2004, 08:23 AM
  3. I need a small programming task
    By in forum Programming
    Replies: 15
    Last Post: 07-31-2002, 08:18 PM
  4. Programming Challenge
    By in forum Programming
    Replies: 9
    Last Post: 02-26-2002, 03:31 PM
  5. Cryptography challenge
    By ndogg in forum General Chat
    Replies: 15
    Last Post: 02-20-2002, 01:50 AM

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
  •