Challenge:
Input:
Two integer parameters a
and b
(where a<b
and the difference is at least 2)
Output:
Output or return this text, where a
and b
are filled in:
(a,b) = ]a,b[ = {a<x<b} = {a<x&&x<b} = a+1..b-1
[a,b) = [a,b[ = {a<=x<b} = {a<=x&&x<b} = a..b-1
(a,b] = ]a,b] = {a<x<=b} = {a<x&&x<=b} = a+1..b
[a,b] = [a,b] = {a<=x<=b} = {a<=x&&x<=b} = a..b
Challenge rules:
- I/O is flexible. Can be printed to STDOUT, returned as a string/character-array, etc. Can be inputted as two integers, decimals, strings (not sure why since you need to calculate the
a+1
andb-1
, but be my guest..), etc. - Any amount of leading and/or trailing new-lines are allowed, and any amount of trailing and/or leading spaces for each line is allowed.
- The spaces at the equal signs (including those to align them in the same column) are mandatory, spaces between the other characters are not allowed.
a+1
andb-1
are replaced with the correct values after these calculations.- You are not allowed to use
≤
instead of<=
. - You are not allowed to use
&
instead of&&
. - You are allowed to output the numbers with
.0
(as long as it's consistent, and not more than one decimal zero). - You can assume
a
is at least 2 lower thanb
(in order for(a,b)
to be correct). - The lines should be output in the order shown.
Example:
Input: a=-5, b=10
Output:
(-5,10) = ]-5,10[ = {-5<x<10} = {-5<x&&x<10} = -4..9
[-5,10) = [-5,10[ = {-5<=x<10} = {-5<=x&&x<10} = -5..9
(-5,10] = ]-5,10] = {-5<x<=10} = {-5<x&&x<=10} = -4..10
[-5,10] = [-5,10] = {-5<=x<=10} = {-5<=x&&x<=10} = -5..10
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
PS: For those who had seen this challenge in the Sandbox when it was still a kolmogorov-complexity challenge with a
and b
hard-coded, I've changed it to an input challenge to prevent boring hard-coded and encoded answers like we usually see with KC challenges.
a=5, b=6
still output(5,6) = ... = 6...5
? \$\endgroup\$a
andb
will always be at least 2 apart. I'll edit the challenge. \$\endgroup\$