# Balanced quinary quasiquine [FINALIZED]

# Now posted: Balanced quinary quasiquine

Give an integer $N$ in balanced quinary, output the first $N$ characters of your source code if $N$ is positive, or the last $-N$ characters of your source code if $N$ is negative.

## Terminology

## Quinary

Standard quinary (base $5$) has digits $0, 1, 2, 3, 4$. In a quinary number a digit $n$ places from the right is worth $5^n$ times that digit's individual value.For example, the quinary number $1234$ converts to decimal like this: $$(1\times5^3)+(2\times5^2)+(3\times5^1)+(4\times5^0)$$ $$(1\times125)+(2\times25)+(3\times5)+(4\times1)$$ $$125+50+15+4$$ $$194$$

## Balanced quinary

Balanced quinary works exactly the same as standard quinary, except it uses digits worth $-2,-1,0,1,2$. In a balanced quinary number a digit $n$ places from the right is worth $5^n$ times that digit's individual value, just like in standard quinary. This allows balanced quinary to express all positive and negative integers without the need for a leading minus sign / negation symbol.For the following example we will use $Y$ to represent $-2$ and $Z$ to represent $-1$, so our digits are $Y,Z,0,1,2$.

For example, the balanced quinary number $YZ12$ converts to decimal like this: $$(Y\times5^3)+(Z\times5^2)+(1\times5^1)+(2\times5^0)$$ $$(-2\times125)+(-1\times25)+(1\times5)+(2\times1)$$ $$-250-25+5+2$$ $$-268$$

## Input

- The input will be an integer in balanced quinary
- You may choose any $5$ characters to represent the $5$ digits of balanced quinary
- The input will never have leading zeroes
- The input may correspond to a value larger in magnitude (absolute value) than the number of characters in your source code

## Output

For input that evaluates to $N$:

- If $N$ is positive, the output is the first $N$ characters of your source code
- If $N$ is negative, the output is the last $-N$ characters of your source code
- If the magnitude (absolute value) of $N$ is greater than the number of characters in your source code, the output consists of your entire source code
- The required characters of your source code must be output in order
- Specifically, if $N$ is negative, the last $-N$ characters must not be in reversed order.

If your source code is`QUINTESSENTIAL`

the last $9$ characters are`ESSENTIAL`

, not`LAITNESSE`

- Specifically, if $N$ is negative, the last $-N$ characters must not be in reversed order.
- The output may include an optional trailing newline
- If $N=0$ the output must be empty (apart from the optional trailing newline)

## Excluded trivial cases

Using source code of length $3$ or fewer * characters* is defined to be a challenge-specific loophole, and is not a valid answer.

## Detailed justification

Source code with length $3$ characters or fewer meets the requirements trivially, without requiring an implementation of balanced quinary.In order to demonstrate that it is correctly interpreting the balanced quinary base system (not just the individual digits), your code must have at least $2$ different outputs for inputs with $2$ digits.

The smallest magnitude of a $2$ digit balanced quinary number is $3$. This means that source code of $3$ or fewer characters would lead to the full source code being output for all $2$ digit inputs, regardless of value. The shortest source code length that can lead to different outputs for different $2$ digit inputs is therefore length $4$ ($4$ characters - even in cases where that means more than $4$ bytes).

## Scoring

This is a code golf challenge. Your score is the length of your source code in bytes. Lower is better.

*Note that your score is in bytes, but the required length of output is measured in characters, in case the two are not equivalent for your chosen language.*

Explanations in answers are optional, but I'm more likely to upvote answers that have one.

## 0 comment threads