#Python, (削除) 119 (削除ここまで)(削除) 115 (削除ここまで) 91
Python, (削除) 119 (削除ここまで)(削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
| Input 1 | Input 2 | Output |
|----------+-------------+---------------|
| 'abcd' | 'abc' | 'd' |
| 'abcd' | 'dabc' | 'cd' |
| 'abcd' | 'dcbabbccd' | 'abc' |
| 'abcdf' | 'abcdebcdf' | 'abcdf' |
| 'abc' | 'abc' | (IndexError) |
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.
#Python, (削除) 119 (削除ここまで)(削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
| Input 1 | Input 2 | Output |
|----------+-------------+---------------|
| 'abcd' | 'abc' | 'd' |
| 'abcd' | 'dabc' | 'cd' |
| 'abcd' | 'dcbabbccd' | 'abc' |
| 'abcdf' | 'abcdebcdf' | 'abcdf' |
| 'abc' | 'abc' | (IndexError) |
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.
Python, (削除) 119 (削除ここまで)(削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
| Input 1 | Input 2 | Output |
|----------+-------------+---------------|
| 'abcd' | 'abc' | 'd' |
| 'abcd' | 'dabc' | 'cd' |
| 'abcd' | 'dcbabbccd' | 'abc' |
| 'abcdf' | 'abcdebcdf' | 'abcdf' |
| 'abc' | 'abc' | (IndexError) |
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.
#Python, (削除) 119 (削除ここまで) (削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
| Input 1 | Input 2 | Output |
|----------+-------------+---------------|
| 'abcd' | 'abc' | 'd' |
| 'abcd' | 'dabc' | 'cd' |
| 'abcd' | 'dcbabbccd' | 'abc' |
| 'abcdf' | 'abcdebcdf' | 'abcdf' |
| 'abc' | 'abc' | (IndexError) |
| Input 1 | Input 2 | Output |
|----------+-------------+---------------|
| 'abcd' | 'abc' | 'd' |
| 'abcd' | 'dabc' | 'cd' |
| 'abcd' | 'dcbabbccd' | 'abc' |
| 'abcdf' | 'abcdebcdf' | 'abcdf' |
| 'abc' | 'abc' | (IndexError) |
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.
#Python, (削除) 119 (削除ここまで) (削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
| Input 1 | Input 2 | Output |
|----------+-------------+---------------|
| 'abcd' | 'abc' | 'd' |
| 'abcd' | 'dabc' | 'cd' |
| 'abcd' | 'dcbabbccd' | 'abc' |
| 'abcdf' | 'abcdebcdf' | 'abcdf' |
| 'abc' | 'abc' | (IndexError) |
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.
#Python, (削除) 119 (削除ここまで) (削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
| Input 1 | Input 2 | Output |
|----------+-------------+---------------|
| 'abcd' | 'abc' | 'd' |
| 'abcd' | 'dabc' | 'cd' |
| 'abcd' | 'dcbabbccd' | 'abc' |
| 'abcdf' | 'abcdebcdf' | 'abcdf' |
| 'abc' | 'abc' | (IndexError) |
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.
#Python, (削除) 119 (削除ここまで) (削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
| Input 1 | Input 2 | Output Output|
|----------+-------------+---------------|
| 'abcd', 'abc' | 'abc' #| 'd' |
| 'abcd', 'dabc' | 'dabc' #| 'cd' |
| 'abcd', 'dcbabbccd' | 'dcbabbccd' #| 'abc' |
| 'abcdf', 'abcdebcdf' | #'abcdebcdf' | 'abcdf' |
| 'abc', 'abc' | 'abc' # | (IndexError) |
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.
#Python, (削除) 119 (削除ここまで) (削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
Input Output
--------------------------------
'abcd', 'abc' # 'd'
'abcd', 'dabc' # 'cd'
'abcd', 'dcbabbccd' # 'abc'
'abcdf', 'abcdebcdf' # 'abcdf'
'abc', 'abc' # (IndexError)
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.
#Python, (削除) 119 (削除ここまで) (削除) 115 (削除ここまで) 91
lambda a,b:[a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a))if a[m:m+n]not in b][0]
Test cases:
| Input 1 | Input 2 | Output |
|----------+-------------+---------------|
| 'abcd' | 'abc' | 'd' |
| 'abcd' | 'dabc' | 'cd' |
| 'abcd' | 'dcbabbccd' | 'abc' |
| 'abcdf' | 'abcdebcdf' | 'abcdf' |
| 'abc' | 'abc' | (IndexError) |
Working on making it shorter, but this is my brain instinct. Not really much of a golfer yet.
Thanks to @user81655 and @NonlinearFruit for the extra bytes.
Edit:
Dang. Tried this code:
def z(a,b):
for s in [a[m:m+n]for n in range(1,len(a)+1)for m in range(len(a)-n+1)]:
if s not in b:return s
return''
Thought it was a few bytes shorter. Turns out it was 1 byte longer than what I had before the edit.