Skip to content

Instantly share code, notes, and snippets.

@Eckankar
Created October 6, 2013 09:04
Show Gist options
  • Select an option

  • Save Eckankar/6851478 to your computer and use it in GitHub Desktop.

Select an option

Save Eckankar/6851478 to your computer and use it in GitHub Desktop.
Fwnies' solution to NCPC 2013 problem E
xs = raw_input()
ys = raw_input()
lxs = len(xs)
lys = len(ys)
d = lys - lxs
i = 0
while True:
if i >= min(lxs, lys):
break
if xs[i] <> ys[i]:
break
i += 1
j = i + max(0, d)
while True:
if j >= lys:
break
if ys[j:] == xs[j - d:]:
break
j += 1
print j - i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment