Recent

Author Topic: Monkeys and coconuts: a challenge  (Read 8084 times)

marcio2003

  • Jr. Member
  • **
  • Posts: 56
Re: Monkeys and coconuts: a challenge
« Reply #15 on: May 01, 2015, 06:27:24 pm »
I am sorry for my previous posted code.
The solution is more simple than everything.
Have n solutions to solve easy way with:
Part_Per_Sailors( n ) = 1204 * n - 820
Amount_ Initial( n ) = 15625 * n - 12504
Is it the ultimate?
What's the next steep?
Code: [Select]
procedure TForm1.B1Click(Sender: TObject);
var
  n: integer;
begin
  StringGrid1.Cells[ 0, 0 ]:= 'Solution';
  StringGrid1.Cells[ 1, 0 ]:= 'AmountInitial';
  StringGrid1.Cells[ 2, 0 ]:= 'FinalQuote/Sailors';
  StringGrid1.AutoAdjustColumns;
  for n:= 1 to 10 do { Ten initial solutions }
  begin
    StringGrid1.Cells[ 0, n ]:= IntToStr( n );
    StringGrid1.Cells[ 1, n ]:= IntToStr( 15625 * n - 12504 );
    StringGrid1.Cells[ 2, n ]:= IntToStr( 1024 * n - 820 );
  end;
end;
Lazarus 2.0.10 Windows 10 64bits

Bart

  • Hero Member
  • *****
  • Posts: 4225
    • Bart en Mariska's Webstek

marcio2003

  • Jr. Member
  • **
  • Posts: 56
Re: Monkeys and coconuts: a challenge
« Reply #17 on: May 01, 2015, 06:32:21 pm »
I am sorry one more time:
Part_Per_Sailors( n ) = 1024 * n - 820
Lazarus 2.0.10 Windows 10 64bits

Eugene Loza

  • Hero Member
  • *****
  • Posts: 570
    • My "almost daily" development blog
Re: Monkeys and coconuts: a challenge
« Reply #18 on: May 02, 2015, 06:03:50 am »
Finally Q2:

Q = 15625*Ni + 3121; where Ni=0,1,2,3...
and
Q = 15625*Ni + 6246; for Q5

Got this by demanding 8 times both sides of the equation be even, i.e. N=2N`+1
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
https://decoherence.itch.io/
(and some ancient games in Turbo Pascal too)
Sources are here: https://github.com/eugeneloza?tab=repositories

 

TinyPortal © 2005-2018