About the TAS gag you are both correct. I actually meant that they create them parallel so 4.5 is correctly.
Very interesting task. If I see it correctly neither Pythagoras nor any angle functions work here so I couldn't solve this. However I see that it has a possible solution, it's just beyond my mathematical knowledge to find the correct formulas at the moment. Let's see if someone else can do it.
A B
|\ /|
| \ / |
| \ C / |
3| \ / |4
| X |
0| / \ |0
| / | \ |
| / | \ |
|/ | \|
D|____F____|E
x
The ladders aren't the same length but just for the picture, this is what I'm deriving from the words. So I'm dropping a perpendicular from C down to line DE, and call that point of intersection F.
The question is asking to find the length of DE, which I have labeled x (edit: not to be confused with big X, which is just a pretty way of showing intersecting ladders).
By similar triangles, Length(DF) = x/3 and Length(EF) = x/4. But Length(DF) + Length(EF) = x.
Substituting, I get that x/3 + x/4 = x.
7x/12 = x.
x = 0.
Broo? What am I doing wrong?
<Swordless> Go hug a tree, you vegetarian (I bet you really are one)
The question is wrong. If the ladders hit the walls at the points specified, then the distance from the intersection to the ground is easy to calculate, and it is not 10 metres. Besides, the data given has absolutely no information about the horizontal scale.
I think the correct statement of the problem specifies that the ladders have lengths 30 and 40 metres respectively, which would make the problem solvable.
I think only one ladder is hitting the corner at the bottom, not both. Otherwise this build situation wouldn't be possible.
Here is how I see it, correct me if I'm wrong:
Must've typed it out wrong :/
Work has me dead-tired ATM.
One ladder is 30 m long, the other is 20 m long. The other case shows, that if such a construction is possible, 7/12 = 1, which clearly isn't true.
"We observe the behaviour of simple folk, and derive pleasure from their defects."
-Aristotle - Book of Humour
I'm sure you've all heard the tired old brain teaser about accurately measuring 4 gallons with two irregularly shaped containers measuring 3 gallons and 5 gallons, respectively.
So, here's an interesting generalization:
You have two irregularly shaped containers, measuring a and b gallons, respectively. Which numbers x can you measure? What is the minimal number of steps required to measure x? For a given x, which pairs a and b are "the worst," that is, they require more steps to measure x than all pairs before them?
This sounds similar to something I just learned in number theory yesterday. For the case in which the numbers are integers, you can write a linear equation ai + bj = x, i.e., x is a linear combination of a and b. This only has solutions if x is divisible by GCD(a, b). I'm not sure if I know enough yet to be able to answer the other questions, so I'll let someone else have a go.
I'm sure you've all heard the tired old brain teaser about accurately measuring 4 gallons with two irregularly shaped containers measuring 3 gallons and 5 gallons, respectively.
So, here's an interesting generalization:
You have two irregularly shaped containers, measuring a and b gallons, respectively. Which numbers x can you measure? What is the minimal number of steps required to measure x? For a given x, which pairs a and b are "the worst," that is, they require more steps to measure x than all pairs before them?
The largest value you can't make is (a-1)b - a where a and b are coprime and a < b.
If a and b are not coprime then there's always values you can't make.
This isn't what you asked, but interesting nonetheless.
Build a man a fire, warm him for a day,
Set a man on fire, warm him for the rest of his life.
Do we have to post problems that have already been solved? I'd love for someone to solve the Collatz conjecture, since it seems so easy.
Hmm, no one has solved the problem I recently posted, so I guess we don't have to post problems that have already been solved at all! Let me know when you have an answer to the third question, smarty pants. (If your immediate instinct was to say for x=1 the worst pairs are consecutive fibonacci numbers, I know what you're thinking, but your instinct is wrong!)
This problem was posted a really long time ago, but I figured it wouldn't hurt to dig it up again:
Gorash wrote:
Write the shortest program that reads space separated arguments from STDIN and prints all permutations of that list on STDOUT.
Shortest means in byte of sourcecode.
Using packages that do it for you is not allowed of course.
Example:
program < echo 1 2 3
should print:
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
in this or another order.
I don't know about other languages, but it's a funny thing in perl...
Gorash wrote:
Here is my current minimum:
-nal
sub p{@_?map{my$e=$_;map[$e,@$_],p(grep{$e ne$_}@_)}@_:0}map{print"@$_"}p@F
I originally wrote a solution in Scheme, which wasn't very short at all (175 bytes or so), but I've recently gotten into Python one-lining, so I decided to give it another shot.
def f(n,v=[]):
if[f([j for j in n if j!=i],v+[i])for i in n]==n:print v
Usage: >>> f(list)
4 bytes shorter including line break and indentation ;)
-nal
sub p{@_?map{my$e=$_;map[$e,@$_],p(grep{$e ne$_}@_)}@_:0}map{print"@$_"}p@F
def f(n,v=[]):
if[f([j for j in n if j!=i],v+[i])for i in n]==n:print v
Usage: >>> f(list)
4 bytes shorter including line break and indentation ;)
I don't know Python (don't like the concept of indenting as block syntax), so how do you actually use this from command line? Note how the perl version also does the parsing of arguments and intial invocation of the recursion.
xebra: Post the mathematica version if you like, but the challenge to do it without a package to do it for you still applies. ;)