about | help | code help+videos | done | prefs |
Write a method that returns the sum of the digits in 'num', except that this sum is reset to zero every time the digit 'tripDigit' appears in the number. For example, if 'num' is 537281, and 'tripDigit' was 7, you would return 11. Adding the digits FROM LEFT TO RIGHT, you would add 5+3 to get 8, but then the next digit is 7, which is the 'tripDigit' so you would reset to zero, then add 2+8+1 to finally get 11. Look at the test data for other examples. test2025_04_17_SL_tripWire(4621273, 2) → 10 test2025_04_17_SL_tripWire(35232, 2) → 0 test2025_04_17_SL_tripWire(71248, 2) → 12 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy