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

Java helppppppppppppp

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


Thread Tools
Search this Thread

All times are GMT -5. The time now is 02:07 PM.

story-0
Ford's 2001 Explorer Sportsman Concept Looks For a New Home

Slideshow: Ford's bizarre fishing-themed Explorer concept has resurfaced after spending decades largely forgotten.

By Verdad Gallardo | 2026-05-12 18:07:46


VIEW MORE
story-1
10 Best Ford Truck Engines We Miss the Most!

Slideshow: The 10 best Ford truck engines we miss the most.

By Joe Kucinski | 2026-05-12 13:09:47


VIEW MORE
story-2
2026 Shelby F-150 Off-Road: Better Than a Raptor R?

Slideshow: first look at the 810 hp 2026 Shelby F-150 Off-Road!

By Brett Foote | 2026-05-12 12:50:07


VIEW MORE
story-3
2027 Super Duty Carhartt Package First Look: 12 Things You NEED to Know!

Slideshow: Everything You Need to Know about the 2027 Super Duty Carhartt Package!

By Michael S. Palmer | 2026-05-07 17:51:06


VIEW MORE
story-4
10 Most Surprising 2026 Ford Truck Features!

Slideshow: 10 most surprising Ford truck options/features in 2026.

By Joe Kucinski | 2026-05-05 11:17:22


VIEW MORE
story-5
Top 10 Ford Trucks Coming to Mecum Indy 2026

Slideshow: Here are the top 10 Fords coming to Mecum Indy 2026.

By Brett Foote | 2026-05-04 13:49:49


VIEW MORE
story-6
5 Best / 5 Worst Ford Truck Wheels of All Time

Slideshow: The 5 best and 5 worst Ford truck wheels of all time

By Joe Kucinski | 2026-04-29 16:49:01


VIEW MORE
story-7
Ford Super Duty: 5 Things Owners LOVE, 5 Things They LOATHE!

Slideshow: Ranking the 5 things owners love about their Super Duty and 5 things they don't

By Joe Kucinski | 2026-04-29 16:36:49


VIEW MORE
story-8
Every 2026 Ford Truck Engine RANKED from WORST to FIRST!

Slideshow: Ranking all 12 Ford truck engines available in 2026.

By Michael S. Palmer | 2026-04-22 13:32:20


VIEW MORE
story-9
The Best F-150 Deal of Every Trim Level (XL through Raptor)

Slideshow: The best Ford F-150 deal for every trim level (XL through Raptor)

By Joe Kucinski | 2026-04-21 15:59:01


VIEW MORE