Determine if a grid contains another gridCount the contiguous submatricesDetermine if land is fully enclosed by fencesDetermine if Strings are equalRecognizing Repetition in stringsIs it a pangram?Find the largest and the smallest number in an arrayFlatten the Array!Split a grid into a gridPrint a quine that contains the inputMaking Squared WordsCheck if a string is entirely made of the same substring
What happens if I accidentally leave an app running and click "Install Now" in Software Updater?
no sense/need/point
Is 'contemporary' ambiguous and if so is there a better word?
Constitutional limitation of criminalizing behavior in US law?
How to preserve a rare version of a book?
Motion-trail-like lines
Hostile Divisor Numbers
In linear regression why does regularisation penalise the parameter values as well?
Why would one crossvalidate the random state number?
Some Russian letters overlap the next line of text when used in drop caps
How to calculate rate of axial precession?
In Futurama, how many beings has Leela slept with?
Gerrymandering Puzzle - Rig the Election
What does にとり mean?
In "Avengers: Endgame", what does this name refer to?
Why is my arithmetic with a long long int behaving this way?
about academic proof-reading, what to do in this situation?
Counting the Number of Real Roots of A Polynomial
How do I allocate more memory to an app on Sheepshaver running Mac OS 9?
How can a hefty sand storm happen in a thin atmosphere like Martian?
Sheared off exhasut pipe: How to fix without a welder?
Dihedral group D4 composition with custom labels
Should homeowners insurance cover the cost of the home?
Sci-fi/fantasy book - ships on steel runners skating across ice sheets
Determine if a grid contains another grid
Count the contiguous submatricesDetermine if land is fully enclosed by fencesDetermine if Strings are equalRecognizing Repetition in stringsIs it a pangram?Find the largest and the smallest number in an arrayFlatten the Array!Split a grid into a gridPrint a quine that contains the inputMaking Squared WordsCheck if a string is entirely made of the same substring
$begingroup$
Challenge
Create a function takes in two 2-dimensional arrays of Characters (or Strings if the programming language does not have characters as a datatype) as inputs: a and b.
Your task is to determine if b contains a. If this is so, return true. Otherwise, return false.
Sample Test Cases
a:
123
456
789
b:
123
456
789
should return true.
a:
code
golf
b:
thisis
code!!
golf!!
ohyeah
should return true.
a:
abcd
efgh
ijkl
b:
abcdef
ghijkl
mnopqr
should return false.
Least bytes wins.
code-golf string grid subsequence array
New contributor
$endgroup$
add a comment |
$begingroup$
Challenge
Create a function takes in two 2-dimensional arrays of Characters (or Strings if the programming language does not have characters as a datatype) as inputs: a and b.
Your task is to determine if b contains a. If this is so, return true. Otherwise, return false.
Sample Test Cases
a:
123
456
789
b:
123
456
789
should return true.
a:
code
golf
b:
thisis
code!!
golf!!
ohyeah
should return true.
a:
abcd
efgh
ijkl
b:
abcdef
ghijkl
mnopqr
should return false.
Least bytes wins.
code-golf string grid subsequence array
New contributor
$endgroup$
1
$begingroup$
Hi and welcome to codegolf! I edited your test cases to (hopefully) make them a bit more clear. Note that we have a sandbox for working on challenges before posting them to main. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
1
$begingroup$
Also, may I take the first array as an array of strings and the second as a string separated by newlines, even though my language(C#) has a character type built in?
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
@Neil Test cases 2 and 3 are not square.
$endgroup$
– Robin Ryder
4 hours ago
1
$begingroup$
Could you add a truthy test case wherea
isn't onb
's left edge and a falsey test case where each line ofa
appears in consecutive lines ofb
but with their left edges staggered?
$endgroup$
– Shaggy
3 hours ago
add a comment |
$begingroup$
Challenge
Create a function takes in two 2-dimensional arrays of Characters (or Strings if the programming language does not have characters as a datatype) as inputs: a and b.
Your task is to determine if b contains a. If this is so, return true. Otherwise, return false.
Sample Test Cases
a:
123
456
789
b:
123
456
789
should return true.
a:
code
golf
b:
thisis
code!!
golf!!
ohyeah
should return true.
a:
abcd
efgh
ijkl
b:
abcdef
ghijkl
mnopqr
should return false.
Least bytes wins.
code-golf string grid subsequence array
New contributor
$endgroup$
Challenge
Create a function takes in two 2-dimensional arrays of Characters (or Strings if the programming language does not have characters as a datatype) as inputs: a and b.
Your task is to determine if b contains a. If this is so, return true. Otherwise, return false.
Sample Test Cases
a:
123
456
789
b:
123
456
789
should return true.
a:
code
golf
b:
thisis
code!!
golf!!
ohyeah
should return true.
a:
abcd
efgh
ijkl
b:
abcdef
ghijkl
mnopqr
should return false.
Least bytes wins.
code-golf string grid subsequence array
code-golf string grid subsequence array
New contributor
New contributor
edited 5 hours ago
FryAmTheEggman
14.8k32583
14.8k32583
New contributor
asked 6 hours ago
HazardHazard
162
162
New contributor
New contributor
1
$begingroup$
Hi and welcome to codegolf! I edited your test cases to (hopefully) make them a bit more clear. Note that we have a sandbox for working on challenges before posting them to main. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
1
$begingroup$
Also, may I take the first array as an array of strings and the second as a string separated by newlines, even though my language(C#) has a character type built in?
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
@Neil Test cases 2 and 3 are not square.
$endgroup$
– Robin Ryder
4 hours ago
1
$begingroup$
Could you add a truthy test case wherea
isn't onb
's left edge and a falsey test case where each line ofa
appears in consecutive lines ofb
but with their left edges staggered?
$endgroup$
– Shaggy
3 hours ago
add a comment |
1
$begingroup$
Hi and welcome to codegolf! I edited your test cases to (hopefully) make them a bit more clear. Note that we have a sandbox for working on challenges before posting them to main. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
1
$begingroup$
Also, may I take the first array as an array of strings and the second as a string separated by newlines, even though my language(C#) has a character type built in?
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
@Neil Test cases 2 and 3 are not square.
$endgroup$
– Robin Ryder
4 hours ago
1
$begingroup$
Could you add a truthy test case wherea
isn't onb
's left edge and a falsey test case where each line ofa
appears in consecutive lines ofb
but with their left edges staggered?
$endgroup$
– Shaggy
3 hours ago
1
1
$begingroup$
Hi and welcome to codegolf! I edited your test cases to (hopefully) make them a bit more clear. Note that we have a sandbox for working on challenges before posting them to main. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
$begingroup$
Hi and welcome to codegolf! I edited your test cases to (hopefully) make them a bit more clear. Note that we have a sandbox for working on challenges before posting them to main. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
1
1
$begingroup$
Also, may I take the first array as an array of strings and the second as a string separated by newlines, even though my language(C#) has a character type built in?
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
Also, may I take the first array as an array of strings and the second as a string separated by newlines, even though my language(C#) has a character type built in?
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
@Neil Test cases 2 and 3 are not square.
$endgroup$
– Robin Ryder
4 hours ago
$begingroup$
@Neil Test cases 2 and 3 are not square.
$endgroup$
– Robin Ryder
4 hours ago
1
1
$begingroup$
Could you add a truthy test case where
a
isn't on b
's left edge and a falsey test case where each line of a
appears in consecutive lines of b
but with their left edges staggered?$endgroup$
– Shaggy
3 hours ago
$begingroup$
Could you add a truthy test case where
a
isn't on b
's left edge and a falsey test case where each line of a
appears in consecutive lines of b
but with their left edges staggered?$endgroup$
– Shaggy
3 hours ago
add a comment |
5 Answers
5
active
oldest
votes
$begingroup$
Brachylog (v2), 4 bytes
ss
Try it online!
Most easily run as a full program, as usual for a decision-problem, with a specified as a command-line argument, b on standard input. The question asks for a function, and the program also works as a function, with b on the left, a on the right, and output via producing an exception if and only if the decision is false.
Explanation
ss
s a substring of rows of the left input
… assert rectangular; swap row and column operations
s a substring of <s>rows</s> columns of the above matrix
implicit assert that the result can be the right input
The "assert rectangular" is, obviously, pointless, as the question guarantees that already. The rest of the program does the grid-finding for us by identifying a substring of the rows and of the columns, i.e. a submatrix.
Meta-discussion
We've had a very similar question before; I'd expect most answers to one question to be modifiable into answers to the other. I think this is the neater version of it, though.
$endgroup$
add a comment |
$begingroup$
Python 2, 106 118 bytes
lambda a,b,L=len:any(any(sum(A==B[j:j+L(A)]for A,B in zip(a,b[i:]))==L(a)for i in range(L(b)))for j in range(L(b[0])))
Try it online!
$endgroup$
$begingroup$
@Neil: Fixed now.
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
Python 2, 160 139 bytes
a,b=input()
l=len(b)+1
p=len(b[0])+1
print any(a==[d[s%p:n]for d in b][s/p:e]for s in range(l*p)for e in range(s/p,l)for n in range(s%p,p))
Try it online!
Generates all possible and compares them with 'a'. I did not assume for it to be square, as it was not stated. But that would make the code a bit smaller.
Original code for understanding purposes:
def f(a,b):
col_len = len(b)+1
row_len = len(b[0])+1
for start_col in range(col_len):
for start_row in range(row_len):
for end_col in range(start_col, col_len):
for end_row in range(start_row, row_len):
t=list(map(lambda a:a[start_row:end_row],b))[start_col:end_col]
#print(t, a)
if t == a:
return True
return False
Version that supports only squares (125 bytes):
a,b=input()
l=len(b)+1
print any(a==[d[s%l:n]for d in b][s/l:e]for s in range(l*l)for e in range(s/l,l)for n in range(s%l,l))
Try it online!
$endgroup$
add a comment |
$begingroup$
J, 21 bytes
<@[(1 e.[:,=)$@[<;.3]
Try it online!
how
<@[
boxed left arg$@[<;.3]
all rectangles in the right arg with the same shape as the left arg- now pass those to things as the left and right arg to...
(1 e.[:,=)
is1
an element ofe.
the flatten of[:,
the boolean matrix showing if the left arg equals any of the rectangles in the right arg.
$endgroup$
add a comment |
$begingroup$
python 3, 50 bytes
# assumes input formated like this
a = ["123","456","789"]
b = ["123","456","789"]
f=lambda a,b:min(max(c in d for d in b)for c in a)
edit: github with working testsuite
New contributor
$endgroup$
$begingroup$
I don't think this actually works for anything... example
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
@HyperNeutrino your example shows intended behavior, "123" is not in ["12","45"]. i added my git repo to my answer.
$endgroup$
– steviestickman
4 hours ago
$begingroup$
@HyperNeutrino I think you have inverteda
andb
. Example (I haven't checked other tests.)
$endgroup$
– Robin Ryder
4 hours ago
$begingroup$
Making the first array ascue is not checked Try it online!
$endgroup$
– Neil
4 hours ago
1
$begingroup$
@steviestickman Oh okay, sorry, I didn't notice the ordering. However, it does break for this.
$endgroup$
– HyperNeutrino
4 hours ago
|
show 2 more comments
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
);
);
Hazard 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%2f185169%2fdetermine-if-a-grid-contains-another-grid%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Brachylog (v2), 4 bytes
ss
Try it online!
Most easily run as a full program, as usual for a decision-problem, with a specified as a command-line argument, b on standard input. The question asks for a function, and the program also works as a function, with b on the left, a on the right, and output via producing an exception if and only if the decision is false.
Explanation
ss
s a substring of rows of the left input
… assert rectangular; swap row and column operations
s a substring of <s>rows</s> columns of the above matrix
implicit assert that the result can be the right input
The "assert rectangular" is, obviously, pointless, as the question guarantees that already. The rest of the program does the grid-finding for us by identifying a substring of the rows and of the columns, i.e. a submatrix.
Meta-discussion
We've had a very similar question before; I'd expect most answers to one question to be modifiable into answers to the other. I think this is the neater version of it, though.
$endgroup$
add a comment |
$begingroup$
Brachylog (v2), 4 bytes
ss
Try it online!
Most easily run as a full program, as usual for a decision-problem, with a specified as a command-line argument, b on standard input. The question asks for a function, and the program also works as a function, with b on the left, a on the right, and output via producing an exception if and only if the decision is false.
Explanation
ss
s a substring of rows of the left input
… assert rectangular; swap row and column operations
s a substring of <s>rows</s> columns of the above matrix
implicit assert that the result can be the right input
The "assert rectangular" is, obviously, pointless, as the question guarantees that already. The rest of the program does the grid-finding for us by identifying a substring of the rows and of the columns, i.e. a submatrix.
Meta-discussion
We've had a very similar question before; I'd expect most answers to one question to be modifiable into answers to the other. I think this is the neater version of it, though.
$endgroup$
add a comment |
$begingroup$
Brachylog (v2), 4 bytes
ss
Try it online!
Most easily run as a full program, as usual for a decision-problem, with a specified as a command-line argument, b on standard input. The question asks for a function, and the program also works as a function, with b on the left, a on the right, and output via producing an exception if and only if the decision is false.
Explanation
ss
s a substring of rows of the left input
… assert rectangular; swap row and column operations
s a substring of <s>rows</s> columns of the above matrix
implicit assert that the result can be the right input
The "assert rectangular" is, obviously, pointless, as the question guarantees that already. The rest of the program does the grid-finding for us by identifying a substring of the rows and of the columns, i.e. a submatrix.
Meta-discussion
We've had a very similar question before; I'd expect most answers to one question to be modifiable into answers to the other. I think this is the neater version of it, though.
$endgroup$
Brachylog (v2), 4 bytes
ss
Try it online!
Most easily run as a full program, as usual for a decision-problem, with a specified as a command-line argument, b on standard input. The question asks for a function, and the program also works as a function, with b on the left, a on the right, and output via producing an exception if and only if the decision is false.
Explanation
ss
s a substring of rows of the left input
… assert rectangular; swap row and column operations
s a substring of <s>rows</s> columns of the above matrix
implicit assert that the result can be the right input
The "assert rectangular" is, obviously, pointless, as the question guarantees that already. The rest of the program does the grid-finding for us by identifying a substring of the rows and of the columns, i.e. a submatrix.
Meta-discussion
We've had a very similar question before; I'd expect most answers to one question to be modifiable into answers to the other. I think this is the neater version of it, though.
edited 3 hours ago
community wiki
2 revs
ais523
add a comment |
add a comment |
$begingroup$
Python 2, 106 118 bytes
lambda a,b,L=len:any(any(sum(A==B[j:j+L(A)]for A,B in zip(a,b[i:]))==L(a)for i in range(L(b)))for j in range(L(b[0])))
Try it online!
$endgroup$
$begingroup$
@Neil: Fixed now.
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
Python 2, 106 118 bytes
lambda a,b,L=len:any(any(sum(A==B[j:j+L(A)]for A,B in zip(a,b[i:]))==L(a)for i in range(L(b)))for j in range(L(b[0])))
Try it online!
$endgroup$
$begingroup$
@Neil: Fixed now.
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
Python 2, 106 118 bytes
lambda a,b,L=len:any(any(sum(A==B[j:j+L(A)]for A,B in zip(a,b[i:]))==L(a)for i in range(L(b)))for j in range(L(b[0])))
Try it online!
$endgroup$
Python 2, 106 118 bytes
lambda a,b,L=len:any(any(sum(A==B[j:j+L(A)]for A,B in zip(a,b[i:]))==L(a)for i in range(L(b)))for j in range(L(b[0])))
Try it online!
edited 3 hours ago
answered 4 hours ago
Chas BrownChas Brown
5,3241523
5,3241523
$begingroup$
@Neil: Fixed now.
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
@Neil: Fixed now.
$endgroup$
– Chas Brown
3 hours ago
$begingroup$
@Neil: Fixed now.
$endgroup$
– Chas Brown
3 hours ago
$begingroup$
@Neil: Fixed now.
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
Python 2, 160 139 bytes
a,b=input()
l=len(b)+1
p=len(b[0])+1
print any(a==[d[s%p:n]for d in b][s/p:e]for s in range(l*p)for e in range(s/p,l)for n in range(s%p,p))
Try it online!
Generates all possible and compares them with 'a'. I did not assume for it to be square, as it was not stated. But that would make the code a bit smaller.
Original code for understanding purposes:
def f(a,b):
col_len = len(b)+1
row_len = len(b[0])+1
for start_col in range(col_len):
for start_row in range(row_len):
for end_col in range(start_col, col_len):
for end_row in range(start_row, row_len):
t=list(map(lambda a:a[start_row:end_row],b))[start_col:end_col]
#print(t, a)
if t == a:
return True
return False
Version that supports only squares (125 bytes):
a,b=input()
l=len(b)+1
print any(a==[d[s%l:n]for d in b][s/l:e]for s in range(l*l)for e in range(s/l,l)for n in range(s%l,l))
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 160 139 bytes
a,b=input()
l=len(b)+1
p=len(b[0])+1
print any(a==[d[s%p:n]for d in b][s/p:e]for s in range(l*p)for e in range(s/p,l)for n in range(s%p,p))
Try it online!
Generates all possible and compares them with 'a'. I did not assume for it to be square, as it was not stated. But that would make the code a bit smaller.
Original code for understanding purposes:
def f(a,b):
col_len = len(b)+1
row_len = len(b[0])+1
for start_col in range(col_len):
for start_row in range(row_len):
for end_col in range(start_col, col_len):
for end_row in range(start_row, row_len):
t=list(map(lambda a:a[start_row:end_row],b))[start_col:end_col]
#print(t, a)
if t == a:
return True
return False
Version that supports only squares (125 bytes):
a,b=input()
l=len(b)+1
print any(a==[d[s%l:n]for d in b][s/l:e]for s in range(l*l)for e in range(s/l,l)for n in range(s%l,l))
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 160 139 bytes
a,b=input()
l=len(b)+1
p=len(b[0])+1
print any(a==[d[s%p:n]for d in b][s/p:e]for s in range(l*p)for e in range(s/p,l)for n in range(s%p,p))
Try it online!
Generates all possible and compares them with 'a'. I did not assume for it to be square, as it was not stated. But that would make the code a bit smaller.
Original code for understanding purposes:
def f(a,b):
col_len = len(b)+1
row_len = len(b[0])+1
for start_col in range(col_len):
for start_row in range(row_len):
for end_col in range(start_col, col_len):
for end_row in range(start_row, row_len):
t=list(map(lambda a:a[start_row:end_row],b))[start_col:end_col]
#print(t, a)
if t == a:
return True
return False
Version that supports only squares (125 bytes):
a,b=input()
l=len(b)+1
print any(a==[d[s%l:n]for d in b][s/l:e]for s in range(l*l)for e in range(s/l,l)for n in range(s%l,l))
Try it online!
$endgroup$
Python 2, 160 139 bytes
a,b=input()
l=len(b)+1
p=len(b[0])+1
print any(a==[d[s%p:n]for d in b][s/p:e]for s in range(l*p)for e in range(s/p,l)for n in range(s%p,p))
Try it online!
Generates all possible and compares them with 'a'. I did not assume for it to be square, as it was not stated. But that would make the code a bit smaller.
Original code for understanding purposes:
def f(a,b):
col_len = len(b)+1
row_len = len(b[0])+1
for start_col in range(col_len):
for start_row in range(row_len):
for end_col in range(start_col, col_len):
for end_row in range(start_row, row_len):
t=list(map(lambda a:a[start_row:end_row],b))[start_col:end_col]
#print(t, a)
if t == a:
return True
return False
Version that supports only squares (125 bytes):
a,b=input()
l=len(b)+1
print any(a==[d[s%l:n]for d in b][s/l:e]for s in range(l*l)for e in range(s/l,l)for n in range(s%l,l))
Try it online!
edited 4 hours ago
answered 4 hours ago
NeilNeil
2,042324
2,042324
add a comment |
add a comment |
$begingroup$
J, 21 bytes
<@[(1 e.[:,=)$@[<;.3]
Try it online!
how
<@[
boxed left arg$@[<;.3]
all rectangles in the right arg with the same shape as the left arg- now pass those to things as the left and right arg to...
(1 e.[:,=)
is1
an element ofe.
the flatten of[:,
the boolean matrix showing if the left arg equals any of the rectangles in the right arg.
$endgroup$
add a comment |
$begingroup$
J, 21 bytes
<@[(1 e.[:,=)$@[<;.3]
Try it online!
how
<@[
boxed left arg$@[<;.3]
all rectangles in the right arg with the same shape as the left arg- now pass those to things as the left and right arg to...
(1 e.[:,=)
is1
an element ofe.
the flatten of[:,
the boolean matrix showing if the left arg equals any of the rectangles in the right arg.
$endgroup$
add a comment |
$begingroup$
J, 21 bytes
<@[(1 e.[:,=)$@[<;.3]
Try it online!
how
<@[
boxed left arg$@[<;.3]
all rectangles in the right arg with the same shape as the left arg- now pass those to things as the left and right arg to...
(1 e.[:,=)
is1
an element ofe.
the flatten of[:,
the boolean matrix showing if the left arg equals any of the rectangles in the right arg.
$endgroup$
J, 21 bytes
<@[(1 e.[:,=)$@[<;.3]
Try it online!
how
<@[
boxed left arg$@[<;.3]
all rectangles in the right arg with the same shape as the left arg- now pass those to things as the left and right arg to...
(1 e.[:,=)
is1
an element ofe.
the flatten of[:,
the boolean matrix showing if the left arg equals any of the rectangles in the right arg.
answered 17 mins ago
JonahJonah
3,0981019
3,0981019
add a comment |
add a comment |
$begingroup$
python 3, 50 bytes
# assumes input formated like this
a = ["123","456","789"]
b = ["123","456","789"]
f=lambda a,b:min(max(c in d for d in b)for c in a)
edit: github with working testsuite
New contributor
$endgroup$
$begingroup$
I don't think this actually works for anything... example
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
@HyperNeutrino your example shows intended behavior, "123" is not in ["12","45"]. i added my git repo to my answer.
$endgroup$
– steviestickman
4 hours ago
$begingroup$
@HyperNeutrino I think you have inverteda
andb
. Example (I haven't checked other tests.)
$endgroup$
– Robin Ryder
4 hours ago
$begingroup$
Making the first array ascue is not checked Try it online!
$endgroup$
– Neil
4 hours ago
1
$begingroup$
@steviestickman Oh okay, sorry, I didn't notice the ordering. However, it does break for this.
$endgroup$
– HyperNeutrino
4 hours ago
|
show 2 more comments
$begingroup$
python 3, 50 bytes
# assumes input formated like this
a = ["123","456","789"]
b = ["123","456","789"]
f=lambda a,b:min(max(c in d for d in b)for c in a)
edit: github with working testsuite
New contributor
$endgroup$
$begingroup$
I don't think this actually works for anything... example
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
@HyperNeutrino your example shows intended behavior, "123" is not in ["12","45"]. i added my git repo to my answer.
$endgroup$
– steviestickman
4 hours ago
$begingroup$
@HyperNeutrino I think you have inverteda
andb
. Example (I haven't checked other tests.)
$endgroup$
– Robin Ryder
4 hours ago
$begingroup$
Making the first array ascue is not checked Try it online!
$endgroup$
– Neil
4 hours ago
1
$begingroup$
@steviestickman Oh okay, sorry, I didn't notice the ordering. However, it does break for this.
$endgroup$
– HyperNeutrino
4 hours ago
|
show 2 more comments
$begingroup$
python 3, 50 bytes
# assumes input formated like this
a = ["123","456","789"]
b = ["123","456","789"]
f=lambda a,b:min(max(c in d for d in b)for c in a)
edit: github with working testsuite
New contributor
$endgroup$
python 3, 50 bytes
# assumes input formated like this
a = ["123","456","789"]
b = ["123","456","789"]
f=lambda a,b:min(max(c in d for d in b)for c in a)
edit: github with working testsuite
New contributor
edited 4 hours ago
New contributor
answered 4 hours ago
steviestickmansteviestickman
12
12
New contributor
New contributor
$begingroup$
I don't think this actually works for anything... example
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
@HyperNeutrino your example shows intended behavior, "123" is not in ["12","45"]. i added my git repo to my answer.
$endgroup$
– steviestickman
4 hours ago
$begingroup$
@HyperNeutrino I think you have inverteda
andb
. Example (I haven't checked other tests.)
$endgroup$
– Robin Ryder
4 hours ago
$begingroup$
Making the first array ascue is not checked Try it online!
$endgroup$
– Neil
4 hours ago
1
$begingroup$
@steviestickman Oh okay, sorry, I didn't notice the ordering. However, it does break for this.
$endgroup$
– HyperNeutrino
4 hours ago
|
show 2 more comments
$begingroup$
I don't think this actually works for anything... example
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
@HyperNeutrino your example shows intended behavior, "123" is not in ["12","45"]. i added my git repo to my answer.
$endgroup$
– steviestickman
4 hours ago
$begingroup$
@HyperNeutrino I think you have inverteda
andb
. Example (I haven't checked other tests.)
$endgroup$
– Robin Ryder
4 hours ago
$begingroup$
Making the first array ascue is not checked Try it online!
$endgroup$
– Neil
4 hours ago
1
$begingroup$
@steviestickman Oh okay, sorry, I didn't notice the ordering. However, it does break for this.
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
I don't think this actually works for anything... example
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
I don't think this actually works for anything... example
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
@HyperNeutrino your example shows intended behavior, "123" is not in ["12","45"]. i added my git repo to my answer.
$endgroup$
– steviestickman
4 hours ago
$begingroup$
@HyperNeutrino your example shows intended behavior, "123" is not in ["12","45"]. i added my git repo to my answer.
$endgroup$
– steviestickman
4 hours ago
$begingroup$
@HyperNeutrino I think you have inverted
a
and b
. Example (I haven't checked other tests.)$endgroup$
– Robin Ryder
4 hours ago
$begingroup$
@HyperNeutrino I think you have inverted
a
and b
. Example (I haven't checked other tests.)$endgroup$
– Robin Ryder
4 hours ago
$begingroup$
Making the first array ascue is not checked Try it online!
$endgroup$
– Neil
4 hours ago
$begingroup$
Making the first array ascue is not checked Try it online!
$endgroup$
– Neil
4 hours ago
1
1
$begingroup$
@steviestickman Oh okay, sorry, I didn't notice the ordering. However, it does break for this.
$endgroup$
– HyperNeutrino
4 hours ago
$begingroup$
@steviestickman Oh okay, sorry, I didn't notice the ordering. However, it does break for this.
$endgroup$
– HyperNeutrino
4 hours ago
|
show 2 more comments
Hazard is a new contributor. Be nice, and check out our Code of Conduct.
Hazard is a new contributor. Be nice, and check out our Code of Conduct.
Hazard is a new contributor. Be nice, and check out our Code of Conduct.
Hazard 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%2f185169%2fdetermine-if-a-grid-contains-another-grid%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$
Hi and welcome to codegolf! I edited your test cases to (hopefully) make them a bit more clear. Note that we have a sandbox for working on challenges before posting them to main. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
1
$begingroup$
Also, may I take the first array as an array of strings and the second as a string separated by newlines, even though my language(C#) has a character type built in?
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
@Neil Test cases 2 and 3 are not square.
$endgroup$
– Robin Ryder
4 hours ago
1
$begingroup$
Could you add a truthy test case where
a
isn't onb
's left edge and a falsey test case where each line ofa
appears in consecutive lines ofb
but with their left edges staggered?$endgroup$
– Shaggy
3 hours ago