Skip to content

Instantly share code, notes, and snippets.

@hostilefork
Created October 17, 2014 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hostilefork/c3ddbd812c699a501197 to your computer and use it in GitHub Desktop.
Save hostilefork/c3ddbd812c699a501197 to your computer and use it in GitHub Desktop.
how-many-numbers-with-length-n-with-k-digits-d-consecutively
// Test output for
// http://stackoverflow.com/questions/26421865/how-many-numbers-with-length-n-with-k-digits-d-consecutively/26426615
when N = 0 and K = 0 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 1 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 2 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 3 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 4 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 5 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 6 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 7 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 8 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 1 and K = 0 and D = 6:
Fast way gives 10
Slow way gives 10
when N = 1 and K = 1 and D = 6:
Fast way gives 1
Slow way gives 1
when N = 1 and K = 2 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 1 and K = 3 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 1 and K = 4 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 1 and K = 5 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 1 and K = 6 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 1 and K = 7 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 1 and K = 8 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 1 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 2 and K = 0 and D = 6:
Fast way gives 100
Slow way gives 100
when N = 2 and K = 1 and D = 6:
Fast way gives 19
Slow way gives 19
when N = 2 and K = 2 and D = 6:
Fast way gives 1
Slow way gives 1
when N = 2 and K = 3 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 2 and K = 4 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 2 and K = 5 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 2 and K = 6 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 2 and K = 7 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 2 and K = 8 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 2 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 3 and K = 0 and D = 6:
Fast way gives 1000
Slow way gives 1000
when N = 3 and K = 1 and D = 6:
Fast way gives 271
Slow way gives 271
when N = 3 and K = 2 and D = 6:
Fast way gives 19
Slow way gives 19
when N = 3 and K = 3 and D = 6:
Fast way gives 1
Slow way gives 1
when N = 3 and K = 4 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 3 and K = 5 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 3 and K = 6 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 3 and K = 7 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 3 and K = 8 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 3 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 4 and K = 0 and D = 6:
Fast way gives 10000
Slow way gives 10000
when N = 4 and K = 1 and D = 6:
Fast way gives 3439
Slow way gives 3439
when N = 4 and K = 2 and D = 6:
Fast way gives 280
Slow way gives 280
when N = 4 and K = 3 and D = 6:
Fast way gives 19
Slow way gives 19
when N = 4 and K = 4 and D = 6:
Fast way gives 1
Slow way gives 1
when N = 4 and K = 5 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 4 and K = 6 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 4 and K = 7 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 4 and K = 8 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 4 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 5 and K = 0 and D = 6:
Fast way gives 100000
Slow way gives 100000
when N = 5 and K = 1 and D = 6:
Fast way gives 40951
Slow way gives 40951
when N = 5 and K = 2 and D = 6:
Fast way gives 3691
Slow way gives 3691
when N = 5 and K = 3 and D = 6:
Fast way gives 280
Slow way gives 280
when N = 5 and K = 4 and D = 6:
Fast way gives 19
Slow way gives 19
when N = 5 and K = 5 and D = 6:
Fast way gives 1
Slow way gives 1
when N = 5 and K = 6 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 5 and K = 7 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 5 and K = 8 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 5 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 6 and K = 0 and D = 6:
Fast way gives 1000000
Slow way gives 1000000
when N = 6 and K = 1 and D = 6:
Fast way gives 468559
Slow way gives 468559
when N = 6 and K = 2 and D = 6:
Fast way gives 45739
Slow way gives 45739
when N = 6 and K = 3 and D = 6:
Fast way gives 3700
Slow way gives 3700
when N = 6 and K = 4 and D = 6:
Fast way gives 280
Slow way gives 280
when N = 6 and K = 5 and D = 6:
Fast way gives 19
Slow way gives 19
when N = 6 and K = 6 and D = 6:
Fast way gives 1
Slow way gives 1
when N = 6 and K = 7 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 6 and K = 8 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 6 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 7 and K = 0 and D = 6:
Fast way gives 10000000
Slow way gives 10000000
when N = 7 and K = 1 and D = 6:
Fast way gives 5217031
Slow way gives 5217031
when N = 7 and K = 2 and D = 6:
Fast way gives 544870
Slow way gives 544870
when N = 7 and K = 3 and D = 6:
Fast way gives 45991
Slow way gives 45991
when N = 7 and K = 4 and D = 6:
Fast way gives 3700
Slow way gives 3700
when N = 7 and K = 5 and D = 6:
Fast way gives 280
Slow way gives 280
when N = 7 and K = 6 and D = 6:
Fast way gives 19
Slow way gives 19
when N = 7 and K = 7 and D = 6:
Fast way gives 1
Slow way gives 1
when N = 7 and K = 8 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 7 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 8 and K = 0 and D = 6:
Fast way gives 100000000
Slow way gives 100000000
when N = 8 and K = 1 and D = 6:
Fast way gives 56953279
Slow way gives 56953279
when N = 8 and K = 2 and D = 6:
Fast way gives 6315481
Slow way gives 6315481
when N = 8 and K = 3 and D = 6:
Fast way gives 549739
Slow way gives 549739
when N = 8 and K = 4 and D = 6:
Fast way gives 46000
Slow way gives 46000
when N = 8 and K = 5 and D = 6:
Fast way gives 3700
Slow way gives 3700
when N = 8 and K = 6 and D = 6:
Fast way gives 280
Slow way gives 280
when N = 8 and K = 7 and D = 6:
Fast way gives 19
Slow way gives 19
when N = 8 and K = 8 and D = 6:
Fast way gives 1
Slow way gives 1
when N = 8 and K = 9 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 9 and K = 0 and D = 6:
Fast way gives 1000000000
Slow way gives 1000000000
when N = 9 and K = 1 and D = 6:
Fast way gives 612579511
Slow way gives 612579511
when N = 9 and K = 2 and D = 6:
Fast way gives 71743159
Slow way gives 71743159
when N = 9 and K = 3 and D = 6:
Fast way gives 6394870
Slow way gives 6394870
when N = 9 and K = 4 and D = 6:
Fast way gives 549991
Slow way gives 549991
when N = 9 and K = 5 and D = 6:
Fast way gives 46000
Slow way gives 46000
when N = 9 and K = 6 and D = 6:
Fast way gives 3700
Slow way gives 3700
when N = 9 and K = 7 and D = 6:
Fast way gives 280
Slow way gives 280
when N = 9 and K = 8 and D = 6:
Fast way gives 19
Slow way gives 19
when N = 9 and K = 9 and D = 6:
Fast way gives 1
Slow way gives 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment