Palantir Technologies Interview Question
109 Interview Reviews |
Back to all Palantir Technologies Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Business Development Engineer at Palantir Technologies:
Given a fleet of 50 trucks, each with a full fuel tank and a range of 100 miles, how far can you deliver a payload? You can transfer the payload from truck to truck, and you can transfer fuel from truck to truck. Extend your answer for n trucks.
| Tags: | analytical, analytical reasoning See more , See less 8 |
See more for this Palantir Technologies Business Development Engineer Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (20)
0 of 1 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
3 of 3 people found this helpful
After 2 miles you would transfer all of the fuel from one truck, and could fill all 49 of the other trucks. (100mile range / 50 trucks = 2 miles before the first truck could be emptied of all fuel and is not needed to carry any fuel) at that point you only have 49 trucks, so 100/49 is the distance before you park the second truck. After parking 49 trucks you would have one full truck of fuel that would finish the last 100 miles.
General solution for X trucks with Y range is Sum for n=1toX of [Y / (x-n)]
Helpful Answer?
Yes |
No
Inappropriate?
3 of 3 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
0 of 9 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
0 of 8 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
0 of 3 people found this helpful
Two trucks go 33 1/3 miles out and the second truck gives ½ of its remaining 2/3 of a tank to the other truck who parks and waits for the other truck to go back. It has enough fuel to return and comes back out with another truck who does the same thing but now we have two trucks 33 miles out and both with 2/3 of a tank or 66 2/3 miles of fuel remaining. With this method of inch worming and returning to refuel you can achieve a spacing of 33 1/3 miles between each truck and continue to refuel the entire chain. Only then once the entire refueling chain is stretched out to the range of 1666.66 miles you can have a truck be totally fueled 100% and then go either 50 more miles and still be theoretically able to return back to home base or 100 miles to sacrifice the truck for a delivery giving you a maximum range of (n + 1) * (1/3 of range) yielding a potential range of 1766 2/3 miles. You use a lot more fuel getting out to where you want to go but your range is increased well above the 400 miles range and the trucks aren’t lost.
Helpful Answer?
Yes |
No
Inappropriate?
0 of 2 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
0 of 1 people found this helpful
Wanna try again?
Helpful Answer?
Yes |
No
Inappropriate?
3 of 3 people found this helpful
The simplest solution involves recursion, or induction.
Imagine a function f(n) where f(n) is the distance n trucks can carry the load, the problem defines f(1)=100, and we're asked to solve for f(50), so our job is to solve for f(n) in terms of f(n-1), f(1) and n.
It's safe to assume each truck, including the fully loaded truck will travel the same distance and that fuel is used uniformly over the distance. So with n trucks, the trucks should travel just far enough that n-1 trucks have room in their tanks for the nth truck's fuel, then transfer an solve for n-1.
This equation is f(n) = f(1)/(n) + f(n-1)
(All perl vs python vs ruby/etc wars aside)
Plugging this into a simple scripting language such as perl is an easy way to solve this:
sub f{
my $n = shift;
return 100 if($n == 1);
return f(1)/($n) + f($n-1);
}
print "50: " . f(50) . "\n";'
On the command line, this gives a quick answer:
> perl -e 'sub f{ my $n = shift; return 100 if($n==1); return f(1)/($n) + f($n-1);} print "50: " . f(50) . "\n";'
50: 449.920533832942
Approximately 449.92 miles with 50 trucks.
The recursive subroutine above will suffice as a general solution in terms of n.
Helpful Answer?
Yes |
No
Inappropriate?
1 of 2 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
0 of 1 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
0 of 1 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
1 of 2 people found this helpful
Much of hte answer depends on what is or is not available in this crazy mad max world. Is there no more fuel in the world? Can the trucks refuel at the main depot? Is it okay to leave trucks parked on the side of the road? Sometimes the interviewers are asking about how you validate assumptions or deal with your own invalid assumptions of the world... normally not.
Of course the normal answer would be 50 or 45 miles range. Shifting loads and siphoning fuel is a pita.
The next answer would be get a CFN card and trusted drivers, then range is more limited by periodic maintenance i.e. oil changes.
Failing that, as was done during the 1970s oil crunch, get some 50 gallon drums and tie them up to the back of the headache bar. Each gallon of diesel weighs about 8 lbs, and can get you about 4 miles down the road. The united states is about 3000 miles wide. That takes about 6000 lbs of fuel. To get back another 6000. It's not very efficient, but you won't get stuck on the side of the road. due to fuel reasons.
But if you want a wanky CS answer. ( similar to JP's answer, but carrying it to stupidity).
With trucks returning to an infinitely fueled depot: ( my favorite extra world pieces).
By driving two trucks too 50 minus a smidgen miles. Park a truck with a driver in it, and it will have a smidgen of fuel in it. The other truck will keep making trips from 0 to 50 minus a little and transfer it's excess fuel to the parked truck. Eventually there is a fully fueled truck 50 (minus a little) miles from the depot. This chain can be extended one link at a time like some horrible towers of Hanoi problem. Finally you end up with a line of n-1 fully fueled trucks. This line alone stretches 2450 miles (minus 49 smidgens). The last truck in the line could round trip out to 2500. ( n * range/2)
After you have a row of fully fueled rucks 2450 miles long, there might be something funky you could do with it to extend the range. Truck 1 would have 1/2 a tank at the next truck, 25 miles into the second leg it could park and the second truck would then have a full tank at 75 miles from base, but not be able to return. Scale this up across the entire line of trucks. ... one short throw away perl script later... looks like that'll get you about another ~100 miles. so almost 2600 miles with parked empty trucks. Maybe a nonlinear spacing would be beter, not sure.. don't care really.
The fundamental answer is that most CS wanking stuff is often irrelevant in the real world. Money money money, cost cost cost. 50 trucks is somewhere in the piles of money range, quit wasting fuel.
Helpful Answer?
Yes |
No
Inappropriate?
1 of 1 people found this helpful
public class test
{
public static void main(String [] args)
{
int num=50;
double result=0;
for(double i=num;i>0;i--)
{
result=result+100/i;
}
System.out.println(result);
}
}
Helpful Answer?
Yes |
No
Inappropriate?
3 of 3 people found this helpful
Daren up top is definitely correct. I propose it's a little simpler than that.
It is just the summation of n=1 to n=50
for
100/n
Call the last truck the first truck, n=1. being full, it can go 100 miles.
when there are 2 trucks left, 50 miles
repeated down to the starting fleet of 50 trucks going 2 miles.
pretty sure using x-n doesn't bring the world down on itself, but it's unnecessary and makes that 49 to 0 error much easier to fall for.
Helpful Answer?
Yes |
No
Inappropriate?
A quick spreadsheet run shows the result as 449.92 miles. It's a horrible and pointless thing to ask this question in an interview without the help of a calculator or spreadsheet.
Helpful Answer?
Yes |
No
Inappropriate?
OR
Number_of_Trucks * Range = Maximum_Payload_Delivery_Distance
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up
5 of 6 people found this helpful
by Anonymous: