human
Count total number of N digit numbers such that the difference between sum of even and odd digits is 1 | Memoization based recursive function to count numbers with even and odd digit sum difference as 1. This function considers leading zero as a digit.
Base Case.
If current subproblem is already computed.
Initialize result.
If the current digit is odd , then add it to odd sum and recur.
Add to even sum and recur.
Store current result in lookup table and return the same.
This is mainly a wrapper over countRec . It explicitly handles leading digit and calls countRec ( ) for remaining digits ..
Initialize number digits considered so far.
Initialize all entries of lookup table.
Initialize final answer.
Initialize even and odd sums.
Explicitly handle first digit and call recursive function countRec for remaining digits . Note that the first digit is considered as even digit.
Driver Code.
A lookup table used for memoization ."
Solution in Python:

What is a code to count total number of N digit numbers such that the difference between sum of even and odd digits is 1 and the other steps required?
assistant
#Here is code to count total number of N digit numbers such that the difference between sum of even and odd digits is 1 and the other steps required.
 def countRec ( digits , esum , osum , isOdd , n ) :
	if digits == n :
		return ( esum - osum == 1 )
	if lookup [ digits ] [ esum ] [ osum ] [ isOdd ] != - 1 :
		return lookup [ digits ] [ esum ] [ osum ] [ isOdd ]
	ans = 0
	if isOdd :
		for i in range ( 10 ) :
			ans += countRec ( digits + 1 , esum , osum + i , False , n )
	else :
		for i in range ( 10 ) :
			ans += countRec ( digits + 1 , esum + i , osum , True , n )
	lookup [ digits ] [ esum ] [ osum ] [ isOdd ] = ans
	return ans
def finalCount ( n ) :
	global lookup
	digits = 0
	lookup = [ [ [ [ - 1 , - 1 ] for i in range ( 500 ) ] for j in range ( 500 ) ] for k in range ( 50 ) ]
	ans = 0
	esum = 0
	osum = 0
	for i in range ( 1 , 10 ) :
		ans += countRec ( digits + 1 , esum + i , osum , True , n )
	return ans
if __name__ == " _ _ main _ _ " :
	lookup = [ ]
	n = 3
	print ( " Count ▁ of ▁ % d ▁ digit ▁ numbers ▁ is ▁ % d " % ( n , finalCount ( n ) ) )