• grue@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      19 days ago

      Code gulf, you say?

      public static String
      convertRomanNumeral(String numeral) {
          numeral = numeral.replace("America", "Mexico");
          return numeral;
      } 
      
    • dfyx@lemmy.helios42.de
      link
      fedilink
      arrow-up
      0
      ·
      19 days ago

      There could be a hidden quadratic cost because the string needs to be reallocated and copied multiple times.

          • Cethin@lemmy.zip
            link
            fedilink
            English
            arrow-up
            0
            ·
            18 days ago

            Recursion is amazing for a small selection of problems. Most of the time you don’t need, or want, it. When it is useful though, it tends to be really useful.

            I don’t understand people’s issue with it. I always found it easy. Maybe that’s why I feel this way. Maybe if you find it challenging you want to avoid it, even when it’s a good solution.

            • kamstrup@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              18 days ago

              Most devs I know like recursion. Trouble is that many popular languages don’t support tail recursion, but throw a stackoverflow error after a few thousand levels. So you have to keep track of max recursion depth manually, and it starts to look like a complicated solution