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 »
Sandbox

Post History

50%
+0 −0
Sandbox Balanced quinary quasiquine [FINALIZED]

posted 2y ago by trichoplax‭  ·  edited 2y ago by trichoplax‭

#14: Post edited by user avatar trichoplax‭ · 2022-10-06T19:30:52Z (about 2 years ago)
Mark as finalized
  • Balanced quinary quasiquine
  • Balanced quinary quasiquine [FINALIZED]
  • 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.[]()
  • # Now posted: [Balanced quinary quasiquine](https://codegolf.codidact.com/posts/287173)
  • ---
  • 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.[]()
#13: Post edited by user avatar trichoplax‭ · 2022-10-06T18:22:49Z (about 2 years ago)
Tidying
  • 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 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
  • ## 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.[]()
#12: Post edited by user avatar trichoplax‭ · 2022-10-06T18:18:02Z (about 2 years ago)
Permit an optional trailing newline
  • 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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and 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
  • ## 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 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.
#11: Post edited by user avatar trichoplax‭ · 2022-10-02T19:52:05Z (about 2 years ago)
Clarify magnitude
  • 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and 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
  • ## 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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and 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.
#10: Post edited by user avatar trichoplax‭ · 2022-10-02T17:30:55Z (about 2 years ago)
Use "fewer" for consistency
  • 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and not a valid answer.
  • <details>
  • <summary>Detailed justification</summary>
  • Source code with length $3$ characters or less 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and 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.
#9: Post edited by user avatar trichoplax‭ · 2022-10-02T17:24:42Z (about 2 years ago)
Remove word "still" that depends on previous optional section
  • 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 still 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and not a valid answer.
  • <details>
  • <summary>Detailed justification</summary>
  • Source code with length $3$ characters or less 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and not a valid answer.
  • <details>
  • <summary>Detailed justification</summary>
  • Source code with length $3$ characters or less 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.
#8: Post edited by user avatar trichoplax‭ · 2022-10-02T17:22:47Z (about 2 years ago)
Hide supplementary terminology section
  • 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 still 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and not a valid answer.
  • <details>
  • <summary>Detailed justification</summary>
  • Source code with length $3$ characters or less 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 still 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and not a valid answer.
  • <details>
  • <summary>Detailed justification</summary>
  • Source code with length $3$ characters or less 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.
#7: Post edited by user avatar trichoplax‭ · 2022-10-02T17:17:00Z (about 2 years ago)
Hide detailed justification for trivial case threshold
  • 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 still 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ characters or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is therefore defined to be a challenge-specific loophole, and not a valid answer.
  • ## 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
  • ### 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 still 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • Using source code of length $3$ or fewer ***characters*** is defined to be a challenge-specific loophole, and not a valid answer.
  • <details>
  • <summary>Detailed justification</summary>
  • Source code with length $3$ characters or less 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.
#6: Post edited by user avatar trichoplax‭ · 2022-10-02T17:05:06Z (about 2 years ago)
Make lengths explicitly characters in excluded cases section
  • 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 still 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole, and not a valid answer.
  • ## 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
  • ### 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 still 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ characters or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is therefore defined to be a challenge-specific loophole, and not a valid answer.
  • ## 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.
#5: Post edited by user avatar trichoplax‭ · 2022-10-02T16:59:35Z (about 2 years ago)
Remove ambiguity in code length in input section
  • 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 still 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 than the length of 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole, and not a valid answer.
  • ## 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
  • ### 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 still 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 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole, and not a valid answer.
  • ## 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.
#4: Post edited by user avatar trichoplax‭ · 2022-10-02T04:23:59Z (about 2 years ago)
Remove ambiguous reference to length
  • 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 still 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 than the length of 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 $N$ (or $-N$) is greater than the length of 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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole, and not a valid answer.
  • ## 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
  • ### 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 still 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 than the length of 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 $N$ (or $-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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole, and not a valid answer.
  • ## 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 by user avatar trichoplax‭ · 2022-10-02T03:07:17Z (about 2 years ago)
Clarify that 3 or fewer characters is not a valid answer
  • 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 still 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 than the length of 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 $N$ (or $-N$) is greater than the length of 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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole.
  • ## 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
  • ### 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 still 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 than the length of 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 $N$ (or $-N$) is greater than the length of 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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole, and not a valid answer.
  • ## 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 by user avatar trichoplax‭ · 2022-10-02T03:02:11Z (about 2 years ago)
Explicitly state input will be in balanced quinary
  • 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 still 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
  • - 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 than the length of 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 $N$ (or $-N$) is greater than the length of 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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole.
  • ## 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
  • ### 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 still 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 than the length of 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 $N$ (or $-N$) is greater than the length of 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`
  • - If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)
  • ## Excluded trivial cases
  • 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. 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).
  • Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole.
  • ## 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 by user avatar trichoplax‭ · 2022-10-02T02:55:08Z (about 2 years ago)
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 still 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
- 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 than the length of 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 $N$ (or $-N$) is greater than the length of 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`
- If $N=0$ the output must be empty (with any permitted exceptions, such as allowing a trailing newline)

## Excluded trivial cases
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. 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).

Source code with length $3$ or less meets the requirements trivially, without requiring an implementation of balanced quinary. Using source code of length $3$ or fewer *characters* is a challenge-specific loophole.

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