<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Code Challenge: Change Dispenser</title>
	<atom:link href="http://blog.stevenlevithan.com/archives/change-dispenser/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.stevenlevithan.com/archives/change-dispenser</link>
	<description>A JavaScript and regular expression centric blog</description>
	<lastBuildDate>Thu, 02 Feb 2012 02:09:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: lawrence</title>
		<link>http://blog.stevenlevithan.com/archives/change-dispenser/comment-page-1#comment-163232</link>
		<dc:creator>lawrence</dc:creator>
		<pubDate>Tue, 13 Dec 2011 11:59:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/?p=79#comment-163232</guid>
		<description>i used the top method and it worked. thank you, i have been looking for this html code for a while.</description>
		<content:encoded><![CDATA[<p>i used the top method and it worked. thank you, i have been looking for this html code for a while.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NEX-C3</title>
		<link>http://blog.stevenlevithan.com/archives/change-dispenser/comment-page-1#comment-155762</link>
		<dc:creator>NEX-C3</dc:creator>
		<pubDate>Thu, 17 Nov 2011 23:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/?p=79#comment-155762</guid>
		<description>I’m impressed!!! Really informative blog post here my friend. I just wanted to comment u0026 say keep up the quality work.</description>
		<content:encoded><![CDATA[<p>I’m impressed!!! Really informative blog post here my friend. I just wanted to comment u0026 say keep up the quality work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prestaul</title>
		<link>http://blog.stevenlevithan.com/archives/change-dispenser/comment-page-1#comment-85164</link>
		<dc:creator>Prestaul</dc:creator>
		<pubDate>Tue, 08 Mar 2011 22:24:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/?p=79#comment-85164</guid>
		<description>Does shorter and no &quot;var&quot; statements == better?  Probably not, but it was fun to slap together and I enjoy taking advantage of array methods whenever possible.

function makeChange(money) {
	return [
		[100, &#039;dollar&#039;],
		[25, &#039;quarter&#039;],
		[10, &#039;dime&#039;],
		[5, &#039;nickel&#039;],
		[1, &#039;penny&#039;, &#039;pennies&#039;]
	].reduce(function(state, coin, cnt) {
		if(cnt = (state.amount / coin[0]) ^ 0) {
			state.change.push(cnt + &#039; &#039; + (cnt &gt; 1 ? coin[2] &#124;&#124; coin[1] + &#039;s&#039; : coin[1]));
			state.amount %= coin[0];
		}
		return state;
	}, { amount: money * 100, change: [] }).change.join(&#039;, &#039;);
}</description>
		<content:encoded><![CDATA[<p>Does shorter and no &#8220;var&#8221; statements == better?  Probably not, but it was fun to slap together and I enjoy taking advantage of array methods whenever possible.</p>
<p>function makeChange(money) {<br />
	return [<br />
		[100, 'dollar'],<br />
		[25, 'quarter'],<br />
		[10, 'dime'],<br />
		[5, 'nickel'],<br />
		[1, 'penny', 'pennies']<br />
	].reduce(function(state, coin, cnt) {<br />
		if(cnt = (state.amount / coin[0]) ^ 0) {<br />
			state.change.push(cnt + &#8216; &#8216; + (cnt &gt; 1 ? coin[2] || coin[1] + &#8216;s&#8217; : coin[1]));<br />
			state.amount %= coin[0];<br />
		}<br />
		return state;<br />
	}, { amount: money * 100, change: [] }).change.join(&#8216;, &#8216;);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Vivenzio</title>
		<link>http://blog.stevenlevithan.com/archives/change-dispenser/comment-page-1#comment-32071</link>
		<dc:creator>John Vivenzio</dc:creator>
		<pubDate>Sat, 02 May 2009 06:27:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/?p=79#comment-32071</guid>
		<description>Obscure bug?

When testing just now I found if you enter makeChange(279.96 * 100) - it rounds to 27995.9999 when multiplied by 100 - very bizarre. ...using Firefox 3.5b4  - reminds me of the Pentium 59.999... days.</description>
		<content:encoded><![CDATA[<p>Obscure bug?</p>
<p>When testing just now I found if you enter makeChange(279.96 * 100) &#8211; it rounds to 27995.9999 when multiplied by 100 &#8211; very bizarre. &#8230;using Firefox 3.5b4  &#8211; reminds me of the Pentium 59.999&#8230; days.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Vivenzio</title>
		<link>http://blog.stevenlevithan.com/archives/change-dispenser/comment-page-1#comment-32070</link>
		<dc:creator>John Vivenzio</dc:creator>
		<pubDate>Sat, 02 May 2009 05:58:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/?p=79#comment-32070</guid>
		<description>Last One... with inventory of bills and coins and shows remainder if can&#039;t make exact change.

var b = [
// checkInventory to null out what&#039;s not available (on hand is b[i][1])
	[10000, 0, &quot;Hundred&quot;],
	[ 5000, 1, &quot;Fifty&quot;, &quot;Fifties&quot;],
	[ 2000, 0, &quot;Twenty&quot;, &quot;Twenties&quot;],
	[ 1000, 0, &quot;Ten&quot;],
	[  500, 0, &quot;Five&quot;],
	[  200, 0, &quot;Two&quot;],
	[  100, 0, &quot;Dollar&quot;],
	[   25, 0, &quot;quarter&quot;],
	[   10, 0, &quot;dime&quot;],
	[    5, 0, &quot;nickel&quot;],
	[    1, 0, &quot;penny&quot;, &quot;pennies&quot;],
	[    0]
];


function makeChange(money) {
    if (b[i][1] &amp;&amp; (x = Math.floor(money / b[i][0])))
        output.push(x + &quot; &quot; + (x &lt;= 1 ? b[i][2] : !b[i][3] ? b[i][2] + &quot;s&quot; : b[i][3]));
    return isNaN(b[i + 1]) ? makeChange(b[i][1] ? money % b[i++][0] : (i++, money)) : 
        output.push(&quot;Remainder: $&quot; + money / 100), output;
}

makeChange(123279.96 * 100).join(&quot;\n&quot;);</description>
		<content:encoded><![CDATA[<p>Last One&#8230; with inventory of bills and coins and shows remainder if can&#8217;t make exact change.</p>
<p>var b = [<br />
// checkInventory to null out what's not available (on hand is b[i][1])<br />
	[10000, 0, "Hundred"],<br />
	[ 5000, 1, "Fifty", "Fifties"],<br />
	[ 2000, 0, "Twenty", "Twenties"],<br />
	[ 1000, 0, "Ten"],<br />
	[  500, 0, "Five"],<br />
	[  200, 0, "Two"],<br />
	[  100, 0, "Dollar"],<br />
	[   25, 0, "quarter"],<br />
	[   10, 0, "dime"],<br />
	[    5, 0, "nickel"],<br />
	[    1, 0, "penny", "pennies"],<br />
	[    0]<br />
];</p>
<p>function makeChange(money) {<br />
    if (b[i][1] &amp;&amp; (x = Math.floor(money / b[i][0])))<br />
        output.push(x + &#8221; &#8221; + (x &lt;= 1 ? b[i][2] : !b[i][3] ? b[i][2] + &#8220;s&#8221; : b[i][3]));<br />
    return isNaN(b[i + 1]) ? makeChange(b[i][1] ? money % b[i++][0] : (i++, money)) :<br />
        output.push(&#8220;Remainder: $&#8221; + money / 100), output;<br />
}</p>
<p>makeChange(123279.96 * 100).join(&#8220;\n&#8221;);</p>
]]></content:encoded>
	</item>
</channel>
</rss>

