Notices
General NON-Automotive Conversation No Political, Sexual or Religious topics please.

Java helppppppppppppp

Thread Tools
 
Search this Thread
 
Old Oct 24, 2005 | 03:22 PM
  #1  
Red Star's Avatar
Red Star
Thread Starter
|
Posting Guru
Joined: Jul 2005
Posts: 1,832
Likes: 0
Java helppppppppppppp

There is gotta be somebody here who knows how to solve this.

Here is original problem. I have to find out total number of bars.
"3 outlaws have stolen a stagecoach shipment of gold bars. they escape to their hideout and agree to divide up the loot in the morning. however, as soon as one of the bandits hears the others snoring, he decides to biry his one-third of the loot for safe-keeping. after dividing the bars into 3 equal piles, he discovers that there is 1 extra bar left, which he adds to his pile, and buries it. the remaining two piles are merged back into one pile, so the others won't notice the missing gold bars.
in turn, the other two outlaws awake, each while the other two are sleeping, and also divide the remaining loot into thirds and discovers one extra gold bar which they add to their own pile and stash away for safe keeping. in the morning, the outlaws proceed to divide up the remaining gold bars and discover that there is, once again, 1 gold bar left over."

This is what I got so far (link below), I think its correct ... but I'm stuck.

http://img373.imageshack.us/img373/8625/untitled3ro1.jpg
 
Reply
Old Oct 24, 2005 | 03:49 PM
  #2  
Greywolf's Avatar
Greywolf
Fleet Owner
Joined: Aug 2001
Posts: 29,941
Likes: 46
From: Drummonds, TN USA
Dunno about the java, but thinking about it deconstructively:

3 bars + 1 extra is four.
4 times 1.5 would be 6, add one and you have 7
7 by 1.5 is a fraction...

(9 + 1) = 10 x 1.5 = (15 +1) = 16 x 1.5 = (24 + 1) = 25 x 1.5 is a fraction... (NULL result)

(12 + 1) = 13 which would not work...

(15 + 1) = 16 which would not work...

(18 + 1) does not work...

(27 + 1) = 28 x 1.5 = (42 +1) =43 x 1.5 is a fraction...

(30 + 1) = 31 does not work...

(33 + 1) = 34 x 1.5 = (51 + 1) = 52 x 1.5 = (78 + 1) = 79 x 1.5 is a fraction...

I don't know how far I want to follow that out, but somehow I think it can be expressed in JAVA to accomplish the result. (I skipped some stages that were apparent in earlier "runs".)

Each pile to be divided is in brackets, I'm sure I goofed on at least one stage - but the java would likely run it (successive incremented numbers) anyway

It would have to run out to four divisions and stop
 

Last edited by Greywolf; Oct 24, 2005 at 04:02 PM.
Reply
Old Oct 24, 2005 | 05:47 PM
  #3  
pitrow's Avatar
pitrow
Elder User
Joined: Mar 2005
Posts: 878
Likes: 0
From: Cornelius, Oregon
I'd say you're pretty close, but shouldn't the second and third bandit be:

left = left - (bars/3 + 1)

Instead of

left = bars - (bars/3 + 1)

Otherwise your always subtracting from the total amount of bars, not what the previous bandit left.

edit: I don't know much about Java, does / give you integer values, or will it return a decimal?
 

Last edited by pitrow; Oct 24, 2005 at 05:51 PM.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
tvh2003
General NON-Automotive Conversation
17
Apr 1, 2008 03:15 PM
andym
General NON-Automotive Conversation
9
Apr 9, 2007 10:00 PM
christop43
General NON-Automotive Conversation
25
Mar 11, 2003 01:06 PM




All times are GMT -5. The time now is 12:37 PM.

story-0
10 Ways Ford is LOSING to the Competition

Slideshow: 10 ways Ford is losing to the competition

By Joe Kucinski | 2026-06-15 09:52:01


VIEW MORE
story-1
Top 6 Best Deals Available on New Fords & Lincolns Right Now

Some great targets in today's expensive world.

By Brett Foote | 2026-06-15 09:35:19


VIEW MORE
story-2
This Hennessey Takes the Expedition Tremor's Off-Roading Capability to the Next Level

Slideshow: The VelociRaptor Expedition gains a lift, upgraded suspension, Brembo brakes, and trail-ready equipment while retaining the stock 440-horsepower EcoBoost V6.

By Verdad Gallardo | 2026-06-12 11:01:55


VIEW MORE
story-3
Top 10 Fords at 2026 Carlisle Ford Nationals

Slideshow: Top 10 Fords at 2026 Ford Nationals

By Joe Kucinski | 2026-06-09 11:10:08


VIEW MORE
story-4
3 Best / 3 Worst Parts of Modern Ford Ownership

Based on years of owning multiple modern Ford products.

By Brett Foote | 2026-06-09 10:53:36


VIEW MORE
story-5
10 Amazing Upgrades That Solve Common Ford Truck Owner Headaches

SPONSORED: From muddy boots to rain-soaked cargo, these upgrades address some of the most common frustrations Ford truck owners face every day.

By Pouria Savadkouei | 2026-06-08 18:50:34


VIEW MORE
story-6
Every 2026 Ford Engine Explained

Here's everything you need to know about every Ford engine available for the 2026 model year.

By Brett Foote | 2026-06-05 12:58:01


VIEW MORE
story-7
10 Ugly Ford Trucks That We Still Kinda Love

Slideshow: 10 ugly Ford trucks that we still kinda love.

By Joe Kucinski | 2026-06-03 09:51:16


VIEW MORE
story-8
10 Things Every Truck Owner NEEDS (2026 Edition)

Slideshow: the best gifts for dads & grads

By Michael S. Palmer | 2026-06-03 15:43:58


VIEW MORE
story-9
Rezvani's Latest Post-Apocalyptic Monster Is a Ford F-150 Raptor Underneath

Slideshow: Called the Fortress, the 850-horsepower pickup combines Raptor underpinnings with military-inspired features, survival equipment, and a starting price of $285,000.

By Verdad Gallardo | 2026-06-03 11:38:36


VIEW MORE