Output visual diagram of picture
$begingroup$
Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol X
for the painting, +
for the matting, and #
for the framing. The symbols must be space-separated. Trailing whitespace is alright, as long as the output visually matches the criteria. The inputs can be 0
.
INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)
OUTPUT:
In text form:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
The winning code completes the conditions in the least possible bytes.
code-golf ascii-art
New contributor
$endgroup$
|
show 8 more comments
$begingroup$
Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol X
for the painting, +
for the matting, and #
for the framing. The symbols must be space-separated. Trailing whitespace is alright, as long as the output visually matches the criteria. The inputs can be 0
.
INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)
OUTPUT:
In text form:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
The winning code completes the conditions in the least possible bytes.
code-golf ascii-art
New contributor
$endgroup$
1
$begingroup$
Nice challenge! For future challenges you may want to use The Sandbox
$endgroup$
– MilkyWay90
yesterday
2
$begingroup$
do you mind if the input is in a different order?
$endgroup$
– zevee
yesterday
1
$begingroup$
Can we return a list of strings?
$endgroup$
– MilkyWay90
yesterday
4
$begingroup$
Can any of the inputs be zero?
$endgroup$
– Laikoni
20 hours ago
1
$begingroup$
Can we have an space at the end of each line?
$endgroup$
– Luis Mendo
14 hours ago
|
show 8 more comments
$begingroup$
Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol X
for the painting, +
for the matting, and #
for the framing. The symbols must be space-separated. Trailing whitespace is alright, as long as the output visually matches the criteria. The inputs can be 0
.
INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)
OUTPUT:
In text form:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
The winning code completes the conditions in the least possible bytes.
code-golf ascii-art
New contributor
$endgroup$
Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol X
for the painting, +
for the matting, and #
for the framing. The symbols must be space-separated. Trailing whitespace is alright, as long as the output visually matches the criteria. The inputs can be 0
.
INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)
OUTPUT:
In text form:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
The winning code completes the conditions in the least possible bytes.
code-golf ascii-art
code-golf ascii-art
New contributor
New contributor
edited 5 hours ago
Jo King
25k359128
25k359128
New contributor
asked yesterday
George HarrisGeorge Harris
1014
1014
New contributor
New contributor
1
$begingroup$
Nice challenge! For future challenges you may want to use The Sandbox
$endgroup$
– MilkyWay90
yesterday
2
$begingroup$
do you mind if the input is in a different order?
$endgroup$
– zevee
yesterday
1
$begingroup$
Can we return a list of strings?
$endgroup$
– MilkyWay90
yesterday
4
$begingroup$
Can any of the inputs be zero?
$endgroup$
– Laikoni
20 hours ago
1
$begingroup$
Can we have an space at the end of each line?
$endgroup$
– Luis Mendo
14 hours ago
|
show 8 more comments
1
$begingroup$
Nice challenge! For future challenges you may want to use The Sandbox
$endgroup$
– MilkyWay90
yesterday
2
$begingroup$
do you mind if the input is in a different order?
$endgroup$
– zevee
yesterday
1
$begingroup$
Can we return a list of strings?
$endgroup$
– MilkyWay90
yesterday
4
$begingroup$
Can any of the inputs be zero?
$endgroup$
– Laikoni
20 hours ago
1
$begingroup$
Can we have an space at the end of each line?
$endgroup$
– Luis Mendo
14 hours ago
1
1
$begingroup$
Nice challenge! For future challenges you may want to use The Sandbox
$endgroup$
– MilkyWay90
yesterday
$begingroup$
Nice challenge! For future challenges you may want to use The Sandbox
$endgroup$
– MilkyWay90
yesterday
2
2
$begingroup$
do you mind if the input is in a different order?
$endgroup$
– zevee
yesterday
$begingroup$
do you mind if the input is in a different order?
$endgroup$
– zevee
yesterday
1
1
$begingroup$
Can we return a list of strings?
$endgroup$
– MilkyWay90
yesterday
$begingroup$
Can we return a list of strings?
$endgroup$
– MilkyWay90
yesterday
4
4
$begingroup$
Can any of the inputs be zero?
$endgroup$
– Laikoni
20 hours ago
$begingroup$
Can any of the inputs be zero?
$endgroup$
– Laikoni
20 hours ago
1
1
$begingroup$
Can we have an space at the end of each line?
$endgroup$
– Luis Mendo
14 hours ago
$begingroup$
Can we have an space at the end of each line?
$endgroup$
– Luis Mendo
14 hours ago
|
show 8 more comments
13 Answers
13
active
oldest
votes
$begingroup$
Python 2, 98 bytes
w,h,a,b=input()
a*='+'
b*='#'
for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)
Try it online!
Prints a space-separated grid, strictly following the spec. I'm amused that *=
is used to convert a
and b
from numbers to strings.
Python 3 can save some bytes by avoiding ' '.join
, maybe more by using f-strings and assignment expressions.
Python 3, 95 bytes
def f(w,h,a,b):
a*='+';b*='#'
for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])
Try it online!
$endgroup$
$begingroup$
93 bytes for Python 3
$endgroup$
– Jo King
yesterday
$begingroup$
I've been outgolfed! NIce job, seems pretty golfed
$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
Nice golf! Very clever.
$endgroup$
– George Harris
5 hours ago
add a comment |
$begingroup$
JavaScript (ES6), 118 113 107 bytes
(w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(i).repeat([F,M,n][i])))(y=>g(x=>'#+X'[x<y?x:y]+' ',w)+`
`,h)
Try it online!
Commented
(w, h, M, F) => ( // given the 4 input variables
g = ( // g = helper function taking:
c, // c = callback function returning a string to repeat
n // n = number of times the painting part must be repeated
) => //
'01210' // string describing the picture structure, with:
.replace( // 0 = frame, 1 = matte, 2 = painting
/./g, // for each character in the above string:
i => // i = identifier of the current area
c(i) // invoke the callback function
.repeat // and repeat the result ...
([F, M, n][i]) // ... either F, M or n times
) // end of replace()
)( // outer call to g:
y => // callback function taking y:
g( // inner call to g:
x => // callback function taking x:
'#+X' // figure out which character to use
[x < y ? x : y] // according to the current position
+ ' ', // append a space
w // repeat the painting part w times
) // end of inner call
+ 'n', // append a line feed
h // repeat the painting part h times
) // end of outer call
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 142 bytes
(t=(p=Table)["# ",2(c=#4+#3)+#2,2c+#];p[t[[i,j]]="+ ",{j,z=#4+1,c+#3+#},{i,z,c+#3+#2}];p[t[[i,j]]="X ",{j,#3+z,c+#},{i,#3+z,c+#2}];""<>#&/@t)&
Try it online!
$endgroup$
add a comment |
$begingroup$
Charcoal, 48 47 44 bytes
≔×NXθ≔×NXηFE+#×Nι«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»Eη⪫⭆θ⌊⟦ιλ⟧
Try it online! Link is to verbose version of code. Note: Trailing space. Edit: Now uses @xnor's algorithm. Explanation:
≔×NXθ≔×NXη
Input the width and height and convert them into strings of X
s.
FE+#×Nι
Loop over the characters +
and #
, converting them into strings of length given by the remaining two inputs. Then loop over those two strings.
«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»
Prefix and suffix the painting with the strings for the matting and framing.
Eη⪫⭆θ⌊⟦ιλ⟧
Loop over the strings, taking the minimum of the horizontal and vertical characters, and then double-spacing the rows, implicitly printing each row on its own line.
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy) / 05AB1E --no-lazy
, 32 31 bytes
и'Xׄ+#vyI©×UεX.ø}®FDнgy×.ø]€S»
Takes the input in the order height, width, matte, frame
. If the input order specified in the challenge is strict (still waiting on OP for verification), a leading s
(swap) can be added for +1 byte.
Required the --no-lazy
Elixir compiler flag in the new version of 05AB1E, since Elixir has some odd behavior due to lazy evaluation for nested maps/loops (here the result without this flag).
Try it online in the legacy version of 05AB1E.
Try it online in the new version of 05AB1E with added --no-lazy
flag.
Explanation:
и # Repeat the second (implicit) input the first (implicit) input amount of
# times as list
'X× '# Repeat "X" that many times
„+#v # Loop `y` over the characters ["+","#"]:
y # Push character `y`
I # Push the next input (matte in the first iteration; frame in the second)
© # And store it in the register (without popping)
× # Repeat character `y` that input amount of times
U # Pop and store that string in variable `X`
εX.ø} # Surround each string in the list with string `X`
®F # Inner loop the value from the register amount of times:
Dнg # Get the new width by taking the length of the first string
y× # Repeat character `y` that many times
.ø # And surround the list with this leading and trailing string
] # Close both the inner and outer loops
€S # Convert each inner string to a list of characters
» # Join every list of characters by spaces, and then every string by newlines
# (and output the result implicitly)
$endgroup$
add a comment |
$begingroup$
MATL, 24 bytes
&l,ithYaQ]'#+X'w)TFX*cYv
Input is: Height, Width, Matte Width, Frame Width.
Try it online!
Explanation
&l % Take height and width implicitly. Push matrix of that size with all
% entries equal to 1
, % Do twice
i % Take input
th % Duplicate, concatenate: gives a 1×2 vector with the number repeated
Ya % Pad matrix with those many zeros vertically and horizontally
Q % Add 1 to each entry
] % End
'#+X' % Push this string
w) % Index into the string with the padded matrix
TF % Push row vector [1 0]
X* % Kronecker product. This inserts columns of zeros
c % Convert to char again. Char 0 is will be displayed as space
Yv % Remove trailing spaces in each line. Implicitly display
$endgroup$
add a comment |
$begingroup$
R, 119 bytes
function(w,h,m,f)write(Reduce(function(x,y)rbind(y,cbind(y,x,y),y),rep(c("+","#"),c(m,f)),matrix("X",w,h)),1,w+2*f+2*m)
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 17 bytes
;ŒB“#+X+#”xʋⱮ«Ɱ/G
Try it online!
Argument 1: [Frame width, Matte width]
Argument 2: [Width, Height]
$endgroup$
add a comment |
$begingroup$
Python 3.8 (pre-release), 116 115 113 bytes
lambda a,b,c,d:"n".join((g:=['#'*(a+2*c+2*d)]*d+[(h:='#'*d)+'+'*(a+c*2)+h]*c)+[h+'+'*c+'X'*a+'+'*c+h]*b+g[::-1])
Try it online!
First attempt at golfing, will be improved soon.
a
is width, b
is height, c
is matte width, and d
is frame width.
-1 bytes using the :=
operator to define h
as e * d
-2 bytes thanks to Jo King suggesting me to remove the e and f parameters
EXPLANATION:
lambda a,b,c,d: Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively).
"n".join( Turn the list into a string, where each element is separated by newlines
(g:= Define g as (while still evaling the lists)...
['#'*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
[(h:='#'*d)+'+'*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
)+
[h+'+'*c+'X'*a+'+'*c+h]*b+ Form the middle row
g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
)
$endgroup$
$begingroup$
Removing thee
assignment saves you two bytes, thef
assignment isn't saving you anything
$endgroup$
– Jo King
yesterday
$begingroup$
@JoKing Oh wow, I forgot to remove thee
andf
assignments after discovering theg
shortcut
$endgroup$
– MilkyWay90
6 hours ago
add a comment |
$begingroup$
Javascript, 158 bytes
(w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
`)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
`)[q](m))+(e+r+"X"[q](w)+r+e+`
`)[q](h)+x+z)
Can probably be trimmed down a little bit
f=
(w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
`)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
`)[q](m))+(e+r+"X "[q](w)+r+e+`
`)[q](h)+x+z)
console.log(f(3,2,1,2))
$endgroup$
add a comment |
$begingroup$
Perl 6, 98 bytes
{map(&min,[X] map (($_='#'x$^d~'+'x$^c)~'X'x*~.flip).comb,$^a,$^b).rotor($b+2*($c+$d)).join("n")}
Try it online!
This is a port of xnor's Python answer.
Perl 6, 115 bytes
->a,b,c,d{$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
")}
Try it online!
Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X';
will assign 'X'
to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9;
will replace all the elements with indexes 3,4,5
of the lists with indexes 1,2,3
with 'X'
.
Explanation:
First, we initialise the list as a a+2*(c+d)
by b+2*(c+d)
rectangle of #
s.
$_=['#'xx$!*2+a]xx($!=c+d)*2+a;
State:
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
Then we assign the inner rectangle of +
s
.[d..^*-d;d..^a+$!+c]='+'xx*;
State:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
Finally, the innermost rectangle of X
s.
.[$!..^*-$!;$!..^a+$!]='X'xx*;
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
$endgroup$
add a comment |
$begingroup$
Canvas, 24 bytes
X;«[lx*e⤢}
X×*+⁸#⁸ *J ×O
Try it here!
Should be 5 bytes shorter, but isn't because Canvas is buggy..
$endgroup$
add a comment |
$begingroup$
Jelly, 35 31 28 bytes
®DxDị¥
⁽-F©ç«þ⁽-ȥç$ị“#+X”K€Y
Try it online!
Takes the input in the order frame, matte, width, height; comma separated. Outputs the ASCII-art picture with frame and matte. If the input order is strict I’d need to add more bytes (as per my original post).
$endgroup$
$begingroup$
I never program in Jelly, but surely 43134,43234 can be compressed? EDIT: I need to learn to read, you mention they can indeed be encoded in 4 bytes each. But what has the input-order to do with whether these numbers can be encoded or not? :S
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen the maximum integer that can be encoded using the two byte syntax is 32250; since both exceed that I can’t save the bytes. For now I’ll assume I can swap things around and revert if it’s not allowed!
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
Ah ok, I see.43134
will need 3 encoding characters, which including a leading/trailing character to indicate it's encoded will be 5 bytes as well. And does Jelly perhaps have a duplicate of some sort, since the second number is 100 larger than the first? Not sure if the actions push 43134, duplicate, push 100, plus, pair is possible and shorter in Jelly?
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen I originally tried that using +0,100 which doesn’t save any. I think I could use a nilad chain to use the fact that in a nilad ³ is 100, but if I’m allowed to reorder inputs the base 250 integers are better
$endgroup$
– Nick Kennedy
18 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
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
});
}
});
George Harris is a new contributor. Be nice, and check out our Code of Conduct.
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%2f181763%2foutput-visual-diagram-of-picture%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
13 Answers
13
active
oldest
votes
13 Answers
13
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Python 2, 98 bytes
w,h,a,b=input()
a*='+'
b*='#'
for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)
Try it online!
Prints a space-separated grid, strictly following the spec. I'm amused that *=
is used to convert a
and b
from numbers to strings.
Python 3 can save some bytes by avoiding ' '.join
, maybe more by using f-strings and assignment expressions.
Python 3, 95 bytes
def f(w,h,a,b):
a*='+';b*='#'
for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])
Try it online!
$endgroup$
$begingroup$
93 bytes for Python 3
$endgroup$
– Jo King
yesterday
$begingroup$
I've been outgolfed! NIce job, seems pretty golfed
$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
Nice golf! Very clever.
$endgroup$
– George Harris
5 hours ago
add a comment |
$begingroup$
Python 2, 98 bytes
w,h,a,b=input()
a*='+'
b*='#'
for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)
Try it online!
Prints a space-separated grid, strictly following the spec. I'm amused that *=
is used to convert a
and b
from numbers to strings.
Python 3 can save some bytes by avoiding ' '.join
, maybe more by using f-strings and assignment expressions.
Python 3, 95 bytes
def f(w,h,a,b):
a*='+';b*='#'
for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])
Try it online!
$endgroup$
$begingroup$
93 bytes for Python 3
$endgroup$
– Jo King
yesterday
$begingroup$
I've been outgolfed! NIce job, seems pretty golfed
$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
Nice golf! Very clever.
$endgroup$
– George Harris
5 hours ago
add a comment |
$begingroup$
Python 2, 98 bytes
w,h,a,b=input()
a*='+'
b*='#'
for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)
Try it online!
Prints a space-separated grid, strictly following the spec. I'm amused that *=
is used to convert a
and b
from numbers to strings.
Python 3 can save some bytes by avoiding ' '.join
, maybe more by using f-strings and assignment expressions.
Python 3, 95 bytes
def f(w,h,a,b):
a*='+';b*='#'
for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])
Try it online!
$endgroup$
Python 2, 98 bytes
w,h,a,b=input()
a*='+'
b*='#'
for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)
Try it online!
Prints a space-separated grid, strictly following the spec. I'm amused that *=
is used to convert a
and b
from numbers to strings.
Python 3 can save some bytes by avoiding ' '.join
, maybe more by using f-strings and assignment expressions.
Python 3, 95 bytes
def f(w,h,a,b):
a*='+';b*='#'
for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])
Try it online!
answered yesterday
xnorxnor
92.5k18188447
92.5k18188447
$begingroup$
93 bytes for Python 3
$endgroup$
– Jo King
yesterday
$begingroup$
I've been outgolfed! NIce job, seems pretty golfed
$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
Nice golf! Very clever.
$endgroup$
– George Harris
5 hours ago
add a comment |
$begingroup$
93 bytes for Python 3
$endgroup$
– Jo King
yesterday
$begingroup$
I've been outgolfed! NIce job, seems pretty golfed
$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
Nice golf! Very clever.
$endgroup$
– George Harris
5 hours ago
$begingroup$
93 bytes for Python 3
$endgroup$
– Jo King
yesterday
$begingroup$
93 bytes for Python 3
$endgroup$
– Jo King
yesterday
$begingroup$
I've been outgolfed! NIce job, seems pretty golfed
$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
I've been outgolfed! NIce job, seems pretty golfed
$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
Nice golf! Very clever.
$endgroup$
– George Harris
5 hours ago
$begingroup$
Nice golf! Very clever.
$endgroup$
– George Harris
5 hours ago
add a comment |
$begingroup$
JavaScript (ES6), 118 113 107 bytes
(w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(i).repeat([F,M,n][i])))(y=>g(x=>'#+X'[x<y?x:y]+' ',w)+`
`,h)
Try it online!
Commented
(w, h, M, F) => ( // given the 4 input variables
g = ( // g = helper function taking:
c, // c = callback function returning a string to repeat
n // n = number of times the painting part must be repeated
) => //
'01210' // string describing the picture structure, with:
.replace( // 0 = frame, 1 = matte, 2 = painting
/./g, // for each character in the above string:
i => // i = identifier of the current area
c(i) // invoke the callback function
.repeat // and repeat the result ...
([F, M, n][i]) // ... either F, M or n times
) // end of replace()
)( // outer call to g:
y => // callback function taking y:
g( // inner call to g:
x => // callback function taking x:
'#+X' // figure out which character to use
[x < y ? x : y] // according to the current position
+ ' ', // append a space
w // repeat the painting part w times
) // end of inner call
+ 'n', // append a line feed
h // repeat the painting part h times
) // end of outer call
$endgroup$
add a comment |
$begingroup$
JavaScript (ES6), 118 113 107 bytes
(w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(i).repeat([F,M,n][i])))(y=>g(x=>'#+X'[x<y?x:y]+' ',w)+`
`,h)
Try it online!
Commented
(w, h, M, F) => ( // given the 4 input variables
g = ( // g = helper function taking:
c, // c = callback function returning a string to repeat
n // n = number of times the painting part must be repeated
) => //
'01210' // string describing the picture structure, with:
.replace( // 0 = frame, 1 = matte, 2 = painting
/./g, // for each character in the above string:
i => // i = identifier of the current area
c(i) // invoke the callback function
.repeat // and repeat the result ...
([F, M, n][i]) // ... either F, M or n times
) // end of replace()
)( // outer call to g:
y => // callback function taking y:
g( // inner call to g:
x => // callback function taking x:
'#+X' // figure out which character to use
[x < y ? x : y] // according to the current position
+ ' ', // append a space
w // repeat the painting part w times
) // end of inner call
+ 'n', // append a line feed
h // repeat the painting part h times
) // end of outer call
$endgroup$
add a comment |
$begingroup$
JavaScript (ES6), 118 113 107 bytes
(w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(i).repeat([F,M,n][i])))(y=>g(x=>'#+X'[x<y?x:y]+' ',w)+`
`,h)
Try it online!
Commented
(w, h, M, F) => ( // given the 4 input variables
g = ( // g = helper function taking:
c, // c = callback function returning a string to repeat
n // n = number of times the painting part must be repeated
) => //
'01210' // string describing the picture structure, with:
.replace( // 0 = frame, 1 = matte, 2 = painting
/./g, // for each character in the above string:
i => // i = identifier of the current area
c(i) // invoke the callback function
.repeat // and repeat the result ...
([F, M, n][i]) // ... either F, M or n times
) // end of replace()
)( // outer call to g:
y => // callback function taking y:
g( // inner call to g:
x => // callback function taking x:
'#+X' // figure out which character to use
[x < y ? x : y] // according to the current position
+ ' ', // append a space
w // repeat the painting part w times
) // end of inner call
+ 'n', // append a line feed
h // repeat the painting part h times
) // end of outer call
$endgroup$
JavaScript (ES6), 118 113 107 bytes
(w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(i).repeat([F,M,n][i])))(y=>g(x=>'#+X'[x<y?x:y]+' ',w)+`
`,h)
Try it online!
Commented
(w, h, M, F) => ( // given the 4 input variables
g = ( // g = helper function taking:
c, // c = callback function returning a string to repeat
n // n = number of times the painting part must be repeated
) => //
'01210' // string describing the picture structure, with:
.replace( // 0 = frame, 1 = matte, 2 = painting
/./g, // for each character in the above string:
i => // i = identifier of the current area
c(i) // invoke the callback function
.repeat // and repeat the result ...
([F, M, n][i]) // ... either F, M or n times
) // end of replace()
)( // outer call to g:
y => // callback function taking y:
g( // inner call to g:
x => // callback function taking x:
'#+X' // figure out which character to use
[x < y ? x : y] // according to the current position
+ ' ', // append a space
w // repeat the painting part w times
) // end of inner call
+ 'n', // append a line feed
h // repeat the painting part h times
) // end of outer call
edited 17 hours ago
answered yesterday
ArnauldArnauld
79.2k796330
79.2k796330
add a comment |
add a comment |
$begingroup$
Wolfram Language (Mathematica), 142 bytes
(t=(p=Table)["# ",2(c=#4+#3)+#2,2c+#];p[t[[i,j]]="+ ",{j,z=#4+1,c+#3+#},{i,z,c+#3+#2}];p[t[[i,j]]="X ",{j,#3+z,c+#},{i,#3+z,c+#2}];""<>#&/@t)&
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 142 bytes
(t=(p=Table)["# ",2(c=#4+#3)+#2,2c+#];p[t[[i,j]]="+ ",{j,z=#4+1,c+#3+#},{i,z,c+#3+#2}];p[t[[i,j]]="X ",{j,#3+z,c+#},{i,#3+z,c+#2}];""<>#&/@t)&
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 142 bytes
(t=(p=Table)["# ",2(c=#4+#3)+#2,2c+#];p[t[[i,j]]="+ ",{j,z=#4+1,c+#3+#},{i,z,c+#3+#2}];p[t[[i,j]]="X ",{j,#3+z,c+#},{i,#3+z,c+#2}];""<>#&/@t)&
Try it online!
$endgroup$
Wolfram Language (Mathematica), 142 bytes
(t=(p=Table)["# ",2(c=#4+#3)+#2,2c+#];p[t[[i,j]]="+ ",{j,z=#4+1,c+#3+#},{i,z,c+#3+#2}];p[t[[i,j]]="X ",{j,#3+z,c+#},{i,#3+z,c+#2}];""<>#&/@t)&
Try it online!
edited 19 hours ago
answered yesterday
J42161217J42161217
13.3k21251
13.3k21251
add a comment |
add a comment |
$begingroup$
Charcoal, 48 47 44 bytes
≔×NXθ≔×NXηFE+#×Nι«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»Eη⪫⭆θ⌊⟦ιλ⟧
Try it online! Link is to verbose version of code. Note: Trailing space. Edit: Now uses @xnor's algorithm. Explanation:
≔×NXθ≔×NXη
Input the width and height and convert them into strings of X
s.
FE+#×Nι
Loop over the characters +
and #
, converting them into strings of length given by the remaining two inputs. Then loop over those two strings.
«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»
Prefix and suffix the painting with the strings for the matting and framing.
Eη⪫⭆θ⌊⟦ιλ⟧
Loop over the strings, taking the minimum of the horizontal and vertical characters, and then double-spacing the rows, implicitly printing each row on its own line.
$endgroup$
add a comment |
$begingroup$
Charcoal, 48 47 44 bytes
≔×NXθ≔×NXηFE+#×Nι«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»Eη⪫⭆θ⌊⟦ιλ⟧
Try it online! Link is to verbose version of code. Note: Trailing space. Edit: Now uses @xnor's algorithm. Explanation:
≔×NXθ≔×NXη
Input the width and height and convert them into strings of X
s.
FE+#×Nι
Loop over the characters +
and #
, converting them into strings of length given by the remaining two inputs. Then loop over those two strings.
«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»
Prefix and suffix the painting with the strings for the matting and framing.
Eη⪫⭆θ⌊⟦ιλ⟧
Loop over the strings, taking the minimum of the horizontal and vertical characters, and then double-spacing the rows, implicitly printing each row on its own line.
$endgroup$
add a comment |
$begingroup$
Charcoal, 48 47 44 bytes
≔×NXθ≔×NXηFE+#×Nι«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»Eη⪫⭆θ⌊⟦ιλ⟧
Try it online! Link is to verbose version of code. Note: Trailing space. Edit: Now uses @xnor's algorithm. Explanation:
≔×NXθ≔×NXη
Input the width and height and convert them into strings of X
s.
FE+#×Nι
Loop over the characters +
and #
, converting them into strings of length given by the remaining two inputs. Then loop over those two strings.
«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»
Prefix and suffix the painting with the strings for the matting and framing.
Eη⪫⭆θ⌊⟦ιλ⟧
Loop over the strings, taking the minimum of the horizontal and vertical characters, and then double-spacing the rows, implicitly printing each row on its own line.
$endgroup$
Charcoal, 48 47 44 bytes
≔×NXθ≔×NXηFE+#×Nι«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»Eη⪫⭆θ⌊⟦ιλ⟧
Try it online! Link is to verbose version of code. Note: Trailing space. Edit: Now uses @xnor's algorithm. Explanation:
≔×NXθ≔×NXη
Input the width and height and convert them into strings of X
s.
FE+#×Nι
Loop over the characters +
and #
, converting them into strings of length given by the remaining two inputs. Then loop over those two strings.
«≔⁺ι⁺θιθ≔⁺ι⁺ηιη»
Prefix and suffix the painting with the strings for the matting and framing.
Eη⪫⭆θ⌊⟦ιλ⟧
Loop over the strings, taking the minimum of the horizontal and vertical characters, and then double-spacing the rows, implicitly printing each row on its own line.
edited 18 hours ago
answered yesterday
NeilNeil
81.8k745178
81.8k745178
add a comment |
add a comment |
$begingroup$
05AB1E (legacy) / 05AB1E --no-lazy
, 32 31 bytes
и'Xׄ+#vyI©×UεX.ø}®FDнgy×.ø]€S»
Takes the input in the order height, width, matte, frame
. If the input order specified in the challenge is strict (still waiting on OP for verification), a leading s
(swap) can be added for +1 byte.
Required the --no-lazy
Elixir compiler flag in the new version of 05AB1E, since Elixir has some odd behavior due to lazy evaluation for nested maps/loops (here the result without this flag).
Try it online in the legacy version of 05AB1E.
Try it online in the new version of 05AB1E with added --no-lazy
flag.
Explanation:
и # Repeat the second (implicit) input the first (implicit) input amount of
# times as list
'X× '# Repeat "X" that many times
„+#v # Loop `y` over the characters ["+","#"]:
y # Push character `y`
I # Push the next input (matte in the first iteration; frame in the second)
© # And store it in the register (without popping)
× # Repeat character `y` that input amount of times
U # Pop and store that string in variable `X`
εX.ø} # Surround each string in the list with string `X`
®F # Inner loop the value from the register amount of times:
Dнg # Get the new width by taking the length of the first string
y× # Repeat character `y` that many times
.ø # And surround the list with this leading and trailing string
] # Close both the inner and outer loops
€S # Convert each inner string to a list of characters
» # Join every list of characters by spaces, and then every string by newlines
# (and output the result implicitly)
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy) / 05AB1E --no-lazy
, 32 31 bytes
и'Xׄ+#vyI©×UεX.ø}®FDнgy×.ø]€S»
Takes the input in the order height, width, matte, frame
. If the input order specified in the challenge is strict (still waiting on OP for verification), a leading s
(swap) can be added for +1 byte.
Required the --no-lazy
Elixir compiler flag in the new version of 05AB1E, since Elixir has some odd behavior due to lazy evaluation for nested maps/loops (here the result without this flag).
Try it online in the legacy version of 05AB1E.
Try it online in the new version of 05AB1E with added --no-lazy
flag.
Explanation:
и # Repeat the second (implicit) input the first (implicit) input amount of
# times as list
'X× '# Repeat "X" that many times
„+#v # Loop `y` over the characters ["+","#"]:
y # Push character `y`
I # Push the next input (matte in the first iteration; frame in the second)
© # And store it in the register (without popping)
× # Repeat character `y` that input amount of times
U # Pop and store that string in variable `X`
εX.ø} # Surround each string in the list with string `X`
®F # Inner loop the value from the register amount of times:
Dнg # Get the new width by taking the length of the first string
y× # Repeat character `y` that many times
.ø # And surround the list with this leading and trailing string
] # Close both the inner and outer loops
€S # Convert each inner string to a list of characters
» # Join every list of characters by spaces, and then every string by newlines
# (and output the result implicitly)
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy) / 05AB1E --no-lazy
, 32 31 bytes
и'Xׄ+#vyI©×UεX.ø}®FDнgy×.ø]€S»
Takes the input in the order height, width, matte, frame
. If the input order specified in the challenge is strict (still waiting on OP for verification), a leading s
(swap) can be added for +1 byte.
Required the --no-lazy
Elixir compiler flag in the new version of 05AB1E, since Elixir has some odd behavior due to lazy evaluation for nested maps/loops (here the result without this flag).
Try it online in the legacy version of 05AB1E.
Try it online in the new version of 05AB1E with added --no-lazy
flag.
Explanation:
и # Repeat the second (implicit) input the first (implicit) input amount of
# times as list
'X× '# Repeat "X" that many times
„+#v # Loop `y` over the characters ["+","#"]:
y # Push character `y`
I # Push the next input (matte in the first iteration; frame in the second)
© # And store it in the register (without popping)
× # Repeat character `y` that input amount of times
U # Pop and store that string in variable `X`
εX.ø} # Surround each string in the list with string `X`
®F # Inner loop the value from the register amount of times:
Dнg # Get the new width by taking the length of the first string
y× # Repeat character `y` that many times
.ø # And surround the list with this leading and trailing string
] # Close both the inner and outer loops
€S # Convert each inner string to a list of characters
» # Join every list of characters by spaces, and then every string by newlines
# (and output the result implicitly)
$endgroup$
05AB1E (legacy) / 05AB1E --no-lazy
, 32 31 bytes
и'Xׄ+#vyI©×UεX.ø}®FDнgy×.ø]€S»
Takes the input in the order height, width, matte, frame
. If the input order specified in the challenge is strict (still waiting on OP for verification), a leading s
(swap) can be added for +1 byte.
Required the --no-lazy
Elixir compiler flag in the new version of 05AB1E, since Elixir has some odd behavior due to lazy evaluation for nested maps/loops (here the result without this flag).
Try it online in the legacy version of 05AB1E.
Try it online in the new version of 05AB1E with added --no-lazy
flag.
Explanation:
и # Repeat the second (implicit) input the first (implicit) input amount of
# times as list
'X× '# Repeat "X" that many times
„+#v # Loop `y` over the characters ["+","#"]:
y # Push character `y`
I # Push the next input (matte in the first iteration; frame in the second)
© # And store it in the register (without popping)
× # Repeat character `y` that input amount of times
U # Pop and store that string in variable `X`
εX.ø} # Surround each string in the list with string `X`
®F # Inner loop the value from the register amount of times:
Dнg # Get the new width by taking the length of the first string
y× # Repeat character `y` that many times
.ø # And surround the list with this leading and trailing string
] # Close both the inner and outer loops
€S # Convert each inner string to a list of characters
» # Join every list of characters by spaces, and then every string by newlines
# (and output the result implicitly)
edited 17 hours ago
answered 19 hours ago
Kevin CruijssenKevin Cruijssen
40.8k566210
40.8k566210
add a comment |
add a comment |
$begingroup$
MATL, 24 bytes
&l,ithYaQ]'#+X'w)TFX*cYv
Input is: Height, Width, Matte Width, Frame Width.
Try it online!
Explanation
&l % Take height and width implicitly. Push matrix of that size with all
% entries equal to 1
, % Do twice
i % Take input
th % Duplicate, concatenate: gives a 1×2 vector with the number repeated
Ya % Pad matrix with those many zeros vertically and horizontally
Q % Add 1 to each entry
] % End
'#+X' % Push this string
w) % Index into the string with the padded matrix
TF % Push row vector [1 0]
X* % Kronecker product. This inserts columns of zeros
c % Convert to char again. Char 0 is will be displayed as space
Yv % Remove trailing spaces in each line. Implicitly display
$endgroup$
add a comment |
$begingroup$
MATL, 24 bytes
&l,ithYaQ]'#+X'w)TFX*cYv
Input is: Height, Width, Matte Width, Frame Width.
Try it online!
Explanation
&l % Take height and width implicitly. Push matrix of that size with all
% entries equal to 1
, % Do twice
i % Take input
th % Duplicate, concatenate: gives a 1×2 vector with the number repeated
Ya % Pad matrix with those many zeros vertically and horizontally
Q % Add 1 to each entry
] % End
'#+X' % Push this string
w) % Index into the string with the padded matrix
TF % Push row vector [1 0]
X* % Kronecker product. This inserts columns of zeros
c % Convert to char again. Char 0 is will be displayed as space
Yv % Remove trailing spaces in each line. Implicitly display
$endgroup$
add a comment |
$begingroup$
MATL, 24 bytes
&l,ithYaQ]'#+X'w)TFX*cYv
Input is: Height, Width, Matte Width, Frame Width.
Try it online!
Explanation
&l % Take height and width implicitly. Push matrix of that size with all
% entries equal to 1
, % Do twice
i % Take input
th % Duplicate, concatenate: gives a 1×2 vector with the number repeated
Ya % Pad matrix with those many zeros vertically and horizontally
Q % Add 1 to each entry
] % End
'#+X' % Push this string
w) % Index into the string with the padded matrix
TF % Push row vector [1 0]
X* % Kronecker product. This inserts columns of zeros
c % Convert to char again. Char 0 is will be displayed as space
Yv % Remove trailing spaces in each line. Implicitly display
$endgroup$
MATL, 24 bytes
&l,ithYaQ]'#+X'w)TFX*cYv
Input is: Height, Width, Matte Width, Frame Width.
Try it online!
Explanation
&l % Take height and width implicitly. Push matrix of that size with all
% entries equal to 1
, % Do twice
i % Take input
th % Duplicate, concatenate: gives a 1×2 vector with the number repeated
Ya % Pad matrix with those many zeros vertically and horizontally
Q % Add 1 to each entry
] % End
'#+X' % Push this string
w) % Index into the string with the padded matrix
TF % Push row vector [1 0]
X* % Kronecker product. This inserts columns of zeros
c % Convert to char again. Char 0 is will be displayed as space
Yv % Remove trailing spaces in each line. Implicitly display
edited 13 hours ago
answered 14 hours ago
Luis MendoLuis Mendo
74.9k888291
74.9k888291
add a comment |
add a comment |
$begingroup$
R, 119 bytes
function(w,h,m,f)write(Reduce(function(x,y)rbind(y,cbind(y,x,y),y),rep(c("+","#"),c(m,f)),matrix("X",w,h)),1,w+2*f+2*m)
Try it online!
$endgroup$
add a comment |
$begingroup$
R, 119 bytes
function(w,h,m,f)write(Reduce(function(x,y)rbind(y,cbind(y,x,y),y),rep(c("+","#"),c(m,f)),matrix("X",w,h)),1,w+2*f+2*m)
Try it online!
$endgroup$
add a comment |
$begingroup$
R, 119 bytes
function(w,h,m,f)write(Reduce(function(x,y)rbind(y,cbind(y,x,y),y),rep(c("+","#"),c(m,f)),matrix("X",w,h)),1,w+2*f+2*m)
Try it online!
$endgroup$
R, 119 bytes
function(w,h,m,f)write(Reduce(function(x,y)rbind(y,cbind(y,x,y),y),rep(c("+","#"),c(m,f)),matrix("X",w,h)),1,w+2*f+2*m)
Try it online!
answered 13 hours ago
GiuseppeGiuseppe
16.9k31052
16.9k31052
add a comment |
add a comment |
$begingroup$
Jelly, 17 bytes
;ŒB“#+X+#”xʋⱮ«Ɱ/G
Try it online!
Argument 1: [Frame width, Matte width]
Argument 2: [Width, Height]
$endgroup$
add a comment |
$begingroup$
Jelly, 17 bytes
;ŒB“#+X+#”xʋⱮ«Ɱ/G
Try it online!
Argument 1: [Frame width, Matte width]
Argument 2: [Width, Height]
$endgroup$
add a comment |
$begingroup$
Jelly, 17 bytes
;ŒB“#+X+#”xʋⱮ«Ɱ/G
Try it online!
Argument 1: [Frame width, Matte width]
Argument 2: [Width, Height]
$endgroup$
Jelly, 17 bytes
;ŒB“#+X+#”xʋⱮ«Ɱ/G
Try it online!
Argument 1: [Frame width, Matte width]
Argument 2: [Width, Height]
answered 12 hours ago
Erik the OutgolferErik the Outgolfer
32.6k429105
32.6k429105
add a comment |
add a comment |
$begingroup$
Python 3.8 (pre-release), 116 115 113 bytes
lambda a,b,c,d:"n".join((g:=['#'*(a+2*c+2*d)]*d+[(h:='#'*d)+'+'*(a+c*2)+h]*c)+[h+'+'*c+'X'*a+'+'*c+h]*b+g[::-1])
Try it online!
First attempt at golfing, will be improved soon.
a
is width, b
is height, c
is matte width, and d
is frame width.
-1 bytes using the :=
operator to define h
as e * d
-2 bytes thanks to Jo King suggesting me to remove the e and f parameters
EXPLANATION:
lambda a,b,c,d: Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively).
"n".join( Turn the list into a string, where each element is separated by newlines
(g:= Define g as (while still evaling the lists)...
['#'*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
[(h:='#'*d)+'+'*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
)+
[h+'+'*c+'X'*a+'+'*c+h]*b+ Form the middle row
g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
)
$endgroup$
$begingroup$
Removing thee
assignment saves you two bytes, thef
assignment isn't saving you anything
$endgroup$
– Jo King
yesterday
$begingroup$
@JoKing Oh wow, I forgot to remove thee
andf
assignments after discovering theg
shortcut
$endgroup$
– MilkyWay90
6 hours ago
add a comment |
$begingroup$
Python 3.8 (pre-release), 116 115 113 bytes
lambda a,b,c,d:"n".join((g:=['#'*(a+2*c+2*d)]*d+[(h:='#'*d)+'+'*(a+c*2)+h]*c)+[h+'+'*c+'X'*a+'+'*c+h]*b+g[::-1])
Try it online!
First attempt at golfing, will be improved soon.
a
is width, b
is height, c
is matte width, and d
is frame width.
-1 bytes using the :=
operator to define h
as e * d
-2 bytes thanks to Jo King suggesting me to remove the e and f parameters
EXPLANATION:
lambda a,b,c,d: Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively).
"n".join( Turn the list into a string, where each element is separated by newlines
(g:= Define g as (while still evaling the lists)...
['#'*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
[(h:='#'*d)+'+'*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
)+
[h+'+'*c+'X'*a+'+'*c+h]*b+ Form the middle row
g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
)
$endgroup$
$begingroup$
Removing thee
assignment saves you two bytes, thef
assignment isn't saving you anything
$endgroup$
– Jo King
yesterday
$begingroup$
@JoKing Oh wow, I forgot to remove thee
andf
assignments after discovering theg
shortcut
$endgroup$
– MilkyWay90
6 hours ago
add a comment |
$begingroup$
Python 3.8 (pre-release), 116 115 113 bytes
lambda a,b,c,d:"n".join((g:=['#'*(a+2*c+2*d)]*d+[(h:='#'*d)+'+'*(a+c*2)+h]*c)+[h+'+'*c+'X'*a+'+'*c+h]*b+g[::-1])
Try it online!
First attempt at golfing, will be improved soon.
a
is width, b
is height, c
is matte width, and d
is frame width.
-1 bytes using the :=
operator to define h
as e * d
-2 bytes thanks to Jo King suggesting me to remove the e and f parameters
EXPLANATION:
lambda a,b,c,d: Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively).
"n".join( Turn the list into a string, where each element is separated by newlines
(g:= Define g as (while still evaling the lists)...
['#'*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
[(h:='#'*d)+'+'*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
)+
[h+'+'*c+'X'*a+'+'*c+h]*b+ Form the middle row
g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
)
$endgroup$
Python 3.8 (pre-release), 116 115 113 bytes
lambda a,b,c,d:"n".join((g:=['#'*(a+2*c+2*d)]*d+[(h:='#'*d)+'+'*(a+c*2)+h]*c)+[h+'+'*c+'X'*a+'+'*c+h]*b+g[::-1])
Try it online!
First attempt at golfing, will be improved soon.
a
is width, b
is height, c
is matte width, and d
is frame width.
-1 bytes using the :=
operator to define h
as e * d
-2 bytes thanks to Jo King suggesting me to remove the e and f parameters
EXPLANATION:
lambda a,b,c,d: Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively).
"n".join( Turn the list into a string, where each element is separated by newlines
(g:= Define g as (while still evaling the lists)...
['#'*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
[(h:='#'*d)+'+'*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
)+
[h+'+'*c+'X'*a+'+'*c+h]*b+ Form the middle row
g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
)
edited 6 hours ago
answered yesterday
MilkyWay90MilkyWay90
543212
543212
$begingroup$
Removing thee
assignment saves you two bytes, thef
assignment isn't saving you anything
$endgroup$
– Jo King
yesterday
$begingroup$
@JoKing Oh wow, I forgot to remove thee
andf
assignments after discovering theg
shortcut
$endgroup$
– MilkyWay90
6 hours ago
add a comment |
$begingroup$
Removing thee
assignment saves you two bytes, thef
assignment isn't saving you anything
$endgroup$
– Jo King
yesterday
$begingroup$
@JoKing Oh wow, I forgot to remove thee
andf
assignments after discovering theg
shortcut
$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
Removing the
e
assignment saves you two bytes, the f
assignment isn't saving you anything$endgroup$
– Jo King
yesterday
$begingroup$
Removing the
e
assignment saves you two bytes, the f
assignment isn't saving you anything$endgroup$
– Jo King
yesterday
$begingroup$
@JoKing Oh wow, I forgot to remove the
e
and f
assignments after discovering the g
shortcut$endgroup$
– MilkyWay90
6 hours ago
$begingroup$
@JoKing Oh wow, I forgot to remove the
e
and f
assignments after discovering the g
shortcut$endgroup$
– MilkyWay90
6 hours ago
add a comment |
$begingroup$
Javascript, 158 bytes
(w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
`)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
`)[q](m))+(e+r+"X"[q](w)+r+e+`
`)[q](h)+x+z)
Can probably be trimmed down a little bit
f=
(w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
`)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
`)[q](m))+(e+r+"X "[q](w)+r+e+`
`)[q](h)+x+z)
console.log(f(3,2,1,2))
$endgroup$
add a comment |
$begingroup$
Javascript, 158 bytes
(w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
`)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
`)[q](m))+(e+r+"X"[q](w)+r+e+`
`)[q](h)+x+z)
Can probably be trimmed down a little bit
f=
(w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
`)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
`)[q](m))+(e+r+"X "[q](w)+r+e+`
`)[q](h)+x+z)
console.log(f(3,2,1,2))
$endgroup$
add a comment |
$begingroup$
Javascript, 158 bytes
(w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
`)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
`)[q](m))+(e+r+"X"[q](w)+r+e+`
`)[q](h)+x+z)
Can probably be trimmed down a little bit
f=
(w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
`)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
`)[q](m))+(e+r+"X "[q](w)+r+e+`
`)[q](h)+x+z)
console.log(f(3,2,1,2))
$endgroup$
Javascript, 158 bytes
(w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
`)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
`)[q](m))+(e+r+"X"[q](w)+r+e+`
`)[q](h)+x+z)
Can probably be trimmed down a little bit
f=
(w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
`)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
`)[q](m))+(e+r+"X "[q](w)+r+e+`
`)[q](h)+x+z)
console.log(f(3,2,1,2))
f=
(w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
`)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
`)[q](m))+(e+r+"X "[q](w)+r+e+`
`)[q](h)+x+z)
console.log(f(3,2,1,2))
f=
(w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
`)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
`)[q](m))+(e+r+"X "[q](w)+r+e+`
`)[q](h)+x+z)
console.log(f(3,2,1,2))
answered yesterday
zeveezevee
58029
58029
add a comment |
add a comment |
$begingroup$
Perl 6, 98 bytes
{map(&min,[X] map (($_='#'x$^d~'+'x$^c)~'X'x*~.flip).comb,$^a,$^b).rotor($b+2*($c+$d)).join("n")}
Try it online!
This is a port of xnor's Python answer.
Perl 6, 115 bytes
->a,b,c,d{$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
")}
Try it online!
Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X';
will assign 'X'
to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9;
will replace all the elements with indexes 3,4,5
of the lists with indexes 1,2,3
with 'X'
.
Explanation:
First, we initialise the list as a a+2*(c+d)
by b+2*(c+d)
rectangle of #
s.
$_=['#'xx$!*2+a]xx($!=c+d)*2+a;
State:
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
Then we assign the inner rectangle of +
s
.[d..^*-d;d..^a+$!+c]='+'xx*;
State:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
Finally, the innermost rectangle of X
s.
.[$!..^*-$!;$!..^a+$!]='X'xx*;
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
$endgroup$
add a comment |
$begingroup$
Perl 6, 98 bytes
{map(&min,[X] map (($_='#'x$^d~'+'x$^c)~'X'x*~.flip).comb,$^a,$^b).rotor($b+2*($c+$d)).join("n")}
Try it online!
This is a port of xnor's Python answer.
Perl 6, 115 bytes
->a,b,c,d{$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
")}
Try it online!
Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X';
will assign 'X'
to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9;
will replace all the elements with indexes 3,4,5
of the lists with indexes 1,2,3
with 'X'
.
Explanation:
First, we initialise the list as a a+2*(c+d)
by b+2*(c+d)
rectangle of #
s.
$_=['#'xx$!*2+a]xx($!=c+d)*2+a;
State:
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
Then we assign the inner rectangle of +
s
.[d..^*-d;d..^a+$!+c]='+'xx*;
State:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
Finally, the innermost rectangle of X
s.
.[$!..^*-$!;$!..^a+$!]='X'xx*;
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
$endgroup$
add a comment |
$begingroup$
Perl 6, 98 bytes
{map(&min,[X] map (($_='#'x$^d~'+'x$^c)~'X'x*~.flip).comb,$^a,$^b).rotor($b+2*($c+$d)).join("n")}
Try it online!
This is a port of xnor's Python answer.
Perl 6, 115 bytes
->a,b,c,d{$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
")}
Try it online!
Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X';
will assign 'X'
to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9;
will replace all the elements with indexes 3,4,5
of the lists with indexes 1,2,3
with 'X'
.
Explanation:
First, we initialise the list as a a+2*(c+d)
by b+2*(c+d)
rectangle of #
s.
$_=['#'xx$!*2+a]xx($!=c+d)*2+a;
State:
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
Then we assign the inner rectangle of +
s
.[d..^*-d;d..^a+$!+c]='+'xx*;
State:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
Finally, the innermost rectangle of X
s.
.[$!..^*-$!;$!..^a+$!]='X'xx*;
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
$endgroup$
Perl 6, 98 bytes
{map(&min,[X] map (($_='#'x$^d~'+'x$^c)~'X'x*~.flip).comb,$^a,$^b).rotor($b+2*($c+$d)).join("n")}
Try it online!
This is a port of xnor's Python answer.
Perl 6, 115 bytes
->a,b,c,d{$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
")}
Try it online!
Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X';
will assign 'X'
to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9;
will replace all the elements with indexes 3,4,5
of the lists with indexes 1,2,3
with 'X'
.
Explanation:
First, we initialise the list as a a+2*(c+d)
by b+2*(c+d)
rectangle of #
s.
$_=['#'xx$!*2+a]xx($!=c+d)*2+a;
State:
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
Then we assign the inner rectangle of +
s
.[d..^*-d;d..^a+$!+c]='+'xx*;
State:
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
Finally, the innermost rectangle of X
s.
.[$!..^*-$!;$!..^a+$!]='X'xx*;
# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #
edited yesterday
answered yesterday
Jo KingJo King
25k359128
25k359128
add a comment |
add a comment |
$begingroup$
Canvas, 24 bytes
X;«[lx*e⤢}
X×*+⁸#⁸ *J ×O
Try it here!
Should be 5 bytes shorter, but isn't because Canvas is buggy..
$endgroup$
add a comment |
$begingroup$
Canvas, 24 bytes
X;«[lx*e⤢}
X×*+⁸#⁸ *J ×O
Try it here!
Should be 5 bytes shorter, but isn't because Canvas is buggy..
$endgroup$
add a comment |
$begingroup$
Canvas, 24 bytes
X;«[lx*e⤢}
X×*+⁸#⁸ *J ×O
Try it here!
Should be 5 bytes shorter, but isn't because Canvas is buggy..
$endgroup$
Canvas, 24 bytes
X;«[lx*e⤢}
X×*+⁸#⁸ *J ×O
Try it here!
Should be 5 bytes shorter, but isn't because Canvas is buggy..
answered 13 hours ago
dzaimadzaima
15.6k22059
15.6k22059
add a comment |
add a comment |
$begingroup$
Jelly, 35 31 28 bytes
®DxDị¥
⁽-F©ç«þ⁽-ȥç$ị“#+X”K€Y
Try it online!
Takes the input in the order frame, matte, width, height; comma separated. Outputs the ASCII-art picture with frame and matte. If the input order is strict I’d need to add more bytes (as per my original post).
$endgroup$
$begingroup$
I never program in Jelly, but surely 43134,43234 can be compressed? EDIT: I need to learn to read, you mention they can indeed be encoded in 4 bytes each. But what has the input-order to do with whether these numbers can be encoded or not? :S
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen the maximum integer that can be encoded using the two byte syntax is 32250; since both exceed that I can’t save the bytes. For now I’ll assume I can swap things around and revert if it’s not allowed!
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
Ah ok, I see.43134
will need 3 encoding characters, which including a leading/trailing character to indicate it's encoded will be 5 bytes as well. And does Jelly perhaps have a duplicate of some sort, since the second number is 100 larger than the first? Not sure if the actions push 43134, duplicate, push 100, plus, pair is possible and shorter in Jelly?
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen I originally tried that using +0,100 which doesn’t save any. I think I could use a nilad chain to use the fact that in a nilad ³ is 100, but if I’m allowed to reorder inputs the base 250 integers are better
$endgroup$
– Nick Kennedy
18 hours ago
add a comment |
$begingroup$
Jelly, 35 31 28 bytes
®DxDị¥
⁽-F©ç«þ⁽-ȥç$ị“#+X”K€Y
Try it online!
Takes the input in the order frame, matte, width, height; comma separated. Outputs the ASCII-art picture with frame and matte. If the input order is strict I’d need to add more bytes (as per my original post).
$endgroup$
$begingroup$
I never program in Jelly, but surely 43134,43234 can be compressed? EDIT: I need to learn to read, you mention they can indeed be encoded in 4 bytes each. But what has the input-order to do with whether these numbers can be encoded or not? :S
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen the maximum integer that can be encoded using the two byte syntax is 32250; since both exceed that I can’t save the bytes. For now I’ll assume I can swap things around and revert if it’s not allowed!
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
Ah ok, I see.43134
will need 3 encoding characters, which including a leading/trailing character to indicate it's encoded will be 5 bytes as well. And does Jelly perhaps have a duplicate of some sort, since the second number is 100 larger than the first? Not sure if the actions push 43134, duplicate, push 100, plus, pair is possible and shorter in Jelly?
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen I originally tried that using +0,100 which doesn’t save any. I think I could use a nilad chain to use the fact that in a nilad ³ is 100, but if I’m allowed to reorder inputs the base 250 integers are better
$endgroup$
– Nick Kennedy
18 hours ago
add a comment |
$begingroup$
Jelly, 35 31 28 bytes
®DxDị¥
⁽-F©ç«þ⁽-ȥç$ị“#+X”K€Y
Try it online!
Takes the input in the order frame, matte, width, height; comma separated. Outputs the ASCII-art picture with frame and matte. If the input order is strict I’d need to add more bytes (as per my original post).
$endgroup$
Jelly, 35 31 28 bytes
®DxDị¥
⁽-F©ç«þ⁽-ȥç$ị“#+X”K€Y
Try it online!
Takes the input in the order frame, matte, width, height; comma separated. Outputs the ASCII-art picture with frame and matte. If the input order is strict I’d need to add more bytes (as per my original post).
edited 13 hours ago
answered 20 hours ago
Nick KennedyNick Kennedy
80137
80137
$begingroup$
I never program in Jelly, but surely 43134,43234 can be compressed? EDIT: I need to learn to read, you mention they can indeed be encoded in 4 bytes each. But what has the input-order to do with whether these numbers can be encoded or not? :S
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen the maximum integer that can be encoded using the two byte syntax is 32250; since both exceed that I can’t save the bytes. For now I’ll assume I can swap things around and revert if it’s not allowed!
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
Ah ok, I see.43134
will need 3 encoding characters, which including a leading/trailing character to indicate it's encoded will be 5 bytes as well. And does Jelly perhaps have a duplicate of some sort, since the second number is 100 larger than the first? Not sure if the actions push 43134, duplicate, push 100, plus, pair is possible and shorter in Jelly?
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen I originally tried that using +0,100 which doesn’t save any. I think I could use a nilad chain to use the fact that in a nilad ³ is 100, but if I’m allowed to reorder inputs the base 250 integers are better
$endgroup$
– Nick Kennedy
18 hours ago
add a comment |
$begingroup$
I never program in Jelly, but surely 43134,43234 can be compressed? EDIT: I need to learn to read, you mention they can indeed be encoded in 4 bytes each. But what has the input-order to do with whether these numbers can be encoded or not? :S
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen the maximum integer that can be encoded using the two byte syntax is 32250; since both exceed that I can’t save the bytes. For now I’ll assume I can swap things around and revert if it’s not allowed!
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
Ah ok, I see.43134
will need 3 encoding characters, which including a leading/trailing character to indicate it's encoded will be 5 bytes as well. And does Jelly perhaps have a duplicate of some sort, since the second number is 100 larger than the first? Not sure if the actions push 43134, duplicate, push 100, plus, pair is possible and shorter in Jelly?
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen I originally tried that using +0,100 which doesn’t save any. I think I could use a nilad chain to use the fact that in a nilad ³ is 100, but if I’m allowed to reorder inputs the base 250 integers are better
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
I never program in Jelly, but surely 43134,43234 can be compressed? EDIT: I need to learn to read, you mention they can indeed be encoded in 4 bytes each. But what has the input-order to do with whether these numbers can be encoded or not? :S
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
I never program in Jelly, but surely 43134,43234 can be compressed? EDIT: I need to learn to read, you mention they can indeed be encoded in 4 bytes each. But what has the input-order to do with whether these numbers can be encoded or not? :S
$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen the maximum integer that can be encoded using the two byte syntax is 32250; since both exceed that I can’t save the bytes. For now I’ll assume I can swap things around and revert if it’s not allowed!
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
@KevinCruijssen the maximum integer that can be encoded using the two byte syntax is 32250; since both exceed that I can’t save the bytes. For now I’ll assume I can swap things around and revert if it’s not allowed!
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
Ah ok, I see.
43134
will need 3 encoding characters, which including a leading/trailing character to indicate it's encoded will be 5 bytes as well. And does Jelly perhaps have a duplicate of some sort, since the second number is 100 larger than the first? Not sure if the actions push 43134, duplicate, push 100, plus, pair is possible and shorter in Jelly?$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
Ah ok, I see.
43134
will need 3 encoding characters, which including a leading/trailing character to indicate it's encoded will be 5 bytes as well. And does Jelly perhaps have a duplicate of some sort, since the second number is 100 larger than the first? Not sure if the actions push 43134, duplicate, push 100, plus, pair is possible and shorter in Jelly?$endgroup$
– Kevin Cruijssen
18 hours ago
$begingroup$
@KevinCruijssen I originally tried that using +0,100 which doesn’t save any. I think I could use a nilad chain to use the fact that in a nilad ³ is 100, but if I’m allowed to reorder inputs the base 250 integers are better
$endgroup$
– Nick Kennedy
18 hours ago
$begingroup$
@KevinCruijssen I originally tried that using +0,100 which doesn’t save any. I think I could use a nilad chain to use the fact that in a nilad ³ is 100, but if I’m allowed to reorder inputs the base 250 integers are better
$endgroup$
– Nick Kennedy
18 hours ago
add a comment |
George Harris is a new contributor. Be nice, and check out our Code of Conduct.
George Harris is a new contributor. Be nice, and check out our Code of Conduct.
George Harris is a new contributor. Be nice, and check out our Code of Conduct.
George Harris is a new contributor. Be nice, and check out our Code of Conduct.
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%2f181763%2foutput-visual-diagram-of-picture%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$
Nice challenge! For future challenges you may want to use The Sandbox
$endgroup$
– MilkyWay90
yesterday
2
$begingroup$
do you mind if the input is in a different order?
$endgroup$
– zevee
yesterday
1
$begingroup$
Can we return a list of strings?
$endgroup$
– MilkyWay90
yesterday
4
$begingroup$
Can any of the inputs be zero?
$endgroup$
– Laikoni
20 hours ago
1
$begingroup$
Can we have an space at the end of each line?
$endgroup$
– Luis Mendo
14 hours ago