How many 18-digit numbers n (without leading zeros) are there such that no digit occurs more than three times in n?
These problems are part of Project Euler and are licensed under CC BY-NC-SA 2.0 UK
http://projecteuler.net/problem=172