Post History
Vyxal D, 62 bytes `$f3uV4udV5β$I$:∇₍λ2|62∵Ẏ;ȯ$0<i`$f3uV4udV5β$I$:∇₍λ2|62∵Ẏ;ȯ$0<i Try it Online! Character map: 4 : -2 3 : -1 0 : 0 1 : 1 2 : 2 Nice, long and yummy quine. Explai...
Answer
#1: Initial revision
# [Vyxal](https://github.com/Vyxal/Vyxal) `D`, 62 bytes ``` `$f3uV4udV5β$I$:∇₍λ2|62∵Ẏ;ȯ$0<i`$f3uV4udV5β$I$:∇₍λ2|62∵Ẏ;ȯ$0<i ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyJEQSIsIiIsImAkZjN1VjR1ZFY1zrIkSSQ64oiH4oKNzrsyfDYy4oi14bqOO8ivJDA8aWAkZjN1VjR1ZFY1zrIkSSQ64oiH4oKNzrsyfDYy4oi14bqOO8ivJDA8aSIsIiIsIjBcbjNcbjFcbjRcbjJcbjMyXG4xNFxuMzFcbjMwXG4xMDAwXG4zMDAwXG4yMzAiXQ==) Character map: ``` 4 : -2 3 : -1 0 : 0 1 : 1 2 : 2 ``` Nice, long and yummy quine. ## Explained ``` `$f3uV4udV5β$I$:∇₍λ2|62∵Ẏ;ȯ$0<i` ``` Push the string `"$f3uV4udV5β$I$:∇₍λ2|62∵Ẏ;ȯ$0<i"` to the stack. This is the "data" of the quine. Now onto the code part: ``` $f3uV4udV5β $f # Push a list of digits of the input in front of that string 3uV # Replace all 3s with -1 4udV # And replace all 4s with -2 5β # And convert that to base 5. Vyxal is smart enough to know how to handle negative digits in the list. ``` The above does the balanced quinary conversion. ``` $I$:∇ $I # Swap the top two stack items to make the stack [quinary number, data string", and quine cheese the string (surround it in backticks and append it to itself) $:∇ # Swap the top two stack items to make the stack [string, number], duplicate the number and then rotate the stack so it becomes [number, string, number] - this will be used to determine which end to get characters from ``` ``` ₍λ2|62∵Ẏ;ȯ ₍ # Apply the next two things to the same stack: λ2|62∵Ẏ; # string[0:min(62, number)] ȯ # string[number:] ``` This gets `number` characters from both the start and end of the string, because there's no built-in to conditionally get either start or end. Also, the lambda is needed to avoid modular indexing with `Ẏ`. The stack will now be `[number, [string[0:min(62, number)], string[number:]]`. ``` $0<i $ # Make the number the top of the stack again 0< # is it negative? i # index that into the [string[0:min(62, number)], string[number:] list - if number is negative, it'll get string[number:]. Otherwise, it'll get string[0:min(62, number)] ```