Skip to content

Instantly share code, notes, and snippets.

View rajatscode's full-sized avatar
💻
trying to exit vim

rajat mehndiratta rajatscode

💻
trying to exit vim
View GitHub Profile
@rajatscode
rajatscode / leetcode_765.py
Created October 29, 2020 05:18
Python 2 code for Leetcode 765
def convert_to_couples(row):
return [n // 2 for n in row]
def trim_couples(couples):
return [
couples[i] for i in xrange(len(couples))
if couples[i//2*2] != couples[i//2*2+1]
]
def reindex_by_appearance(sequence):
@rajatscode
rajatscode / LICENSE
Created June 6, 2020 20:02
This license applies to all public gists listed at https://gist.github.com/rajatscode
MIT License
Copyright (c) 2020 rajat mehndiratta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@rajatscode
rajatscode / james_road.py
Created June 6, 2020 07:06
Jane Street alternative name generator
# To get this to work: install names (`pip3 install --user -U names`)
import names
import random
# copied from https://pe.usps.com/text/pub28/28apc_002.htm
# hardcoded because requests + BeautifulSoup got too ugly and it's faster to
# just extract and prettify the words from the page manually
STREET_SUFFIXES = {
'Alley', 'Annex', 'Arcade', 'Avenue', 'Bayou', 'Beach', 'Bend', 'Bluff',
'Bluffs', 'Bottom', 'Boulevard', 'Branch', 'Bridge', 'Brook', 'Brooks',
@rajatscode
rajatscode / random_lowercase_strings.py
Last active May 28, 2020 06:14
Generating random lowercase ASCII strings in Python
import argparse
import cProfile
import itertools
import random
import string
ALL_FUNCTION_NAMES=[
'using_choice', 'using_sample', 'using_randint', 'using_randint_with_offset', 'using_randbits',
'using_randbits_ascii_lowercase', 'using_one_long_randbits'
]