Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

2 of 8
added an alternate version
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

#JavaScript (ES6), 74 bytes

Returns a list of non-wrapping integers.

n=>(g=(u,v=1)=>n?(n--,u)&-u^v?g(u,v*2):g(u+1,1):v?[u-v,...g(u,v-1)]:[])(1)

Try it online!


#JavaScript (ES6), 110 bytes

Returns wrapping uppercase letters.

n=>(g=(u,v=1,s=i='')=>(s+=String.fromCharCode(65+i++%26),n--)?u&-u^v?g(u,v*2,s):g(u+1,1,s):s.substr(u-v,v))(1)

Try it online!

Or 104 bytes if lowercase is acceptable.

Based upon a construction by Donald Knuth. Related OEIS entry: A182105.

Arnauld
  • 205.5k
  • 21
  • 187
  • 670

AltStyle によって変換されたページ (->オリジナル) /