Inscriptio LabyrinthicaLay out the CarpetFind the Longest Palindrome in a String by Removing...
Why were these characters absent in Spider-Man: Far From Home?
What do you call a statistical mean that is calculated from upper and lower extremes in any given dataset?
Everyone but three
Are there any Saints that have miraculously overcome death (should have died, but did not)?
I have found a mistake on someone's code published online: what is the protocol?
"This used to be my phone number"
How can one convert an expression to a string while keeping the quotation marks of strings that are part of the expression?
What makes MOVEQ quicker than a normal MOVE in 68000 assembly?
Is this Android phone Android 9.0 or Android 6.0?
Pauli exclusion principle - black holes
Should I have one hand on throttle during engine ignition?
Why isn't a binary file shown as 0s and 1s?
Why jet engines sound louder on the ground than inside the aircraft?
How to not confuse readers with simultaneous events?
Why is the Intel 8086 CPU called a 16-bit CPU?
Why aren't there any women super GMs?
Which modern firearm should a time traveler bring to be easily reproducible for a historic civilization?
Strategy to pay off revolving debt while building reserve savings fund?
What causes a rotating object to rotate forever without external force—inertia, or something else?
Software need db owner permission to master database (sql2016)
Random piece of plastic
Inscriptio Labyrinthica
Did Hitler say this quote about homeschooling?
How to interpret a promising preprint that was never published?
Inscriptio Labyrinthica
Lay out the CarpetFind the Longest Palindrome in a String by Removing CharactersGenerate keyboard shortcuts for a menuCompute the specificity of a CSS selectorSwap capitalization of two stringsTwisting Words!Quine multiple timesIt's Not 2015 Anymore!Movie Title Styled StringPerfect PalindromesOdd'em out: letters
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
$begingroup$
In the burial place of King Silo of Asturias there is an inscription that reads SILO PRINCEPS FECIT (King Silo made this).
The first letter is found in the very middle, and from there one reads by going in any non-diagonal direction radiating outward. The final letter is found on all four corners. In this challenge, you'll generalize the process to make them.
Input
A string (or equivalent), and an integer. You may make the following assumptions about the input:
- The string will have an odd length.
- The integer will be an odd number between 1 and one less than twice the length of the string.
Output
An inscriptio labyrinthica for the string, using the integer for the height (see models). Output should be each letter with no spaces, line break as default to your system/language.
Test cases
Note that an input of 1 or (length * 2 - 1) will result in a horizontal or vertical palindrome.
Input: FOO, 3 Input: BAR, 1 Input: BAR, 3 Input: BAR, 5
Output: OOO Output: RABAR Output: RAR Output: R
OFO ABA A
OOO RAR B
A
R
Input: ABCDE, 5 Input: ABCDE, 3 Input: *<>v^, 5
Output: EDCDE Output: EDCBCDE ^v>v^
DCBCD DCBABCD v><>v
CBABC EDCBCDE ><*<>
DCBCD v><>v
EDCDE ^v>v^
Scoring
This is code-golf so shortest answer in bytes wins. Standard loopholes forbidden.
code-golf string
$endgroup$
|
show 6 more comments
$begingroup$
In the burial place of King Silo of Asturias there is an inscription that reads SILO PRINCEPS FECIT (King Silo made this).
The first letter is found in the very middle, and from there one reads by going in any non-diagonal direction radiating outward. The final letter is found on all four corners. In this challenge, you'll generalize the process to make them.
Input
A string (or equivalent), and an integer. You may make the following assumptions about the input:
- The string will have an odd length.
- The integer will be an odd number between 1 and one less than twice the length of the string.
Output
An inscriptio labyrinthica for the string, using the integer for the height (see models). Output should be each letter with no spaces, line break as default to your system/language.
Test cases
Note that an input of 1 or (length * 2 - 1) will result in a horizontal or vertical palindrome.
Input: FOO, 3 Input: BAR, 1 Input: BAR, 3 Input: BAR, 5
Output: OOO Output: RABAR Output: RAR Output: R
OFO ABA A
OOO RAR B
A
R
Input: ABCDE, 5 Input: ABCDE, 3 Input: *<>v^, 5
Output: EDCDE Output: EDCBCDE ^v>v^
DCBCD DCBABCD v><>v
CBABC EDCBCDE ><*<>
DCBCD v><>v
EDCDE ^v>v^
Scoring
This is code-golf so shortest answer in bytes wins. Standard loopholes forbidden.
code-golf string
$endgroup$
1
$begingroup$
not totally unrelated
$endgroup$
– Giuseppe
12 hours ago
$begingroup$
Can the input contain spaces? If so, how should they be handled?
$endgroup$
– Nitrodon
12 hours ago
$begingroup$
@Nitrodon Sure, and no special handling, just treat them as any other character. So inputingA B C
,1 would result inC B A B C
(using a value of 1 since I can't show verticality in comments ha)
$endgroup$
– guifa
12 hours ago
$begingroup$
The last test case says height is 3, but the output has 5 rows.
$endgroup$
– RootTwo
11 hours ago
1
$begingroup$
May we take the width instead of the height?
$endgroup$
– attinat
2 hours ago
|
show 6 more comments
$begingroup$
In the burial place of King Silo of Asturias there is an inscription that reads SILO PRINCEPS FECIT (King Silo made this).
The first letter is found in the very middle, and from there one reads by going in any non-diagonal direction radiating outward. The final letter is found on all four corners. In this challenge, you'll generalize the process to make them.
Input
A string (or equivalent), and an integer. You may make the following assumptions about the input:
- The string will have an odd length.
- The integer will be an odd number between 1 and one less than twice the length of the string.
Output
An inscriptio labyrinthica for the string, using the integer for the height (see models). Output should be each letter with no spaces, line break as default to your system/language.
Test cases
Note that an input of 1 or (length * 2 - 1) will result in a horizontal or vertical palindrome.
Input: FOO, 3 Input: BAR, 1 Input: BAR, 3 Input: BAR, 5
Output: OOO Output: RABAR Output: RAR Output: R
OFO ABA A
OOO RAR B
A
R
Input: ABCDE, 5 Input: ABCDE, 3 Input: *<>v^, 5
Output: EDCDE Output: EDCBCDE ^v>v^
DCBCD DCBABCD v><>v
CBABC EDCBCDE ><*<>
DCBCD v><>v
EDCDE ^v>v^
Scoring
This is code-golf so shortest answer in bytes wins. Standard loopholes forbidden.
code-golf string
$endgroup$
In the burial place of King Silo of Asturias there is an inscription that reads SILO PRINCEPS FECIT (King Silo made this).
The first letter is found in the very middle, and from there one reads by going in any non-diagonal direction radiating outward. The final letter is found on all four corners. In this challenge, you'll generalize the process to make them.
Input
A string (or equivalent), and an integer. You may make the following assumptions about the input:
- The string will have an odd length.
- The integer will be an odd number between 1 and one less than twice the length of the string.
Output
An inscriptio labyrinthica for the string, using the integer for the height (see models). Output should be each letter with no spaces, line break as default to your system/language.
Test cases
Note that an input of 1 or (length * 2 - 1) will result in a horizontal or vertical palindrome.
Input: FOO, 3 Input: BAR, 1 Input: BAR, 3 Input: BAR, 5
Output: OOO Output: RABAR Output: RAR Output: R
OFO ABA A
OOO RAR B
A
R
Input: ABCDE, 5 Input: ABCDE, 3 Input: *<>v^, 5
Output: EDCDE Output: EDCBCDE ^v>v^
DCBCD DCBABCD v><>v
CBABC EDCBCDE ><*<>
DCBCD v><>v
EDCDE ^v>v^
Scoring
This is code-golf so shortest answer in bytes wins. Standard loopholes forbidden.
code-golf string
code-golf string
edited 11 hours ago
guifa
asked 12 hours ago
guifaguifa
5992 silver badges8 bronze badges
5992 silver badges8 bronze badges
1
$begingroup$
not totally unrelated
$endgroup$
– Giuseppe
12 hours ago
$begingroup$
Can the input contain spaces? If so, how should they be handled?
$endgroup$
– Nitrodon
12 hours ago
$begingroup$
@Nitrodon Sure, and no special handling, just treat them as any other character. So inputingA B C
,1 would result inC B A B C
(using a value of 1 since I can't show verticality in comments ha)
$endgroup$
– guifa
12 hours ago
$begingroup$
The last test case says height is 3, but the output has 5 rows.
$endgroup$
– RootTwo
11 hours ago
1
$begingroup$
May we take the width instead of the height?
$endgroup$
– attinat
2 hours ago
|
show 6 more comments
1
$begingroup$
not totally unrelated
$endgroup$
– Giuseppe
12 hours ago
$begingroup$
Can the input contain spaces? If so, how should they be handled?
$endgroup$
– Nitrodon
12 hours ago
$begingroup$
@Nitrodon Sure, and no special handling, just treat them as any other character. So inputingA B C
,1 would result inC B A B C
(using a value of 1 since I can't show verticality in comments ha)
$endgroup$
– guifa
12 hours ago
$begingroup$
The last test case says height is 3, but the output has 5 rows.
$endgroup$
– RootTwo
11 hours ago
1
$begingroup$
May we take the width instead of the height?
$endgroup$
– attinat
2 hours ago
1
1
$begingroup$
not totally unrelated
$endgroup$
– Giuseppe
12 hours ago
$begingroup$
not totally unrelated
$endgroup$
– Giuseppe
12 hours ago
$begingroup$
Can the input contain spaces? If so, how should they be handled?
$endgroup$
– Nitrodon
12 hours ago
$begingroup$
Can the input contain spaces? If so, how should they be handled?
$endgroup$
– Nitrodon
12 hours ago
$begingroup$
@Nitrodon Sure, and no special handling, just treat them as any other character. So inputing
A B C
,1 would result in C B A B C
(using a value of 1 since I can't show verticality in comments ha)$endgroup$
– guifa
12 hours ago
$begingroup$
@Nitrodon Sure, and no special handling, just treat them as any other character. So inputing
A B C
,1 would result in C B A B C
(using a value of 1 since I can't show verticality in comments ha)$endgroup$
– guifa
12 hours ago
$begingroup$
The last test case says height is 3, but the output has 5 rows.
$endgroup$
– RootTwo
11 hours ago
$begingroup$
The last test case says height is 3, but the output has 5 rows.
$endgroup$
– RootTwo
11 hours ago
1
1
$begingroup$
May we take the width instead of the height?
$endgroup$
– attinat
2 hours ago
$begingroup$
May we take the width instead of the height?
$endgroup$
– attinat
2 hours ago
|
show 6 more comments
6 Answers
6
active
oldest
votes
$begingroup$
Charcoal, 25 19 bytes
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η‖O←↑
Try it online! Link is to verbose version of code. Explanation:
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η
Draw a quarter of the inscription.
‖O←↑
Reflect to complete the inscription.
$endgroup$
add a comment |
$begingroup$
Jelly, 12 bytes
Uṡṛ‘HɗŒBŒḄZY
Try it online!
A dyadic link taking the string as its left and height as its right argument. Returns a string with line breaks. If a list of strings were acceptable for output, I can remove the final Y
saving a byte. Interestingly the original “SILO PRINCEPS FECIT” looks to me like ASCII art of a 3D diamond when I look at it on TIO.
$endgroup$
$begingroup$
I clicked on the try it just to see and yes, indeed, it does 3D. Weird but cool.
$endgroup$
– guifa
8 hours ago
add a comment |
$begingroup$
R, 93 bytes
function(s,H,h=H/2-.5,w=length(s)-h-1)write(s[1+outer(abs(-w:w),abs(-h:h),`+`)],"",2*w+1,,"")
Try it online!
Takes input as a vector of characters.
First compute $w$ and $h$ such that the output is of size $(2w+1)times(2h+1)$.
In the output, we want the character in position $(i,j)$ to be the $1+|i-h|+|j-w|$ th character of the input. The rest is formatting.
$endgroup$
add a comment |
$begingroup$
Japt -R
, 19 16 bytes
z
ò@VÔtYVÊaU)êÃê
Try it
$endgroup$
add a comment |
$begingroup$
J, 27 bytes
([{~]+/&(|@i:)#@[-1+])-:@<:
Try it online!
An example will clarify the high-level approach.
Consider 'ABCDE' f 3
We notice that what we seek is simply the "cross addition" table of 1 0 1
and 3 2 1 0 1 2 3
, which looks like this:
4 3 2 1 2 3 4
3 2 1 0 1 2 3
4 3 2 1 2 3 4
We then pull those indexes from the original string: [{~
.
All the rest of the code is just boring arithmetic and the use of i:
to construct the arguments 1 0 1
and 3 2 1 0 1 2 3
.
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 57 bytes
(g=Reverse@Rest@#~Join~#&)@BlockMap[g,#,⌈#2/2⌉,1]&
Try it online!
$endgroup$
1
$begingroup$
@lirtosiast then the firstg
isn't evaluated the first time the function is called. Try it online!
$endgroup$
– attinat
1 hour ago
$begingroup$
Interesting, any idea why it appears to work when you use @@ or @@@?
$endgroup$
– lirtosiast
58 mins ago
$begingroup$
@lirtosiast It thinkPrint/@f[...]
->Print/@Transpose[g[...]]
->Transpose[Print@g[...]]
, by which timeg
is defined.
$endgroup$
– attinat
48 mins ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f188528%2finscriptio-labyrinthica%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Charcoal, 25 19 bytes
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η‖O←↑
Try it online! Link is to verbose version of code. Explanation:
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η
Draw a quarter of the inscription.
‖O←↑
Reflect to complete the inscription.
$endgroup$
add a comment |
$begingroup$
Charcoal, 25 19 bytes
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η‖O←↑
Try it online! Link is to verbose version of code. Explanation:
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η
Draw a quarter of the inscription.
‖O←↑
Reflect to complete the inscription.
$endgroup$
add a comment |
$begingroup$
Charcoal, 25 19 bytes
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η‖O←↑
Try it online! Link is to verbose version of code. Explanation:
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η
Draw a quarter of the inscription.
‖O←↑
Reflect to complete the inscription.
$endgroup$
Charcoal, 25 19 bytes
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η‖O←↑
Try it online! Link is to verbose version of code. Explanation:
E⊘⊕η✂θκ⁺κ⁻Lθ⊘⊖η
Draw a quarter of the inscription.
‖O←↑
Reflect to complete the inscription.
edited 9 hours ago
answered 9 hours ago
NeilNeil
86.4k8 gold badges46 silver badges183 bronze badges
86.4k8 gold badges46 silver badges183 bronze badges
add a comment |
add a comment |
$begingroup$
Jelly, 12 bytes
Uṡṛ‘HɗŒBŒḄZY
Try it online!
A dyadic link taking the string as its left and height as its right argument. Returns a string with line breaks. If a list of strings were acceptable for output, I can remove the final Y
saving a byte. Interestingly the original “SILO PRINCEPS FECIT” looks to me like ASCII art of a 3D diamond when I look at it on TIO.
$endgroup$
$begingroup$
I clicked on the try it just to see and yes, indeed, it does 3D. Weird but cool.
$endgroup$
– guifa
8 hours ago
add a comment |
$begingroup$
Jelly, 12 bytes
Uṡṛ‘HɗŒBŒḄZY
Try it online!
A dyadic link taking the string as its left and height as its right argument. Returns a string with line breaks. If a list of strings were acceptable for output, I can remove the final Y
saving a byte. Interestingly the original “SILO PRINCEPS FECIT” looks to me like ASCII art of a 3D diamond when I look at it on TIO.
$endgroup$
$begingroup$
I clicked on the try it just to see and yes, indeed, it does 3D. Weird but cool.
$endgroup$
– guifa
8 hours ago
add a comment |
$begingroup$
Jelly, 12 bytes
Uṡṛ‘HɗŒBŒḄZY
Try it online!
A dyadic link taking the string as its left and height as its right argument. Returns a string with line breaks. If a list of strings were acceptable for output, I can remove the final Y
saving a byte. Interestingly the original “SILO PRINCEPS FECIT” looks to me like ASCII art of a 3D diamond when I look at it on TIO.
$endgroup$
Jelly, 12 bytes
Uṡṛ‘HɗŒBŒḄZY
Try it online!
A dyadic link taking the string as its left and height as its right argument. Returns a string with line breaks. If a list of strings were acceptable for output, I can remove the final Y
saving a byte. Interestingly the original “SILO PRINCEPS FECIT” looks to me like ASCII art of a 3D diamond when I look at it on TIO.
answered 8 hours ago
Nick KennedyNick Kennedy
5,0149 silver badges14 bronze badges
5,0149 silver badges14 bronze badges
$begingroup$
I clicked on the try it just to see and yes, indeed, it does 3D. Weird but cool.
$endgroup$
– guifa
8 hours ago
add a comment |
$begingroup$
I clicked on the try it just to see and yes, indeed, it does 3D. Weird but cool.
$endgroup$
– guifa
8 hours ago
$begingroup$
I clicked on the try it just to see and yes, indeed, it does 3D. Weird but cool.
$endgroup$
– guifa
8 hours ago
$begingroup$
I clicked on the try it just to see and yes, indeed, it does 3D. Weird but cool.
$endgroup$
– guifa
8 hours ago
add a comment |
$begingroup$
R, 93 bytes
function(s,H,h=H/2-.5,w=length(s)-h-1)write(s[1+outer(abs(-w:w),abs(-h:h),`+`)],"",2*w+1,,"")
Try it online!
Takes input as a vector of characters.
First compute $w$ and $h$ such that the output is of size $(2w+1)times(2h+1)$.
In the output, we want the character in position $(i,j)$ to be the $1+|i-h|+|j-w|$ th character of the input. The rest is formatting.
$endgroup$
add a comment |
$begingroup$
R, 93 bytes
function(s,H,h=H/2-.5,w=length(s)-h-1)write(s[1+outer(abs(-w:w),abs(-h:h),`+`)],"",2*w+1,,"")
Try it online!
Takes input as a vector of characters.
First compute $w$ and $h$ such that the output is of size $(2w+1)times(2h+1)$.
In the output, we want the character in position $(i,j)$ to be the $1+|i-h|+|j-w|$ th character of the input. The rest is formatting.
$endgroup$
add a comment |
$begingroup$
R, 93 bytes
function(s,H,h=H/2-.5,w=length(s)-h-1)write(s[1+outer(abs(-w:w),abs(-h:h),`+`)],"",2*w+1,,"")
Try it online!
Takes input as a vector of characters.
First compute $w$ and $h$ such that the output is of size $(2w+1)times(2h+1)$.
In the output, we want the character in position $(i,j)$ to be the $1+|i-h|+|j-w|$ th character of the input. The rest is formatting.
$endgroup$
R, 93 bytes
function(s,H,h=H/2-.5,w=length(s)-h-1)write(s[1+outer(abs(-w:w),abs(-h:h),`+`)],"",2*w+1,,"")
Try it online!
Takes input as a vector of characters.
First compute $w$ and $h$ such that the output is of size $(2w+1)times(2h+1)$.
In the output, we want the character in position $(i,j)$ to be the $1+|i-h|+|j-w|$ th character of the input. The rest is formatting.
answered 8 hours ago
Robin RyderRobin Ryder
2,8014 silver badges24 bronze badges
2,8014 silver badges24 bronze badges
add a comment |
add a comment |
$begingroup$
Japt -R
, 19 16 bytes
z
ò@VÔtYVÊaU)êÃê
Try it
$endgroup$
add a comment |
$begingroup$
Japt -R
, 19 16 bytes
z
ò@VÔtYVÊaU)êÃê
Try it
$endgroup$
add a comment |
$begingroup$
Japt -R
, 19 16 bytes
z
ò@VÔtYVÊaU)êÃê
Try it
$endgroup$
Japt -R
, 19 16 bytes
z
ò@VÔtYVÊaU)êÃê
Try it
answered 7 hours ago
ShaggyShaggy
20.5k3 gold badges20 silver badges69 bronze badges
20.5k3 gold badges20 silver badges69 bronze badges
add a comment |
add a comment |
$begingroup$
J, 27 bytes
([{~]+/&(|@i:)#@[-1+])-:@<:
Try it online!
An example will clarify the high-level approach.
Consider 'ABCDE' f 3
We notice that what we seek is simply the "cross addition" table of 1 0 1
and 3 2 1 0 1 2 3
, which looks like this:
4 3 2 1 2 3 4
3 2 1 0 1 2 3
4 3 2 1 2 3 4
We then pull those indexes from the original string: [{~
.
All the rest of the code is just boring arithmetic and the use of i:
to construct the arguments 1 0 1
and 3 2 1 0 1 2 3
.
$endgroup$
add a comment |
$begingroup$
J, 27 bytes
([{~]+/&(|@i:)#@[-1+])-:@<:
Try it online!
An example will clarify the high-level approach.
Consider 'ABCDE' f 3
We notice that what we seek is simply the "cross addition" table of 1 0 1
and 3 2 1 0 1 2 3
, which looks like this:
4 3 2 1 2 3 4
3 2 1 0 1 2 3
4 3 2 1 2 3 4
We then pull those indexes from the original string: [{~
.
All the rest of the code is just boring arithmetic and the use of i:
to construct the arguments 1 0 1
and 3 2 1 0 1 2 3
.
$endgroup$
add a comment |
$begingroup$
J, 27 bytes
([{~]+/&(|@i:)#@[-1+])-:@<:
Try it online!
An example will clarify the high-level approach.
Consider 'ABCDE' f 3
We notice that what we seek is simply the "cross addition" table of 1 0 1
and 3 2 1 0 1 2 3
, which looks like this:
4 3 2 1 2 3 4
3 2 1 0 1 2 3
4 3 2 1 2 3 4
We then pull those indexes from the original string: [{~
.
All the rest of the code is just boring arithmetic and the use of i:
to construct the arguments 1 0 1
and 3 2 1 0 1 2 3
.
$endgroup$
J, 27 bytes
([{~]+/&(|@i:)#@[-1+])-:@<:
Try it online!
An example will clarify the high-level approach.
Consider 'ABCDE' f 3
We notice that what we seek is simply the "cross addition" table of 1 0 1
and 3 2 1 0 1 2 3
, which looks like this:
4 3 2 1 2 3 4
3 2 1 0 1 2 3
4 3 2 1 2 3 4
We then pull those indexes from the original string: [{~
.
All the rest of the code is just boring arithmetic and the use of i:
to construct the arguments 1 0 1
and 3 2 1 0 1 2 3
.
edited 1 hour ago
answered 8 hours ago
JonahJonah
3,9512 gold badges12 silver badges21 bronze badges
3,9512 gold badges12 silver badges21 bronze badges
add a comment |
add a comment |
$begingroup$
Wolfram Language (Mathematica), 57 bytes
(g=Reverse@Rest@#~Join~#&)@BlockMap[g,#,⌈#2/2⌉,1]&
Try it online!
$endgroup$
1
$begingroup$
@lirtosiast then the firstg
isn't evaluated the first time the function is called. Try it online!
$endgroup$
– attinat
1 hour ago
$begingroup$
Interesting, any idea why it appears to work when you use @@ or @@@?
$endgroup$
– lirtosiast
58 mins ago
$begingroup$
@lirtosiast It thinkPrint/@f[...]
->Print/@Transpose[g[...]]
->Transpose[Print@g[...]]
, by which timeg
is defined.
$endgroup$
– attinat
48 mins ago
add a comment |
$begingroup$
Wolfram Language (Mathematica), 57 bytes
(g=Reverse@Rest@#~Join~#&)@BlockMap[g,#,⌈#2/2⌉,1]&
Try it online!
$endgroup$
1
$begingroup$
@lirtosiast then the firstg
isn't evaluated the first time the function is called. Try it online!
$endgroup$
– attinat
1 hour ago
$begingroup$
Interesting, any idea why it appears to work when you use @@ or @@@?
$endgroup$
– lirtosiast
58 mins ago
$begingroup$
@lirtosiast It thinkPrint/@f[...]
->Print/@Transpose[g[...]]
->Transpose[Print@g[...]]
, by which timeg
is defined.
$endgroup$
– attinat
48 mins ago
add a comment |
$begingroup$
Wolfram Language (Mathematica), 57 bytes
(g=Reverse@Rest@#~Join~#&)@BlockMap[g,#,⌈#2/2⌉,1]&
Try it online!
$endgroup$
Wolfram Language (Mathematica), 57 bytes
(g=Reverse@Rest@#~Join~#&)@BlockMap[g,#,⌈#2/2⌉,1]&
Try it online!
answered 1 hour ago
attinatattinat
1,6272 silver badges9 bronze badges
1,6272 silver badges9 bronze badges
1
$begingroup$
@lirtosiast then the firstg
isn't evaluated the first time the function is called. Try it online!
$endgroup$
– attinat
1 hour ago
$begingroup$
Interesting, any idea why it appears to work when you use @@ or @@@?
$endgroup$
– lirtosiast
58 mins ago
$begingroup$
@lirtosiast It thinkPrint/@f[...]
->Print/@Transpose[g[...]]
->Transpose[Print@g[...]]
, by which timeg
is defined.
$endgroup$
– attinat
48 mins ago
add a comment |
1
$begingroup$
@lirtosiast then the firstg
isn't evaluated the first time the function is called. Try it online!
$endgroup$
– attinat
1 hour ago
$begingroup$
Interesting, any idea why it appears to work when you use @@ or @@@?
$endgroup$
– lirtosiast
58 mins ago
$begingroup$
@lirtosiast It thinkPrint/@f[...]
->Print/@Transpose[g[...]]
->Transpose[Print@g[...]]
, by which timeg
is defined.
$endgroup$
– attinat
48 mins ago
1
1
$begingroup$
@lirtosiast then the first
g
isn't evaluated the first time the function is called. Try it online!$endgroup$
– attinat
1 hour ago
$begingroup$
@lirtosiast then the first
g
isn't evaluated the first time the function is called. Try it online!$endgroup$
– attinat
1 hour ago
$begingroup$
Interesting, any idea why it appears to work when you use @@ or @@@?
$endgroup$
– lirtosiast
58 mins ago
$begingroup$
Interesting, any idea why it appears to work when you use @@ or @@@?
$endgroup$
– lirtosiast
58 mins ago
$begingroup$
@lirtosiast It think
Print/@f[...]
-> Print/@Transpose[g[...]]
-> Transpose[Print@g[...]]
, by which time g
is defined.$endgroup$
– attinat
48 mins ago
$begingroup$
@lirtosiast It think
Print/@f[...]
-> Print/@Transpose[g[...]]
-> Transpose[Print@g[...]]
, by which time g
is defined.$endgroup$
– attinat
48 mins ago
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f188528%2finscriptio-labyrinthica%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
not totally unrelated
$endgroup$
– Giuseppe
12 hours ago
$begingroup$
Can the input contain spaces? If so, how should they be handled?
$endgroup$
– Nitrodon
12 hours ago
$begingroup$
@Nitrodon Sure, and no special handling, just treat them as any other character. So inputing
A B C
,1 would result inC B A B C
(using a value of 1 since I can't show verticality in comments ha)$endgroup$
– guifa
12 hours ago
$begingroup$
The last test case says height is 3, but the output has 5 rows.
$endgroup$
– RootTwo
11 hours ago
1
$begingroup$
May we take the width instead of the height?
$endgroup$
– attinat
2 hours ago