Login or Sign Up to become a member!
LessThanDot Site Logo

LessThanDot

A Technical Community for IT Professionals

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Highly Rated Users

Forum
No Posts Rated

Top 50
Given
Received

Forum Statistics

Users
Members:
1549
Members Online:
2
Guests Online:
1

Total Post History
Posts:
80403
Topics:
18392

7-Day Post History
New Posts:
14
New Topics:
3
Active Topics:
8

Our newest member
syed20

Other

FAQ
All times are UTC [ DST ]

Google Ads

LTD Puzzle 21: counting the money

Mind Boggling Puzzles, to keep that grey matter in shape...
Forum rules
Always post answers in a "Hidecode" tag, so that others have a chance to answer the question too.
Please wait...

LTD Puzzle 21: counting the money

Postby chrissie1 on Sat Feb 07, 2009 10:49 am

You should give all the possible combinations to pay for the given amount of money.

knowing that you have the following currency
1 chrissiecent
2 chrissiecent
5 chrissiecent
10 chrissiecent
20 chrissiecent
50 chrissiecent
1 chrissie
2 chrissie

also give the solution with the least amount of pieces.

Do this for the amounts from 1.00 to 10.00 increments of 0.01.
For higher numbers (>1) this will take a while to print so only give the number of possible solutions for them.

example output.

amountnumber of possible solutionssolution
0.0111 cc
0.0221 cc + 1cc, 2cc
0.0321 cc + 1cc + 1cc, 1cc + 2cc
.........
1...are you nuts?


You will as always be rewarded with praise and glory from the being called chrissie1.
pink fuzzy slippers
User avatar
chrissie1
Senior Guru
Senior Guru
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088
 
Posts: 9346
Joined: Wed Oct 10, 2007 7:18 pm
Location: Belgium

Re: LTD Puzzle 21: counting the money

Postby earthandfire on Mon Feb 09, 2009 10:21 am

I've not yet got the coin breakdowns working, however the available combinations produces some horrendous values.

Code is hidden, SHOW


Do you really want all 4000 or so possible solutions for 0.99cc1?

1cc = ChrissieCent and C = Chrissie

I'll post the code later
earthandfire
Senior Apprentice
Senior Apprentice
LTD Bronze - Rating: 63LTD Bronze - Rating: 63
 
Posts: 103
Joined: Sun Nov 25, 2007 6:07 pm
Unrated

Re: LTD Puzzle 21: counting the money

Postby chrissie1 on Mon Feb 09, 2009 10:29 am

Uhm, I guess not ;-). Not that it would hurt anyone. Unless everybody starts printing the results, that would really harm the penguins.

the first ten will do, just to show the algorithm is correct.
pink fuzzy slippers
User avatar
chrissie1
Senior Guru
Senior Guru
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088
 
Posts: 9346
Joined: Wed Oct 10, 2007 7:18 pm
Location: Belgium
Unrated

Re: LTD Puzzle 21: counting the money

Postby MHGlassman on Mon Feb 09, 2009 3:18 pm

Great puzzle, Chrissie, although I'm not sure you realized the scope of the solution set when you requested that we run the algorithm through 10 chrissies.

I can confirm the counts that earthandfire posted earlier. Below you'll find my code (in Visual FoxPro, easily converted to SQL) that creates and saves all the possible combinations of change. I'm not sure how earthandfire approached the problem, but I found it easier to work it as an 8 place (one for each coin or bill) counting function rather than to find all the combinations worth 1, 2, 3, 4, ..., 999, 1000 chrissiecents (in that order).

In addition to my code, I have listed the 49 combinations of change that total 10 chrissiecents or less, as well as the combination of the smallest number of coins or bills that total each amount from 1 chrissiecent through 2.00 chrissies.

Note that the code I used is not spcific to Chrissie's currency values. By altering the contents of CoinsBills and the value of nMaxToChange, one can determine the combinations of coins and bills that total any range of values, without altering the code. Monetary systems that don't use cents would require very minor modifications to the code.

The code:
Code is hidden, SHOW


The 49 combinations of change totalling up to 10 chrissiecents:
Code is hidden, SHOW


The smallest combinations of change totalling up to 2 chrissie:
Code is hidden, SHOW


Thanks for posing this puzzle. It made for a fun and challenging weekend.

Mike
"The trouble with quotes on the Internet is that it's 
difficult to determine whether or not they are genuine."
-- Abraham Lincoln
User avatar
MHGlassman
Senior Apprentice
Senior Apprentice
LTD Bronze - Rating: 115LTD Bronze - Rating: 115LTD Bronze - Rating: 115
 
Posts: 72
Joined: Tue Jun 17, 2008 7:58 pm
Location: Englewood, CO, USA

Re: LTD Puzzle 21: counting the money

Postby chrissie1 on Mon Feb 09, 2009 3:23 pm

A whole weekend, oops. Sorry.

I admit I didn't try it :blush: .
pink fuzzy slippers
User avatar
chrissie1
Senior Guru
Senior Guru
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088
 
Posts: 9346
Joined: Wed Oct 10, 2007 7:18 pm
Location: Belgium
Unrated

Re: LTD Puzzle 21: counting the money

Postby MHGlassman on Mon Feb 09, 2009 3:33 pm

No, it didn't take the whole weekend to program, but the fun lasted that long!!
(Sorry, that sounds like a chewing gum tag line.) :tssk:
"The trouble with quotes on the Internet is that it's 
difficult to determine whether or not they are genuine."
-- Abraham Lincoln
User avatar
MHGlassman
Senior Apprentice
Senior Apprentice
LTD Bronze - Rating: 115LTD Bronze - Rating: 115LTD Bronze - Rating: 115
 
Posts: 72
Joined: Tue Jun 17, 2008 7:58 pm
Location: Englewood, CO, USA
Unrated

Re: LTD Puzzle 21: counting the money

Postby earthandfire on Mon Feb 09, 2009 3:41 pm

I'm still working on the breakdown .....

The code for the combinations:

Code is hidden, SHOW


I've got to a meeting now so I wont be able to finish the breakdown calculations till I get home!
Last edited by earthandfire on Mon Feb 09, 2009 3:43 pm, edited 1 time in total.
earthandfire
Senior Apprentice
Senior Apprentice
LTD Bronze - Rating: 63LTD Bronze - Rating: 63
 
Posts: 103
Joined: Sun Nov 25, 2007 6:07 pm

Re: LTD Puzzle 21: counting the money

Postby chrissie1 on Mon Feb 09, 2009 3:42 pm

MHGlassman wrote:No, it didn't take the whole weekend to program, but the fun lasted that long!!
(Sorry, that sounds like a chewing gum tag line.) :tssk:


Fun costs money. That' ll be 50 chrissies than.
pink fuzzy slippers
User avatar
chrissie1
Senior Guru
Senior Guru
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088
 
Posts: 9346
Joined: Wed Oct 10, 2007 7:18 pm
Location: Belgium
Unrated

Re: LTD Puzzle 21: counting the money

Postby chrissie1 on Mon Feb 09, 2009 3:43 pm

earthandfire wrote:I'm still working on the breakdown .....

The code for the combinations:


What? No Modules? Have you gone soft on me (uhm, someday I'll rephrase that)?
pink fuzzy slippers
User avatar
chrissie1
Senior Guru
Senior Guru
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088
 
Posts: 9346
Joined: Wed Oct 10, 2007 7:18 pm
Location: Belgium
Unrated

Re: LTD Puzzle 21: counting the money

Postby earthandfire on Mon Feb 09, 2009 3:45 pm

You moan when I produce a solution in SQL, so I use VB. Now you want Modules.... I give up :)
earthandfire
Senior Apprentice
Senior Apprentice
LTD Bronze - Rating: 63LTD Bronze - Rating: 63
 
Posts: 103
Joined: Sun Nov 25, 2007 6:07 pm
Unrated

Re: LTD Puzzle 21: counting the money

Postby chrissie1 on Mon Feb 09, 2009 3:47 pm

earthandfire wrote:You moan when I produce a solution in SQL, so I use VB. Now you want Modules.... I give up :)



I'm trying to keep you on your toes. Somebody has to.
pink fuzzy slippers
User avatar
chrissie1
Senior Guru
Senior Guru
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088LTD Gold - Rating: 2088
LTD Gold - Rating: 2088LTD Gold - Rating: 2088
 
Posts: 9346
Joined: Wed Oct 10, 2007 7:18 pm
Location: Belgium
Unrated