Draw this diamond pattern
up vote
16
down vote
favorite
The below pattern will form the basis of this challenge.
/
/
/
/
/
// /
/ //
/
/
/
/
/
Given an input width and height, each >=1
, output the above ASCII art pattern repeated that many times, joining (and overlapping) at the small diamonds.
For example, here is an input with width = 2
and height = 1
:
/ /
/ /
/ /
/ /
/ /
// // /
/ // //
/ /
/ /
/ /
/ /
/ /
Here is an input width = 3
and height = 2
:
/ / /
/ / /
/ / /
/ / /
/ / /
// // // /
/ // // //
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
// // // /
/ // // //
/ / /
/ / /
/ / /
/ / /
/ / /
Rules and I/O
- Input and output can be given by any convenient method.
- You can print it to STDOUT or return it as a function result.
- Either a full program or a function are acceptable.
- Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.
Standard loopholes are forbidden.- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
code-golf ascii-art
add a comment |
up vote
16
down vote
favorite
The below pattern will form the basis of this challenge.
/
/
/
/
/
// /
/ //
/
/
/
/
/
Given an input width and height, each >=1
, output the above ASCII art pattern repeated that many times, joining (and overlapping) at the small diamonds.
For example, here is an input with width = 2
and height = 1
:
/ /
/ /
/ /
/ /
/ /
// // /
/ // //
/ /
/ /
/ /
/ /
/ /
Here is an input width = 3
and height = 2
:
/ / /
/ / /
/ / /
/ / /
/ / /
// // // /
/ // // //
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
// // // /
/ // // //
/ / /
/ / /
/ / /
/ / /
/ / /
Rules and I/O
- Input and output can be given by any convenient method.
- You can print it to STDOUT or return it as a function result.
- Either a full program or a function are acceptable.
- Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.
Standard loopholes are forbidden.- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
code-golf ascii-art
Loosely related
– Luis Mendo
yesterday
add a comment |
up vote
16
down vote
favorite
up vote
16
down vote
favorite
The below pattern will form the basis of this challenge.
/
/
/
/
/
// /
/ //
/
/
/
/
/
Given an input width and height, each >=1
, output the above ASCII art pattern repeated that many times, joining (and overlapping) at the small diamonds.
For example, here is an input with width = 2
and height = 1
:
/ /
/ /
/ /
/ /
/ /
// // /
/ // //
/ /
/ /
/ /
/ /
/ /
Here is an input width = 3
and height = 2
:
/ / /
/ / /
/ / /
/ / /
/ / /
// // // /
/ // // //
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
// // // /
/ // // //
/ / /
/ / /
/ / /
/ / /
/ / /
Rules and I/O
- Input and output can be given by any convenient method.
- You can print it to STDOUT or return it as a function result.
- Either a full program or a function are acceptable.
- Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.
Standard loopholes are forbidden.- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
code-golf ascii-art
The below pattern will form the basis of this challenge.
/
/
/
/
/
// /
/ //
/
/
/
/
/
Given an input width and height, each >=1
, output the above ASCII art pattern repeated that many times, joining (and overlapping) at the small diamonds.
For example, here is an input with width = 2
and height = 1
:
/ /
/ /
/ /
/ /
/ /
// // /
/ // //
/ /
/ /
/ /
/ /
/ /
Here is an input width = 3
and height = 2
:
/ / /
/ / /
/ / /
/ / /
/ / /
// // // /
/ // // //
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
// // // /
/ // // //
/ / /
/ / /
/ / /
/ / /
/ / /
Rules and I/O
- Input and output can be given by any convenient method.
- You can print it to STDOUT or return it as a function result.
- Either a full program or a function are acceptable.
- Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.
Standard loopholes are forbidden.- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
code-golf ascii-art
code-golf ascii-art
asked yesterday
AdmBorkBork
25.4k362223
25.4k362223
Loosely related
– Luis Mendo
yesterday
add a comment |
Loosely related
– Luis Mendo
yesterday
Loosely related
– Luis Mendo
yesterday
Loosely related
– Luis Mendo
yesterday
add a comment |
6 Answers
6
active
oldest
votes
up vote
5
down vote
Canvas, 26 25 24 21 bytes
4/╬/╬⁰r:⤢n⁸{╵×↔¹A×├m↶
Try it here!
Explanation:
4/ create a 4-long diagonal
╬ quad-palindromize it - big inner diamond
/╬ quad-palindromize "/" - small diamond
⁰r center the two added vertically
:⤢n overlap with its transpose
⁷{ for each input:
╵× repeat the canvas input+1 times horizontally
↔ reverse horizontally
¹ the input,
A× times 10,
├ plus 2
m mold the canvas to that width
↶ rotate the canvas anti-clockwise, setting up for the other input
add a comment |
up vote
5
down vote
JavaScript (ES8), 167 161 159 bytes
Takes input as (width)(height)
.
w=>h=>(g=h=>h?g(--h)+`
`+([4106,4016,31305,21504,17010]['0102344320'[h%=10]]+'').replace(/./g,c=>'\/'[c^h>5]||''.padEnd(c-1)).repeat(w+1).slice(8):'')(h*10+2)
Try it online!
How?
We encode the upper half of the pattern with digits:
$0$ means
$1$ means/
$n=2$ to $7$ means $n-1$ spaces
This gives:
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
1 ···/····· --> [3 spaces] [] [/] [5 spaces] --> 4016
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
2 ··/······ --> [2 spaces] [/] [2 spaces] [] [4 spaces] --> 31305
3 ·/······· --> [1 space] [/] [4 spaces] [] [3 spaces] --> 21504
4 /······/ --> [/] [6 spaces] [] [/] [] --> 17010
For the lower half, we use the rows $4,3,2,0$ with /
and inverted.
add a comment |
up vote
2
down vote
Perl 5 -p
, 148 bytes
$_='3A3'x$_.$/.'3B3
3A3
2/2\2
1/4\1
A6A
B6B
1\4/1
2\2/2
3B3
3A3
'=~s/^.*$/$&x$_/mger x<>.'3B3'x$_;s|A+|/\|g;s|B+|\/|g;s/d/$"x$&/ge;s|^ | |gm
Try it online!
add a comment |
up vote
2
down vote
Haskell, 179 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$["\/\ /"," \ / "," \ / "," \/ "," /\ "]
Try it online!
Haskell, 181 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$map t[49200,36058,31630,30010,29038]
t 0=""
t n="\ /"!!mod n 3:t(div n 3)
Try it online!
add a comment |
up vote
2
down vote
Charcoal, 24 23 bytes
´/↘²‖C↘‖MLF⊖NCχ⁰F⊖NC⁰χ
Try it online! Link is to verbose version of code. Explanation:
´/↘²
Draw one eighth of the original pattern.
‖C↘
Duplicate it to make one quarter of the original pattern.
‖ML
Duplicate it twice more to complete the original pattern.
F⊖NCχ⁰
Copy the required number of times horizontally.
F⊖NC⁰χ
Copy the required number of times vertically.
Note: I think ‖M↘L
should work for a two-byte saving but a) M↘
crashes and b) M↖
doesn't crash but appears to produce incorrect output.
add a comment |
up vote
0
down vote
JavaScript (ES6), 139 bytes
This is using quite a different approach from my initial answer, so I'm posting this separately.
Takes input as (width)(height)
.
w=>h=>(g=x=>y>8?` /\
`[a=(x+y*9)%10,b=(x+y)%10,x?(y%10>3&&2*(a==8)|b==5)|(y%10<6&&2*(a==6)|b==7):3]+g(x--?x:--y&&w):'')(w=w*10+2,y=-~h*10)
Try it online!
add a comment |
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
Canvas, 26 25 24 21 bytes
4/╬/╬⁰r:⤢n⁸{╵×↔¹A×├m↶
Try it here!
Explanation:
4/ create a 4-long diagonal
╬ quad-palindromize it - big inner diamond
/╬ quad-palindromize "/" - small diamond
⁰r center the two added vertically
:⤢n overlap with its transpose
⁷{ for each input:
╵× repeat the canvas input+1 times horizontally
↔ reverse horizontally
¹ the input,
A× times 10,
├ plus 2
m mold the canvas to that width
↶ rotate the canvas anti-clockwise, setting up for the other input
add a comment |
up vote
5
down vote
Canvas, 26 25 24 21 bytes
4/╬/╬⁰r:⤢n⁸{╵×↔¹A×├m↶
Try it here!
Explanation:
4/ create a 4-long diagonal
╬ quad-palindromize it - big inner diamond
/╬ quad-palindromize "/" - small diamond
⁰r center the two added vertically
:⤢n overlap with its transpose
⁷{ for each input:
╵× repeat the canvas input+1 times horizontally
↔ reverse horizontally
¹ the input,
A× times 10,
├ plus 2
m mold the canvas to that width
↶ rotate the canvas anti-clockwise, setting up for the other input
add a comment |
up vote
5
down vote
up vote
5
down vote
Canvas, 26 25 24 21 bytes
4/╬/╬⁰r:⤢n⁸{╵×↔¹A×├m↶
Try it here!
Explanation:
4/ create a 4-long diagonal
╬ quad-palindromize it - big inner diamond
/╬ quad-palindromize "/" - small diamond
⁰r center the two added vertically
:⤢n overlap with its transpose
⁷{ for each input:
╵× repeat the canvas input+1 times horizontally
↔ reverse horizontally
¹ the input,
A× times 10,
├ plus 2
m mold the canvas to that width
↶ rotate the canvas anti-clockwise, setting up for the other input
Canvas, 26 25 24 21 bytes
4/╬/╬⁰r:⤢n⁸{╵×↔¹A×├m↶
Try it here!
Explanation:
4/ create a 4-long diagonal
╬ quad-palindromize it - big inner diamond
/╬ quad-palindromize "/" - small diamond
⁰r center the two added vertically
:⤢n overlap with its transpose
⁷{ for each input:
╵× repeat the canvas input+1 times horizontally
↔ reverse horizontally
¹ the input,
A× times 10,
├ plus 2
m mold the canvas to that width
↶ rotate the canvas anti-clockwise, setting up for the other input
edited yesterday
answered yesterday
dzaima
13.8k21653
13.8k21653
add a comment |
add a comment |
up vote
5
down vote
JavaScript (ES8), 167 161 159 bytes
Takes input as (width)(height)
.
w=>h=>(g=h=>h?g(--h)+`
`+([4106,4016,31305,21504,17010]['0102344320'[h%=10]]+'').replace(/./g,c=>'\/'[c^h>5]||''.padEnd(c-1)).repeat(w+1).slice(8):'')(h*10+2)
Try it online!
How?
We encode the upper half of the pattern with digits:
$0$ means
$1$ means/
$n=2$ to $7$ means $n-1$ spaces
This gives:
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
1 ···/····· --> [3 spaces] [] [/] [5 spaces] --> 4016
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
2 ··/······ --> [2 spaces] [/] [2 spaces] [] [4 spaces] --> 31305
3 ·/······· --> [1 space] [/] [4 spaces] [] [3 spaces] --> 21504
4 /······/ --> [/] [6 spaces] [] [/] [] --> 17010
For the lower half, we use the rows $4,3,2,0$ with /
and inverted.
add a comment |
up vote
5
down vote
JavaScript (ES8), 167 161 159 bytes
Takes input as (width)(height)
.
w=>h=>(g=h=>h?g(--h)+`
`+([4106,4016,31305,21504,17010]['0102344320'[h%=10]]+'').replace(/./g,c=>'\/'[c^h>5]||''.padEnd(c-1)).repeat(w+1).slice(8):'')(h*10+2)
Try it online!
How?
We encode the upper half of the pattern with digits:
$0$ means
$1$ means/
$n=2$ to $7$ means $n-1$ spaces
This gives:
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
1 ···/····· --> [3 spaces] [] [/] [5 spaces] --> 4016
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
2 ··/······ --> [2 spaces] [/] [2 spaces] [] [4 spaces] --> 31305
3 ·/······· --> [1 space] [/] [4 spaces] [] [3 spaces] --> 21504
4 /······/ --> [/] [6 spaces] [] [/] [] --> 17010
For the lower half, we use the rows $4,3,2,0$ with /
and inverted.
add a comment |
up vote
5
down vote
up vote
5
down vote
JavaScript (ES8), 167 161 159 bytes
Takes input as (width)(height)
.
w=>h=>(g=h=>h?g(--h)+`
`+([4106,4016,31305,21504,17010]['0102344320'[h%=10]]+'').replace(/./g,c=>'\/'[c^h>5]||''.padEnd(c-1)).repeat(w+1).slice(8):'')(h*10+2)
Try it online!
How?
We encode the upper half of the pattern with digits:
$0$ means
$1$ means/
$n=2$ to $7$ means $n-1$ spaces
This gives:
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
1 ···/····· --> [3 spaces] [] [/] [5 spaces] --> 4016
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
2 ··/······ --> [2 spaces] [/] [2 spaces] [] [4 spaces] --> 31305
3 ·/······· --> [1 space] [/] [4 spaces] [] [3 spaces] --> 21504
4 /······/ --> [/] [6 spaces] [] [/] [] --> 17010
For the lower half, we use the rows $4,3,2,0$ with /
and inverted.
JavaScript (ES8), 167 161 159 bytes
Takes input as (width)(height)
.
w=>h=>(g=h=>h?g(--h)+`
`+([4106,4016,31305,21504,17010]['0102344320'[h%=10]]+'').replace(/./g,c=>'\/'[c^h>5]||''.padEnd(c-1)).repeat(w+1).slice(8):'')(h*10+2)
Try it online!
How?
We encode the upper half of the pattern with digits:
$0$ means
$1$ means/
$n=2$ to $7$ means $n-1$ spaces
This gives:
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
1 ···/····· --> [3 spaces] [] [/] [5 spaces] --> 4016
0 ···/····· --> [3 spaces] [/] [] [5 spaces] --> 4106
2 ··/······ --> [2 spaces] [/] [2 spaces] [] [4 spaces] --> 31305
3 ·/······· --> [1 space] [/] [4 spaces] [] [3 spaces] --> 21504
4 /······/ --> [/] [6 spaces] [] [/] [] --> 17010
For the lower half, we use the rows $4,3,2,0$ with /
and inverted.
edited 13 hours ago
answered yesterday
Arnauld
68k584288
68k584288
add a comment |
add a comment |
up vote
2
down vote
Perl 5 -p
, 148 bytes
$_='3A3'x$_.$/.'3B3
3A3
2/2\2
1/4\1
A6A
B6B
1\4/1
2\2/2
3B3
3A3
'=~s/^.*$/$&x$_/mger x<>.'3B3'x$_;s|A+|/\|g;s|B+|\/|g;s/d/$"x$&/ge;s|^ | |gm
Try it online!
add a comment |
up vote
2
down vote
Perl 5 -p
, 148 bytes
$_='3A3'x$_.$/.'3B3
3A3
2/2\2
1/4\1
A6A
B6B
1\4/1
2\2/2
3B3
3A3
'=~s/^.*$/$&x$_/mger x<>.'3B3'x$_;s|A+|/\|g;s|B+|\/|g;s/d/$"x$&/ge;s|^ | |gm
Try it online!
add a comment |
up vote
2
down vote
up vote
2
down vote
Perl 5 -p
, 148 bytes
$_='3A3'x$_.$/.'3B3
3A3
2/2\2
1/4\1
A6A
B6B
1\4/1
2\2/2
3B3
3A3
'=~s/^.*$/$&x$_/mger x<>.'3B3'x$_;s|A+|/\|g;s|B+|\/|g;s/d/$"x$&/ge;s|^ | |gm
Try it online!
Perl 5 -p
, 148 bytes
$_='3A3'x$_.$/.'3B3
3A3
2/2\2
1/4\1
A6A
B6B
1\4/1
2\2/2
3B3
3A3
'=~s/^.*$/$&x$_/mger x<>.'3B3'x$_;s|A+|/\|g;s|B+|\/|g;s/d/$"x$&/ge;s|^ | |gm
Try it online!
answered 23 hours ago
Xcali
4,890520
4,890520
add a comment |
add a comment |
up vote
2
down vote
Haskell, 179 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$["\/\ /"," \ / "," \ / "," \/ "," /\ "]
Try it online!
Haskell, 181 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$map t[49200,36058,31630,30010,29038]
t 0=""
t n="\ /"!!mod n 3:t(div n 3)
Try it online!
add a comment |
up vote
2
down vote
Haskell, 179 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$["\/\ /"," \ / "," \ / "," \/ "," /\ "]
Try it online!
Haskell, 181 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$map t[49200,36058,31630,30010,29038]
t 0=""
t n="\ /"!!mod n 3:t(div n 3)
Try it online!
add a comment |
up vote
2
down vote
up vote
2
down vote
Haskell, 179 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$["\/\ /"," \ / "," \ / "," \/ "," /\ "]
Try it online!
Haskell, 181 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$map t[49200,36058,31630,30010,29038]
t 0=""
t n="\ /"!!mod n 3:t(div n 3)
Try it online!
Haskell, 179 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$["\/\ /"," \ / "," \ / "," \/ "," /\ "]
Try it online!
Haskell, 181 bytes
k '\'='/'
k '/'='\'
k x=x
f x=take(10*x+2)
w#h=map(f w.cycle).f h.drop 9.cycle$(++).reverse=<<map(map k)$map t[49200,36058,31630,30010,29038]
t 0=""
t n="\ /"!!mod n 3:t(div n 3)
Try it online!
edited 10 hours ago
answered yesterday
ovs
18.1k21058
18.1k21058
add a comment |
add a comment |
up vote
2
down vote
Charcoal, 24 23 bytes
´/↘²‖C↘‖MLF⊖NCχ⁰F⊖NC⁰χ
Try it online! Link is to verbose version of code. Explanation:
´/↘²
Draw one eighth of the original pattern.
‖C↘
Duplicate it to make one quarter of the original pattern.
‖ML
Duplicate it twice more to complete the original pattern.
F⊖NCχ⁰
Copy the required number of times horizontally.
F⊖NC⁰χ
Copy the required number of times vertically.
Note: I think ‖M↘L
should work for a two-byte saving but a) M↘
crashes and b) M↖
doesn't crash but appears to produce incorrect output.
add a comment |
up vote
2
down vote
Charcoal, 24 23 bytes
´/↘²‖C↘‖MLF⊖NCχ⁰F⊖NC⁰χ
Try it online! Link is to verbose version of code. Explanation:
´/↘²
Draw one eighth of the original pattern.
‖C↘
Duplicate it to make one quarter of the original pattern.
‖ML
Duplicate it twice more to complete the original pattern.
F⊖NCχ⁰
Copy the required number of times horizontally.
F⊖NC⁰χ
Copy the required number of times vertically.
Note: I think ‖M↘L
should work for a two-byte saving but a) M↘
crashes and b) M↖
doesn't crash but appears to produce incorrect output.
add a comment |
up vote
2
down vote
up vote
2
down vote
Charcoal, 24 23 bytes
´/↘²‖C↘‖MLF⊖NCχ⁰F⊖NC⁰χ
Try it online! Link is to verbose version of code. Explanation:
´/↘²
Draw one eighth of the original pattern.
‖C↘
Duplicate it to make one quarter of the original pattern.
‖ML
Duplicate it twice more to complete the original pattern.
F⊖NCχ⁰
Copy the required number of times horizontally.
F⊖NC⁰χ
Copy the required number of times vertically.
Note: I think ‖M↘L
should work for a two-byte saving but a) M↘
crashes and b) M↖
doesn't crash but appears to produce incorrect output.
Charcoal, 24 23 bytes
´/↘²‖C↘‖MLF⊖NCχ⁰F⊖NC⁰χ
Try it online! Link is to verbose version of code. Explanation:
´/↘²
Draw one eighth of the original pattern.
‖C↘
Duplicate it to make one quarter of the original pattern.
‖ML
Duplicate it twice more to complete the original pattern.
F⊖NCχ⁰
Copy the required number of times horizontally.
F⊖NC⁰χ
Copy the required number of times vertically.
Note: I think ‖M↘L
should work for a two-byte saving but a) M↘
crashes and b) M↖
doesn't crash but appears to produce incorrect output.
edited 15 mins ago
answered yesterday
Neil
77.5k744174
77.5k744174
add a comment |
add a comment |
up vote
0
down vote
JavaScript (ES6), 139 bytes
This is using quite a different approach from my initial answer, so I'm posting this separately.
Takes input as (width)(height)
.
w=>h=>(g=x=>y>8?` /\
`[a=(x+y*9)%10,b=(x+y)%10,x?(y%10>3&&2*(a==8)|b==5)|(y%10<6&&2*(a==6)|b==7):3]+g(x--?x:--y&&w):'')(w=w*10+2,y=-~h*10)
Try it online!
add a comment |
up vote
0
down vote
JavaScript (ES6), 139 bytes
This is using quite a different approach from my initial answer, so I'm posting this separately.
Takes input as (width)(height)
.
w=>h=>(g=x=>y>8?` /\
`[a=(x+y*9)%10,b=(x+y)%10,x?(y%10>3&&2*(a==8)|b==5)|(y%10<6&&2*(a==6)|b==7):3]+g(x--?x:--y&&w):'')(w=w*10+2,y=-~h*10)
Try it online!
add a comment |
up vote
0
down vote
up vote
0
down vote
JavaScript (ES6), 139 bytes
This is using quite a different approach from my initial answer, so I'm posting this separately.
Takes input as (width)(height)
.
w=>h=>(g=x=>y>8?` /\
`[a=(x+y*9)%10,b=(x+y)%10,x?(y%10>3&&2*(a==8)|b==5)|(y%10<6&&2*(a==6)|b==7):3]+g(x--?x:--y&&w):'')(w=w*10+2,y=-~h*10)
Try it online!
JavaScript (ES6), 139 bytes
This is using quite a different approach from my initial answer, so I'm posting this separately.
Takes input as (width)(height)
.
w=>h=>(g=x=>y>8?` /\
`[a=(x+y*9)%10,b=(x+y)%10,x?(y%10>3&&2*(a==8)|b==5)|(y%10<6&&2*(a==6)|b==7):3]+g(x--?x:--y&&w):'')(w=w*10+2,y=-~h*10)
Try it online!
answered 1 min ago
Arnauld
68k584288
68k584288
add a comment |
add a comment |
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175619%2fdraw-this-diamond-pattern%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Loosely related
– Luis Mendo
yesterday