Skip to main content
deleted 779 characters in body
Source Link
frosqh
  • 341
  • 1
  • 7

Python 3, 8989 86 bytes

-2 thanks to Mr. Xcoder.

-3 inspiring from Asone Tuhid answer's.

lambda a,b:[i for i in rangesum(a,b)if sum(map(int,str(i)[:-3]))==sum==2*sum(map(int,str(i)[-3:]))]for i in range(a,b+1))

Try it online!

The range is half-open. The output numbers does not contains leading zeros.

Some tests Tests results :

Example 1 : 
a = 10000
b = 11001
Lucky numbers : [1001, 1010]1 

Example 2 : 
a = 2000100000
b = 2100200000
Lucky numbers : [2002, 2011, 2020]5280 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : [222006, 222015, 222024, 222033, 222042, 222051, 222060] 

To count lucky numbers, also in 89 bytes :

lambda a,b:sum([sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))for i in range(a,b)])

Try it online!

Tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : 2 

Example 2 :  
a = 2000 123456
b = 2100654321
Lucky numbers : 331607 

Example 3 : 
a = 2220000
b = 222100999999
Lucky numbers : 755252 

Try it online!

Python 3, 89 bytes

lambda a,b:[i for i in range(a,b)if sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))]

Try it online!

The range is half-open. The output numbers does not contains leading zeros.

Some tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : [1001, 1010] 

Example 2 : 
a = 2000
b = 2100
Lucky numbers : [2002, 2011, 2020] 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : [222006, 222015, 222024, 222033, 222042, 222051, 222060] 

To count lucky numbers, also in 89 bytes :

lambda a,b:sum([sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))for i in range(a,b)])

Try it online!

Tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : 2 

Example 2 :  
a = 2000 
b = 2100
Lucky numbers : 3 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : 7 

Python 3, 89 86 bytes

-2 thanks to Mr. Xcoder.

-3 inspiring from Asone Tuhid answer's.

lambda a,b:sum(sum(map(int,str(i)))==2*sum(map(int,str(i)[-3:]))for i in range(a,b+1))

Tests results :

Example 1 : 
a = 0
b = 1
Lucky numbers : 1 

Example 2 : 
a = 100000
b = 200000
Lucky numbers : 5280 

Example 3 : 
a = 123456
b = 654321
Lucky numbers : 31607 

Example 3 : 
a = 0
b = 999999
Lucky numbers : 55252 

Try it online!

added 765 characters in body
Source Link
frosqh
  • 341
  • 1
  • 7

Python 3, 89 bytes

lambda a,b:[i for i in range(a,b)if sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))]

Try it online!

The range is half-open. The output numbers does not contains leading zeros.

Some tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : [1001, 1010] 

Example 2 : 
a = 2000
b = 2100
Lucky numbers : [2002, 2011, 2020] 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : [222006, 222015, 222024, 222033, 222042, 222051, 222060] 

To count lucky numbers, also in 89 bytes :

lambda a,b:sum([sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))for i in range(a,b)])

Try it online!

Tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : 2 

Example 2 :  
a = 2000 
b = 2100
Lucky numbers : 3 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : 7 

Python 3, 89 bytes

lambda a,b:[i for i in range(a,b)if sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))]

Try it online!

The range is half-open. The output numbers does not contains leading zeros.

Some tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : [1001, 1010] 

Example 2 : 
a = 2000
b = 2100
Lucky numbers : [2002, 2011, 2020] 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : [222006, 222015, 222024, 222033, 222042, 222051, 222060] 

Python 3, 89 bytes

lambda a,b:[i for i in range(a,b)if sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))]

Try it online!

The range is half-open. The output numbers does not contains leading zeros.

Some tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : [1001, 1010] 

Example 2 : 
a = 2000
b = 2100
Lucky numbers : [2002, 2011, 2020] 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : [222006, 222015, 222024, 222033, 222042, 222051, 222060] 

To count lucky numbers, also in 89 bytes :

lambda a,b:sum([sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))for i in range(a,b)])

Try it online!

Tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : 2 

Example 2 :  
a = 2000 
b = 2100
Lucky numbers : 3 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : 7 
Source Link
frosqh
  • 341
  • 1
  • 7

Python 3, 89 bytes

lambda a,b:[i for i in range(a,b)if sum(map(int,str(i)[:-3]))==sum(map(int,str(i)[-3:]))]

Try it online!

The range is half-open. The output numbers does not contains leading zeros.

Some tests results :

Example 1 : 
a = 1000
b = 1100
Lucky numbers : [1001, 1010] 

Example 2 : 
a = 2000
b = 2100
Lucky numbers : [2002, 2011, 2020] 

Example 3 : 
a = 222000
b = 222100
Lucky numbers : [222006, 222015, 222024, 222033, 222042, 222051, 222060]