Joined: 5/3/2004
Posts: 1203
JXQ, here's the question I started with. This might enable you to solve it: (Asked of one person while pointing to another): What would you say if I asked you if he was the random person?
JXQ
Experienced player (761)
Joined: 5/6/2005
Posts: 3132
Thanks for pointing me in the right direction! I was able to solve the problem. I'm going to give that second one a shot next week at work. Hopefully it will take a while, that way it will help the time pass :)
<Swordless> Go hug a tree, you vegetarian (I bet you really are one)
Player (36)
Joined: 9/11/2004
Posts: 2630
Not exactly a math problem but. This perl script is intended to cat exactly two files (passed as arguments) to stdout. However, it has a bug. This bug can be fixed by adding, changing, or deleting a single character. Fix the script.
$_='ngif';tr/\146\147\151\156/\126\122\107\101/;/(.{2})$/;$"=$';foreach${$&}(@{qq^$_^})
{${"$_\$#{$_}"}{${qq/\107\126/}}=q^\^^;}++$";foreach(keys%{qq#$`$&\$1#}){open(${$"},$_);(print)while<GV>;}
[Edit by Bisqwit: Added newlines to prevent the forum layout from breaking]
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Player (206)
Joined: 5/29/2004
Posts: 5712
That's a programming language?? v( O_o )>
put yourself in my rocketpack if that poochie is one outrageous dude
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Bag of Magic Food wrote:
That's a programming language?? v( O_o )>
Yep. Very compressed at that. Like, instead of "search input for occurances of 't' and replace them with 'u'", you say "s/t/u/g" or "tr/t/u".
Player (206)
Joined: 5/29/2004
Posts: 5712
Oh, extreme shorthand.
put yourself in my rocketpack if that poochie is one outrageous dude
Player (36)
Joined: 9/11/2004
Posts: 2630
Well, no. That's anything but shorthand. It's just compressed and squished and formed into a nuisance.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Player (36)
Joined: 9/11/2004
Posts: 2630
This year Mrs. Claus goaded Santa into losing some weight, so he told the Reindeer to take this year off. He loaded up a 1 pound toy for every child in the world (2 billion) into his Super Stretchable Santa BagTM, stretched and took off running. Assuming no force is lost to friction, even placement of households, Santa delivers gifts infinitely quickly once he arrives at the roof of the house. (Santa must come to a full and complete stop, otherwise he might mess up the Christmas Tree). Unfortunately Santa seems to have a problem with his metabolism. He converts his own mass directly into energy. Making it difficult to nigh impossible to lose weight. Assuming he begins the night as 150 kg, how heavy is he when he ends the night? Assuming one stop per household, each household has one child, and the houses are distributed uniformly across the surface area of the earth. (Don't worry about shortest path algorithm with 2 billion members (that's silly), assume he does a column from north pole to south pole, turns around and does the next.) Also, remember that Santa has all of Christmas eve to work with, (including Time Zones, (but the day is shorter in the southern hemisphere, so let's say he has 31 hours to work with))
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Skilled player (1827)
Joined: 4/20/2005
Posts: 2161
Location: Norrköping, Sweden
I'm probably doing this all wrong, but here's what I've come up with: The earth's surface area is about 5,1*10^8 square km. With 2 billion households with a child, this gives us about 4 children per square km. The distance between each household should be about 250 m (I'm really not sure if this is right, how do you measure the medium distance on a surface area if you know how many elements there are?). 250 m between every household and 2 billion households, he must travel about 500 billion meters. He has 31 hours to do this, so he must travel at a constant speed of about 4,48 * 10^6 m/s. I'm to tired to continue this as of now, but if no one points out that I'm way off, I'll continue these calculations tomorrow :) What I'm least sure of is whether or not the distance between each household is 250 m...
Player (36)
Joined: 9/11/2004
Posts: 2630
Santa must come to a full and complete stop at every house, Santa moves at relativistic speeds. And Santa's mass is constantly changing. For starters.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Skilled player (1827)
Joined: 4/20/2005
Posts: 2161
Location: Norrköping, Sweden
Crap, I fail at math and physics :) Well, I'll let one of you guys try to solve this, this was way harder than I first thought. Good luck!
Joined: 3/8/2004
Posts: 185
Location: Denmark
(I should've never gotten into this) Hmm... Interesting things to consider: The amount of force (~ energy) required to accelerate (and decelerate) santa x m/s escalates as his speed goes up, by a factor of gamma. He would have to first accelerate for half the distance between a house and the next, and then decellerate for the same distance, making this a question of how fast he would have to be going when viewed from the earth by a stationary observer on it when passing the halfway mark. Assuming 31 hours (111600 seconds) to make the deliveries, he would need to make a delivery every 0,0000558 seconds, leaving him half that to accelerate, and half to decelerate. The distance from house to house in this idealized world is the distance Randil stated, 250m. Therefore, the problem lies in determining how much energy a relativistic object would have to expend to cover the 125 m to the halfway mark in 0,0000279 seconds, with it's mass (energy) reserve dwindling at each house. Since relativity theory isn't something I've ever encountered on a mathematical basis, count me out of this one.
"We observe the behaviour of simple folk, and derive pleasure from their defects." -Aristotle - Book of Humour
Skilled player (1827)
Joined: 4/20/2005
Posts: 2161
Location: Norrköping, Sweden
Doesn't both time, mass and distance change quite drastically for an object moving at great speeds? With these variables in mind, as well as all the other stuff, makes this problem quite difficult ;) It seems to me like there are many variables to keep in mind. I will be interested to see the solution to this! PS: I would never have guessed that I was right when I said 250 m! ;)
Player (36)
Joined: 9/11/2004
Posts: 2630
Old puzzle, new twist: You work for the Secret Service, but are not particularly well respected. You were given sixteen coins, and told that two of them are counterfeit. The counterfeit coins either weigh less than or more than the other fourteen coins, and they both weigh the same amount. You also have a scale. Except this scale is triangle shaped and has three pans. (No one ever gives you the good equipment.) Unfortunately, the Secret Service is beholden to the Scale Industry Corporate Interests, and are forcing the Secret Service to pay them every time a scale is used by anyone. How many weighings are required to determine which two coins are false?
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Editor, Player (69)
Joined: 6/22/2005
Posts: 1050
Do both of the counterfeit coins have the same weight? Also, how does a triangular balance work?
Current Projects: TAS: Wizards & Warriors III.
Player (36)
Joined: 9/11/2004
Posts: 2630
Both are the same weight. The triangular balance works as if you put an equilateral triangle on a point fulcrum, and then put the coins on each corner.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Former player
Joined: 3/30/2004
Posts: 1354
Location: Heather's imagination
A minimum of 2 and a maximum of 6 should do it I think.
someone is out there who will like you. take off your mask so they can find you faster. I support the new Nekketsu Kouha Kunio-kun.
Player (36)
Joined: 9/11/2004
Posts: 2630
I have a minimum of 3 and a max of 6. How'd you get the 2?
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Former player
Joined: 5/3/2004
Posts: 366
4 piles of four, weigh the first three. Best case: they all weigh the same, hence they're all known good, both bad ones are in pile 4. Take two coins from pile 4 and a known good one. Weigh them. Best cases: both tested coins are the same.
Joined: 4/16/2005
Posts: 251
5 max is also possible. EDIT: Found algorithm for max 4 and proof that 4 is minimum. And I didn't see that you posted a perl riddle OmnipotentEntity. Will tackle that right on... :) EDIT2: A $ in the keys of the hash building loop solves it, but using the length of @ARGV... don't let enyone see that. ;) A challenge of my own: 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...
Former player
Joined: 3/30/2004
Posts: 1354
Location: Heather's imagination
Oh mine didn't take into account that you could weigh more than 3 coins at once. Edit: My minimum of 2 is, you weigh three coins and one is different. You take the two that are the same and set them aside, grab two others, and weigh compared to the different one. If they're the same the two you weighed first are the different ones.
someone is out there who will like you. take off your mask so they can find you faster. I support the new Nekketsu Kouha Kunio-kun.
Player (36)
Joined: 9/11/2004
Posts: 2630
A few loaded questions for the permutation question, does it matter how fast it runs? Does it matter if there are repeated members in the output list? Do we have to use strictures? And for the coin puzzle, care to post your solution? I can't reproduce it, I had gotten five a few days ago though.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Joined: 4/16/2005
Posts: 251
About the permutation: - I put it the way I read it on a forum about that matter: It should run on a GHz machine in less than 5 minutes and if it uses more than a couple of ten megs of ram something is wrong with your algorithm. - Never thought about members of the list being equal, but since it makes it a lot more complicated, lets say no, only true sets as input. - Strictures? like use strict? Waste of precious bytes if you ask me. A few additional things I can imagine to be nasty: - It should run on all architectures... not like that PI algorithm... ;) - Of course it should not store info in the name of the file, or eval$0 would be an upper boundary to almost everything. - compiler/interpreter switches count as part of the source About the weighing: Basic technique is bisection. Put an equal numer on each of the pans. Scale being in balance is easy, the bad ones are the rest. If the scale tips, two of the pans will be in balance, since the two bad ones can only be either in those two one each, or both in the rest of the coins. You have by that bisected your coins in a way, so that you know for sure that both will be in the same portion. Since in this the scale will always have at least two equal sides "to tip to one side" means the side that is different from the two equal ones. Notation: [10]:[6] = [5:5]:[5:1] - means, split your batch of 10 into two of five, and your batch of 6 into one of five, and one alone. 3(1):3(1) - means you've got two piles of three, where you know for sure that there's one bad in each of them. 3(1a):3(1a):3(1b2c):7(1b0c) - means that we've three possible cases. Either one each in the first two ones (a), one each in the last two ones (b), or both in the last pile of 3 (c). 5:5:5:1 - weigh all the underlined ones. Below, each time you weigh and the scale tips, it is assumed that you sort the two of equal weight first in the next notation, so if you weigh 3:3:3:7, and two are equal, the result is: 3(1a):3(1a):3(1b2c):7(1b0c) meaning you've got two batches of three with equal weight, one batch of three with different weight and 7 others. Interpretation of the other line noise, read above. Complete algorithm: 16 = 3:3:3:7. - balance: [3:3:3]:[7](2) = [9]:[2:2:2:1](2) -- 9:[2](1a):[2](1a):2(1b2c):1(1b0c) = 9:[1:1](1a):[1:1](1a):2(1b2c):1(1b0c) --- balance: [9:2:2]:[2(1b2c):1(1b0c)] = [13]:[1:1:1](2) --- no balance: Compare the two of equal weight to a known good one. Either those or the other two from the [2](1a):[2](1a) result. - no balance: 3(1a):3(1a):3(1b2c):[7](1b0c) = 3(1a):3(1a):3(1b2c):[3:3:1](1b0c) -- balance: 3:3:3(1a2b):3:3:1(1a0b) = [12]:[4](2) = [11:1]:[1:1:1:1](2), compare each two of them to a known good one. -- tips to first one: [3](1):[3](1):[3:3:3:1] = [1:1:1](1):[1:1:1](1):10, weigh both piles separately. -- tips to one of last: 3:3:3(1):3(1):3:1 = [1:1:1](1):[1:1:1](1):10, weigh both piles separately. I hope that's understandable...
Player (36)
Joined: 9/11/2004
Posts: 2630
Wow, that's really suprising. I understood it perfectly thanks. Here's an easy one for you physics buffs. I have a insulated cube with wire on the edges, every edge of the cube contains a 1 Ohm resistor. How much resitance is there from the bottom-front-right corner to the top-back-left corner? Still working on the permutation algorithm.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Joined: 4/16/2005
Posts: 251
Our physics teacher gave us that one over holidays in 12th grade... Have you gotten into the permutation yet? I managed to shave another 13 characters of my solution today. EDIT: and I posted bullshit above... you can't pipe an echo with <... correct line is of course: echo 1 2 3 | program