Post History
Given 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 ...
#6: Post edited
- Given 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
- 1000 : 125 : "QUINTESSENTIAL"
- Z000 : -125 : "QUINTESSENTIAL"
- ```
- ## 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 are optional, but I'm more likely to upvote answers that have one.[]()
- Given 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## Input
- - The input will be an integer in balanced quinary
- - You may choose any $5$ characters to represent the $5$ digits of balanced quinary
- - As these digits do not necessarily have to be numeric characters, you are free to choose between taking input as a numeric type, or as a string, including any ordered data structure of characters
- - 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
- 1000 : 125 : "QUINTESSENTIAL"
- Z000 : -125 : "QUINTESSENTIAL"
- ```
- ## 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 are optional, but I'm more likely to upvote answers that have one.[]()
#5: Post edited
- Given 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
100 : 125 : "QUINTESSENTIAL"Z00 : -125 : "QUINTESSENTIAL"- ```
- ## 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.[]()
- Given 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
- 1000 : 125 : "QUINTESSENTIAL"
- Z000 : -125 : "QUINTESSENTIAL"
- ```
- ## 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 are optional, but I'm more likely to upvote answers that have one.[]()
#4: Post edited
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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
- 100 : 125 : "QUINTESSENTIAL"
- Z00 : -125 : "QUINTESSENTIAL"
- ```
- ## 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.[]()
- Given 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
- 100 : 125 : "QUINTESSENTIAL"
- Z00 : -125 : "QUINTESSENTIAL"
- ```
- ## 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.[]()
#3: Post edited
- 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
100: 125 : "QUINTESSENTIAL"Z00: -125 : "QUINTESSENTIAL"- ```
- ## 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.[]()
- 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
- 100 : 125 : "QUINTESSENTIAL"
- Z00 : -125 : "QUINTESSENTIAL"
- ```
- ## 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.[]()
#2: Post edited
- 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## 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.[]()
- 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
- <details>
- <summary>Quinary</summary>
- 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$$
- </details>
- <details>
- <summary>Balanced quinary</summary>
- 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$$
- </details>
- ## 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
- - The input will never be empty (zero is represented in balanced quinary as the digit $0$)
- ## 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`
- - 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.
- <details>
- <summary>Detailed justification</summary>
- 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).
- </details>
- ## Test cases
- These test cases use $Y,Z,0,1,2$ as digits of value $-2,-1,0,1,2$ respectively. In your own code you are free to use whichever character you wish to represent each of these 5 values.
- The test cases are in the format
- `quinary input : decimal equivalent : "output characters"`
- The output characters are based on your source code being the string `QUINTESSENTIAL` and the double quotes do not form part of the output (they just make empty output easier to read for these test cases).
- ```text
- 0 : 0 : ""
- Z : -1 : "L"
- 1 : 1 : "Q"
- Y : -2 : "AL"
- 2 : 2 : "QU"
- Z2 : -3 : "IAL"
- 1Y : 3 : "QUI"
- Z1 : -4 : "TIAL"
- 1Z : 4 : "QUIN"
- Z0 : -5 : "NTIAL"
- 10 : 5 : "QUINT"
- 100: 125 : "QUINTESSENTIAL"
- Z00: -125 : "QUINTESSENTIAL"
- ```
- ## 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.[]()
#1: Initial revision
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 <details> <summary>Quinary</summary> 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$$ </details> <details> <summary>Balanced quinary</summary> 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$$ </details> ## 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` - 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. <details> <summary>Detailed justification</summary> 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). </details> ## 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.[]()