Should we? It's the kind of thing that's cool. I participate as long as the task is useless yet fun to do
Should we? It's the kind of thing that's cool. I participate as long as the task is useless yet fun to do
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.
It wouldn't be something hard... something like what I did here (see bottom of the page)
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.
Sounds like my job discription.for the most part all i do is bang bits. *
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.
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.
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: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.
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!"
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)
I'll probably come up with something Friday. I would have today but I got busy with other things.
Bookmarks