Skip to content

Instantly share code, notes, and snippets.

View svgl's full-sized avatar

svgl

View GitHub Profile
@svgl
svgl / simple_twitter.py
Last active May 25, 2020 17:50
Design a simplified version of Twitter, where users can post tweets, follow/unfollow others, and is able to see the 10 most recent tweets in the user’s news feed.
from time import time
from pprint import pprint
def postTweet(userid, tweet):
"""
"""
tweets.append({"message": tweet, "userid": userid, "creationTime": time()})
def follow(follower, followee):
"""
@svgl
svgl / oneRow.py
Last active May 6, 2020 22:02
Given an array of words, return the words that can be typed using letters of only one row on a keyboard.
keyboard_layouts = {
"qwerty": ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'],
"qwertz": ['qwertzuiop', 'asdfghjk', 'yxcvbnm'],
"azerty": ['azertyuiop', 'qsdfghjkl', 'wxcvbnm'],
"qzerty": ['qzertyuiop', 'asdfghjkl', 'wxcvbnm'],
"dvorak": ['pyfgcrl', 'aoeuidhtns', 'qjkxbmwvz'],
"colemak": ['qwfpgjluy', 'arstdhneio', 'zxcvbkm'],
"workman": ['qdrwbjfup', 'ashtgyneol', 'zxmcvkl'],
}