This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Let x, y, and z, be strings over some alphabet Σ, where |z| = |x| + |y| (here |w| | |
denotes the length of a string w). We say that z is a shuffle of x and y if there are (possibly empty) | |
strings x1, x2, . . . , xk and y1, y2, . . . , yk so that x = x1x2 . . . xk, y = y1y2 . . . yk, and z = x1y1x2y2 . . . xkyk. | |
Intuitively, z can be constructed as the concatenation of pieces of x and y, in the order in which these | |
pieces appear in x and y, respectively. For example, 'alabama' is a shuffle of 'aba' and 'lama', but 'amalaba' is not. | |
We want an algorithm that, given as input three strings x, y, and z such that |z| = |x| + |y|, returns | |
true if z is a shuffle of x and y, and returns false otherwise. | |
Answer: Dynamic Programming |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from MySQLdb import connect | |
conn = connect(user="[user]", passwd= "[password]", host="[host]") | |
cur = conn.cursor() | |
cur.execute("show databases;") | |
dbs_to_update = filter( | |
lambda db: db not in ('information_schema', 'mysql', 'performance_schema'), | |
[dbname[0] for dbname in cur.fetchall()]) |