Post History
Perl 5, 47 bytes Reads code from stdin (trailing newline is optional). Writes result to stdout. perl -pE's/#\K..?$/$&$&$&/;/.{5}/||s/\w/$&$&/g' printf %s '#ACF' | perl -pE'...
#2: Post edited
# [Perl 5], 48 bytes- Reads code from stdin (trailing newline is optional). Writes result to stdout.
- ```
perl -pE's/#\K..?$/$&x 3/e;/#...$/&&s/\w/$&$&/g'- ```
- ```bash
- printf %s '#ACF' | perl -pE'
- # if one or two digits, triplicate
s/#\K..?$/$&x 3/e;# if three digits, double-up each/#...$/ && s/\w/$&$&/g- '
- ```
[Try it online!][TIO-mpsh6myp]- [Perl 5]: https://www.perl.org/
[TIO-mpsh6myp]: https://tio.run/##JY3RCoJAEEXf5yuWZvOhcsfU0G2pKMmXfkGICCuhdHGF@vo2dzvzcs/lwui6f64ssqE2A3tc@rY2Bni14aTg@uheWoHum3a4scl0mRsWbtlkwc8KDFVmvhYzImUNYXUSYseJBx@WUK0IhRCcgmCcvceWB3S3FiO2Zhh5APdO9h7A@OgsProDTFNnqWccFuV/WhRlCShz6VTKPJcSMMsyp5kHMFrGSbryf3wCPHhc80/fTg9N1xob6h8 "Perl 5 – Try It Online"
- # [Perl 5], 47 bytes
- Reads code from stdin (trailing newline is optional). Writes result to stdout.
- ```
- perl -pE's/#\K..?$/$&$&$&/;/.{5}/||s/\w/$&$&/g'
- ```
- ```bash
- printf %s '#ACF' | perl -pE'
- # if one or two digits, triplicate
- s/#\K..?$/$&$&$&/;
- # if only three digits, double-up each
- /.{5}/ || s/\w/$&$&/g
- '
- ```
- [Try it online!][TIO-mqbh6652]
- [Perl 5]: https://www.perl.org/
- [TIO-mqbh6652]: https://tio.run/##JY3dCoJAEIXv5ykWZ@uiH8dM0W2pKMmbXkGICEuhdHGFLqpXb3O379zMdzgwquzusUHWl7pn1blrSq2BF2tOEi5V@1ASVFc3/ZV5o0Wq2XzDvBk/SdBU6OnKnxBJowmLo@9vOfGxDUnyX/GH3u9h9XQl3YzBgK0YBg7AnZWdAzA8WAsPNoBRZC1yDMMs/0@zLM8BRSqsCpGmQgAmSWI1cQAGi3AZxe6PuwD3Dtv8r2@r@rpttJmrHw "Perl 5 – Try It Online"
#1: Initial revision
# [Perl 5], 48 bytes
Reads code from stdin (trailing newline is optional). Writes result to stdout.
```
perl -pE's/#\K..?$/$&x 3/e;/#...$/&&s/\w/$&$&/g'
```
```bash
printf %s '#ACF' | perl -pE'
# if one or two digits, triplicate
s/#\K..?$/$&x 3/e;
# if three digits, double-up each
/#...$/ && s/\w/$&$&/g
'
```
[Try it online!][TIO-mpsh6myp]
[Perl 5]: https://www.perl.org/
[TIO-mpsh6myp]: https://tio.run/##JY3RCoJAEEXf5yuWZvOhcsfU0G2pKMmXfkGICCuhdHGF@vo2dzvzcs/lwui6f64ssqE2A3tc@rY2Bni14aTg@uheWoHum3a4scl0mRsWbtlkwc8KDFVmvhYzImUNYXUSYseJBx@WUK0IhRCcgmCcvceWB3S3FiO2Zhh5APdO9h7A@OgsProDTFNnqWccFuV/WhRlCShz6VTKPJcSMMsyp5kHMFrGSbryf3wCPHhc80/fTg9N1xob6h8 "Perl 5 – Try It Online"
