<?xml version="1.0" encoding="windows-1252"?>
<node id="1012437" title="Golf for unique digits" created="2013-01-09 06:24:22" updated="2013-01-09 06:24:22">
<type id="115">
perlquestion</type>
<author id="785151">
Cody Fendant</author>
<data>
<field name="doctext">
&lt;p&gt;Inspired by the fact that 2013 is the first year since 1987 which has four unique digits, what's your best code to 
determine the number of unique digits in a number?
&lt;/p&gt;
&lt;p&gt;Here's what I ended up with, skipping the &lt;code&gt;%unique&lt;/code&gt; method:
&lt;/p&gt;
&lt;code&gt;
$y = 2013;
($y = join('',sort(split(//,$y)))) =~ tr/0-9//s;
print "unique digits: " .  length($y) . $/;

&lt;/code&gt;
&lt;p&gt;I'm sure there's something smarter.&lt;/p&gt;</field>
</data>
</node>
