PDA

View Full Version : challenge


kryptech.net
05-18-2004, 11:17 AM
any good ideas, I want to start a challenge... any ideas, sans, jemfinch, stuka, anybody???

zachogden
05-18-2004, 07:52 PM
i've always wanted to challenge someone. like; someone posts a problem, and you have 24 hours to solve it in any language you know. I'd like to challenge you, krytech. As soon as someone posts a problem, we setup a start time. Sound like a plan?

kryptech.net
05-18-2004, 09:56 PM
awsome, hope I can hold my ground... :)

zachogden
05-19-2004, 12:51 AM
All we need now is a problem.... one that can be solved in 24 hours.

kryptech.net
05-19-2004, 10:40 AM
hmm.. that eliminates a lot. :)

kryptech.net
05-19-2004, 05:38 PM
anyone, a problem?

GnuVince
05-19-2004, 07:31 PM
Write a function that returns the perimeter of a rectangle.

zachogden
05-20-2004, 12:26 AM
Thst's not much of a challenge. lol.

kryptech.net
05-20-2004, 09:05 AM
oh, yeah. even I can do that one. :) (I'm just hoping that was a joke)

woodwind
06-07-2004, 04:53 AM
So do it, guys. It can't hurt you.

MJPhill
06-08-2004, 11:33 PM
Expanded upon: Write a function that, upon being given the perimeter of a rectangle, gives the dimensions of the rectangle with the greatest area as well as the one with the smallest area using the given perimeter.

woodwind
06-09-2004, 01:57 AM
Assuming you want integral dimensions, here is a messy brute-force solution:


import math

# Returns a tuple of tuples containing ((max_w, max_l), (min_w, min_l))
# p is the perimeter
def find_dims(p):
r = int(math.ceil(p/2))
max_w = 0
max_l = 0
for w in range(1, r+1):
l = r-w
if w*l > max_w*max_l:
max_w = w
max_l = l
min_w = max_w
min_l = max_l
for w in range(1, r):
l = r-w
if w*l < min_w*min_l:
min_w = w
min_l = l

return ((max_w, max_l), (min_w, min_l))


Am I right?

woodwind
06-09-2004, 02:53 AM
Here's a formulaic method. Maybe hard to understand, but it's short and it works:

import math

def find_dims2(p):
max_w = int(math.floor(p/4))
max_l = max_w
if 2*(max_w+max_l+1) <= p:
max_l += 1
min_l = int(math.floor(p/2)) - 1
return ((max_w, max_l), (1, min_l))

Strike
06-09-2004, 11:41 AM
Well the simple answer is that for any given perimeter, the dimensions with the max area are equal. That is, for any given rectangle perimeter p, p/4 is the length of the side of the rectangle which will have the maximum area. The dimensions of the rectangle with the smallest area are where one of the dimensions is epsilon and the other dimension is (p/2) minus epsilon (okay, minus two epsilon ;)).

kryptech.net
06-09-2004, 03:05 PM
okay.... so the smallest area is (very, very, very near) zero, and the max is p/4 squared

woodwind
06-09-2004, 06:07 PM
Yeah, it's a lot easier with non-integral dimensions. You have a square for max and you have an infinitely small rectangle (which is cool to think about!) for min. The brute-force solution requires a bit of programming, though, so I figured that's what he meant.

iDxMan
06-10-2004, 09:51 AM
Originally posted by woodwind
So do it, guys. It can't hurt you.

Notice that neither have posted any code towards a solution. Gee...

-r

kryptech.net
06-10-2004, 02:55 PM
WTF.. you want me to make a function that returns a perimeter or a rectangle... like that's hard...
int perimiter(int width, int length) {
return width * 2+ length * 2;
}

iDxMan
06-13-2004, 05:00 PM
I don't really care what you do. There seems to be lots of talk and no challenge.

At the least view http://acm.uva.es/problemset/ and pick something that fits. I believe several of the challenges have been suggested here in the past. Perhaps you'll find something that's not too easy for you....

-r

kryptech.net
06-13-2004, 06:00 PM
most things are not too easy for me... ;-)