Credit card Verification Haskell Code

{- Convert positive integer to list of digit -}
{- Input : 12345 o/p : [1, 2, 3, 4, 5 -}
toList :: Integer -> [Integer]
toList 0 = []
toList x = toList (x `div` 10) ++ [x `mod` 10]

{- Reverse the integer after converting it to list -}
-- toDigitsRev :: Integer -> [Integer]
toListReverse :: Integer -> [Integer]
toListReverse xs = (reverse . toList) xs

{- Double every second number -}
doubleSecondEach :: [Integer] -> [Integer]
doubleSecondEach [] = []
doubleSecondEach (x:[]) = [x]
doubleSecondEach (x:y:xs) = x : (2*y) : doubleSecondEach xs

{- Sum the digit in the number we are sure there is one digit number or two digit number -}
sum' :: Integer -> Integer
sum' x = (x `mod` 10) + (x `div` 10)

{- sum all the element in list -}
{- when a element is [13,5,6] we have to add like this: 1 + 3 + 5 + 6 -}
sumDigits :: [Integer] -> Integer
sumDigits [] = 0
sumDigits [x] = sum' x
sumDigits (x:xs) = sum' x + sumDigits xs

{- Validate the credit card number -}
validate :: Integer -> Bool
validate x = if (sumDigits $ doubleSecondEach $ toListReverse x ) `mod` 10 == 0 then True else False

Fixing Google Play Games plugin and Unity integration error – Android

Recently i was having multiple issues with google play games plugin integration in Unity. It was not working at all. After spending the couple of hours in it, i was able to fix the issue. This is a note to myself as well for others who are having trouble with the integration.

I was using Admob plugin along with Google Play Games plugin. In the process of fixing the error i got different kinds of error. Some error was due to the import while some was due to the Authentication issues from the play game service. I will discuss about these both.

Continue reading Fixing Google Play Games plugin and Unity integration error – Android