We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In the code you provided, the mistake lies in reusing the variable name tot for two different purposes within the same scope. This leads to incorrect results in the output.
The mistake was in using tot as both the total number of inputs and the count of digits to be subtracted (totalCount). By reusing the same variable, the value of tot was being overwritten, leading to incorrect calculations. I've renamed the variable that holds the total count of digits to totalCount to avoid this issue.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #172: Investigating numbers with few repeated digits
You are viewing a single comment's thread. Return to all comments →
In the code you provided, the mistake lies in reusing the variable name tot for two different purposes within the same scope. This leads to incorrect results in the output.
The mistake was in using tot as both the total number of inputs and the count of digits to be subtracted (totalCount). By reusing the same variable, the value of tot was being overwritten, leading to incorrect calculations. I've renamed the variable that holds the total count of digits to totalCount to avoid this issue.