aboutsummaryrefslogtreecommitdiff
path: root/challenge-195/deadmarshal/d/ch1.d
blob: b1c6252960856feb79ca990b0e0164e0a9d7895a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import std.stdio:writeln;

bool has_dups(int n)
{
  int[int] hash;
  while(n)
  {
    if(hash.require(n%10,0)) return true;
    hash[n%10] = 1;
    n /= 10;
  }
  return false;
}

int special_integers(int n)
{
  int count = 0;
  for(int i = 1; i <= n; ++i) if(!has_dups(i)) count++;
  return count;
}

void main()
{
  writeln(special_integers(15));
  writeln(special_integers(35));
}