Post History
If the challenge author does not specify otherwise, should an answer be required to work repeatedly? That is, is an answer allowed to be written in a way that saves bytes by only working the first ...
#1: Initial revision
Answers that work only once
If the challenge author does not specify otherwise, should an answer be required to work repeatedly? That is, is an answer allowed to be written in a way that saves bytes by only working the first time it is called? ## Example I wondered this after realising that an [existing JavaScript answer](https://codegolf.codidact.com/posts/293750/294028#answer-294028) could be shortened but that it would then only work the first time it is called. Code at the time of writing: ```js n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l} ``` Potential shorter version, which does not work a second time: ```js n=>{for(;n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l} ``` This saves 4 bytes by not initialising `l`. JavaScript works fine with an uninitialised `l`, but the value of `l` persists after the function returns, so that `l` is still holding the previous output next time the function is called, resulting in incorrect output on all subsequent calls.