# [APL (Dyalog APL)](https://www.dyalog.com/products.htm), 30 bytes Requires `⎕IO` to be `0`. ``` (+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)⊃1 ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m70qpTIxJz89PrEgZ8EWK7_E3NTigsTkVK5HfVM9_R-1TTBYWlqSpmtx00hDW8dCwdCsWgMo46IDJBw1ox_17nrUtfRR7-JD6w0fdS161Ls1tvbQCiBL81FXs-GS4qTk4psebkBTjIB8oJbgIGcgGeLhGcxVDWQAJR719mkAtR2e_qh3i5smiAAaYKj9qHezoYEBl5VrXgrcSRCHLFgAoQE) The main idea is to use an ambivalent function, where the monadic variant would return the result, and the dyadic variant would keep track of the count. ``` (+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)⊃1 (+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢) # The ambivalent function: + # monadic: identity (*); dyadic: left + right , # concatenated with 8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢ # octal and hexadecimal versions: {(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]} # dyadic function to convert int to base-n string: (⎕D,⎕A) # digits concatenated to alphabet [ ] # indexed by ⍵ # right argument ⊥⍣¯1 # in base (returns digit vector, e.g. 42 in base-16 is [2, 10]) ⍺ # left argument ¨ # applied to: 8 ⊢ # 8 and right argument, 16 ⊢ # 16 and right argument, # To Summarize: # monadic version returns: [arg, oct(arg), hex(arg)] # dyadic version returns: [left + right, oct(right), hex(right)] # since left argument is always 1 when snippet is repeated, we can simplify it to # [1 + right, oct(right), hex(right)] ⊃ # pick first (extracts the current count) # when snippet is repeated this would be in front of all the dyadic calls # but not in front of the final monadic call 1 # The initial count 💎 ``` Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).