2

I'm trying to create a programm that has the ability to calculate the most effective way of breaking down the number of stamps (3 and 5 cent) necessary for a consignment. That is - if a transmission costs, for example, 11 cents, it would take one 5 cent stamp and two 3 cent stamps. The minimum price for a transmission is 8 cents.

Can you please help me come across on how to calculate that?

Thank you.

EDIT: Strong inducti0n with 3- and 5-peso notes and can pay any number greater than 7.

Xeen
  • 121
  • You would also need 1 and 2 cents stamp for your program to work efficiently! – MonK Jul 06 '14 at 12:29
  • @Sid nope, that is not necessary as in my situation if, for example, the transimission would cost 12 cents, it would take two 5 cent stamps and one 3 cent stamp. – Xeen Jul 06 '14 at 12:31
  • $5+3$ if I properly understood the strategy. – Claude Leibovici Jul 06 '14 at 12:33
  • What if it costs 7 cents. There are values that cannot be reached with these values. – Mathmo123 Jul 06 '14 at 12:33
  • $5+3$ again. The problem starts to be interesting. What do we want to do ? Minimize the loss because only two kinds of stamps ? – Claude Leibovici Jul 06 '14 at 12:35
  • You can't reach 12 with 5 and 3.5*2+2=12. – MonK Jul 06 '14 at 12:36
  • @Mathmo123 I just updated my post in regard to that. – Xeen Jul 06 '14 at 12:37
  • @ClaudeLeibovici that's correct, and I can't figure out how to pull this one off :) – Xeen Jul 06 '14 at 12:37
  • @Sid there is no need to get precisely 12, it should make a total of 12 or more, if that's what it takes, but no less. And, of course, it should have as little over the 12 as possible hence the 2x5+3 in my example – Xeen Jul 06 '14 at 12:38
  • Isn't 12 = 4 * 3 ? – Tom Collinge Jul 06 '14 at 12:43
  • Oops! Right ...I am sorry.I can reach 12:) – MonK Jul 06 '14 at 12:45
  • Here are possible transaction that you can reach. The need is to crack this sequence : $8,9,10,11,12,13,15,18,20,23,24,25....$ – MonK Jul 06 '14 at 12:49
  • @Sid that's right and I've been trying to do that for the last 2 days or so with no success :) – Xeen Jul 06 '14 at 12:50
  • See this question for proof ANY n > 7 can be sum of fives and threes. – Tom Collinge Jul 06 '14 at 12:50
  • @TomCollinge I'm not sure I understood what you meant by that – Xeen Jul 06 '14 at 12:53
  • 1
    There seems to be some debate on what quantities can be represented as such a sum - answer is any > 7. You still have to determine how to do this optimally.http://math.stackexchange.com/questions/256642/strong-inducti0n-with-3-and-5-peso-notes-and-can-pay-any-number-greater-than-7 (helps if I put the link in !) – Tom Collinge Jul 06 '14 at 12:54
  • Yes, that is correct. – Xeen Jul 06 '14 at 12:55
  • Hey @Xeen look at the solution to this question. http://math.stackexchange.com/questions/102222/strong-mathematical-induction-why-more-than-one-base-case. – MonK Jul 06 '14 at 13:16

2 Answers2

1

Since you are using a program and we know that some such combination exists, start with the number of 5's that are equal or greater than the required quantity. If equal then you are done, otherwise reduce the fives by 1 and if the difference is a multiple of three you are done.

Repeat this process until you get a match.

Result maximises the number of fives and therefore minimises total number of stamps.

Tom Collinge
  • 7,981
  • 25
  • 59
0

Maybe a linear program helps:

$Min \ \ c-3x-5y$

$3x+5y \geq c$

$x,y \in \mathbb N_0$

With this program you can minimize the loss.

greetings,

calculus

callculus42
  • 30,550