Once in a tram: Hackerrank
Once in a tram : One day, Jack was going home by tram. When he got his ticket, he noticed that number on the ticket was not lucky. A lucky ticket is a six-digit number on the ticket in which sum of the first three digits is equal to the sum of the last three digits.
For example, number
165912 is lucky because sum of , and .
Since the number on the ticket wasn’t lucky, Jack needs your help to find the next lucky ticket number.
For example, if Jack’s ticket number is
165901, then the next lucky ticket number is
Given Jack’s current ticket number, find and print the next lucky ticket number.
The first line contains an integer, , denoting the number on the ticket.
For the given input find and print the next lucky ticket number.
Sample Input 0
Sample Output 0
After the first lucky number is , where the sum of first three digits is equal to the sum of last three digits .
Brute force works here. Need to look for test scenarios. Need some logic to deduce.