about | help | code help+videos | done | prefs |
I came up with the idea for this problem when I was writing some numbers down at the same time the bell was ringing. Write a method that accepts a non-negative integer parameter and returns a string with "Ding" and "Ring" inserted between each digit in the number. If the number is only one digit long you simply return that number as a string. In all other cases, the "Ding" and "Ring" alternate in such a way that "Ding" is always the last word before the last digit of the number. Look at the test data for additional examples. I only needed 8 lines of code for this one, so don't make it more complicated than needed! I probably could have done it in even less lines but it may have become messy. Just think clearly and keep it simple! digitDingRing3(1010) → "1 Ding 0 Ring 1 Ding 0" digitDingRing3(5782) → "5 Ding 7 Ring 8 Ding 2" digitDingRing3(3) → "3" ...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: 300
Copyright Nick Parlante 2017 - privacy