Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Balanced quinary quasiquine

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...

posted 1y ago by lyxal‭

Answer
#1: Initial revision by user avatar lyxal‭ · 2022-10-18T04:18:00Z (over 1 year ago)
# [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)]
```