Skip to main content
added 101 characters in body
Source Link
AZTECCO
  • 10.9k
  • 1
  • 15
  • 58

Haskell, 7070 69 bytes

[x|x<-filter(0#)[0..],0#x]
a#x=a!divMod x 10
a!(d,m)|d<1=a==m|c<-a-m+1=m<=a&&c#d

Try it online!Try it online!

  • k is an infinite sequence

    Thanks to @Unrelated String for saving 1 by using filter instead of list comprehension.

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1

Haskell, 70 bytes

[x|x<-[0..],0#x]
a#x=a!divMod x 10
a!(d,m)|d<1=a==m|c<-a-m+1=m<=a&&c#d

Try it online!

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1

Haskell, 70 69 bytes

filter(0#)[0..]
a#x=a!divMod x 10
a!(d,m)|d<1=a==m|c<-a-m+1=m<=a&&c#d

Try it online!

  • Thanks to @Unrelated String for saving 1 by using filter instead of list comprehension.

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1
deleted 2 characters in body
Source Link
AZTECCO
  • 10.9k
  • 1
  • 15
  • 58

Haskell, 7170 bytes

[x|x<-[0..],0#x]
a#x=a!divMod x 10
a!(d,m)|d<1=a==m|1>0=m<=a&&(|d<1=a==m|c<-a-m+1)#dm+1=m<=a&&c#d

Try it online!Try it online!

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1

Haskell, 71 bytes

[x|x<-[0..],0#x]
a#x=a!divMod x 10
a!(d,m)|d<1=a==m|1>0=m<=a&&(a-m+1)#d

Try it online!

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1

Haskell, 70 bytes

[x|x<-[0..],0#x]
a#x=a!divMod x 10
a!(d,m)|d<1=a==m|c<-a-m+1=m<=a&&c#d

Try it online!

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1
added 7 characters in body
Source Link
AZTECCO
  • 10.9k
  • 1
  • 15
  • 58

Haskell, 7671 bytes

[x|x<-[0..],0#x]
a#x=a!divMod x 10
a!(d,m)|d<1=a-m|m<=a=|d<1=a==m|1>0=m<=a&&(a-m+1)#d|1>0=1
k=[x|x<-[0..],0==0#x]#d

Try it online!Try it online!

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1

Haskell, 76 bytes

a#x=a!divMod x 10
a!(d,m)|d<1=a-m|m<=a=(a-m+1)#d|1>0=1
k=[x|x<-[0..],0==0#x]

Try it online!

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1

Haskell, 71 bytes

[x|x<-[0..],0#x]
a#x=a!divMod x 10
a!(d,m)|d<1=a==m|1>0=m<=a&&(a-m+1)#d

Try it online!

  • k is an infinite sequence

We start from the end checking if the last digit(m) doesn't consume more groups than available a a-m>=0

Then we remove m groups and add 1 a=a-m+1 and move backwards.

At the end we must have exactly one group a-m+1==1

3010200  
      m  a   a=a-m+1
      0  0   1 
     0   1   2
    2    2   1
   0     1   2
  1      2   2
 0       2   3
3        3   1
Fixed error
Source Link
AZTECCO
  • 10.9k
  • 1
  • 15
  • 58
Loading
Source Link
AZTECCO
  • 10.9k
  • 1
  • 15
  • 58
Loading