Quantcast
Channel: Time to settle this: Java vs C++ - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 6

Answer by GammaFunction for Time to settle this: Java vs C++

$
0
0

Zsh -oextendedglob, 82 69 51 bytes

<<<${1//(#m)(_?|[A-Z])/${${MATCH[2]:u}:-_$MATCH:l}}

Try it online! Try it online! Try it online!

Even if the flags count toward byte count, adding 14 bytes for -oextendedglob still undercuts the 82 byte program!

<<<${1//(#m)(_?|[A-Z])/${${MATCH[2]:u}:-_$MATCH:l}}
   ${1//              /                           }  # replacement
        (#m)                                         # enable $MATCH parameter
            (_?|[A_Z])                               # "?" matches any character
                         ${MATCH[2]:u}               # substitute 2nd char, uppercased
                       ${             :-_$MATCH:l}   # if empty, substitute "_" and lowercased match
<<<                                                  # print to stdout

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>