File tree
Expand file treeCollapse file tree1 file changed
+36
-0
lines changed Expand file treeCollapse file tree1 file changed
+36
-0
lines changed Original file line number | Diff line number | Diff line change |
---|
|
| 1 | +#!/bin/python3 |
| 2 | + |
| 3 | +import math |
| 4 | +import os |
| 5 | +import random |
| 6 | +import re |
| 7 | +import sys |
| 8 | + |
| 9 | +# Complete the appendAndDelete function below. |
| 10 | +def appendAndDelete(s, t, k): |
| 11 | +min_len = min(len(s), len(t)) |
| 12 | +first_different_index = min_len |
| 13 | + |
| 14 | +for i in range(min_len): |
| 15 | +if s[i] != t[i]: |
| 16 | +first_different_index = i |
| 17 | +break |
| 18 | + |
| 19 | +necessary_operations = len(s) + len(t) - 2 * first_different_index |
| 20 | + |
| 21 | +return("Yes" if k == necessary_operations or (k >= necessary_operations and (k - necessary_operations) % 2 == 0 ) or k >= len(s) + len(t) else "No") |
| 22 | + |
| 23 | +if __name__ == '__main__': |
| 24 | +fptr = open(os.environ['OUTPUT_PATH'], 'w') |
| 25 | + |
| 26 | +s = input() |
| 27 | + |
| 28 | +t = input() |
| 29 | + |
| 30 | +k = int(input()) |
| 31 | + |
| 32 | +result = appendAndDelete(s, t, k) |
| 33 | + |
| 34 | +fptr.write(result + '\n') |
| 35 | + |
| 36 | +fptr.close() |
You can’t perform that action at this time.
0 commit comments