Skip to content

Instantly share code, notes, and snippets.

@alothings
alothings / serviceAccount.yaml
Created September 28, 2018 20:13
serviceaccount.yaml
apiVersion: v1
imagePullSecrets:
- name: some-secret
kind: ServiceAccount
metadata:
name: devops-sa
namespace: devops
----
kind: Role
@alothings
alothings / bm.py
Created June 14, 2017 00:46
python
"""
Pattern matching problem
Boyer Moore algorithm
First is my attempt, below is the code provided in the book
Idea:
Optimize brute force approach using 2 heuristics:
- Looking-Glass: start searches from last character of the
pattern and work backwards
- Character-Jump: During testing of a pattern P, a mismatch
"""
Pattern matching problem
Boyer Moore algorithm
First is my attempt, below is the code provided in the book
Idea:
Optimize brute force approach using 2 heuristics:
- Looking-Glass: start searches from last character of the
pattern and work backwards
- Character-Jump: During testing of a pattern P, a mismatch
def func(row):
return int(row.split()[k])
if __name__ == '__main__':
n, m = map(int, input().split())
rows = [input() for _ in range(n)]
k = int(input())
# for row in sorted(rows, key=lambda row: int(row.split()[k])): #works
customers = {}
for i in range(n):
size, price = input().split()
customers[size] = price
# To comprehension
@alothings
alothings / find_anagrams.py
Created June 24, 2016 20:16
Given a list with strings and a word, find the strings that are anagrams of the word given.
'''
Return anagrams of the same word
To optimize in future can use bit strings
'''
def find_anagrams(list_of_anagrams, word):
l = []
for s in list_of_anagrams:
if sorted(word) == sorted(s):
l.append(s)
@alothings
alothings / max_product_of_integers
Created June 24, 2016 20:05
Given a large number and a small integer n, convert it to string, and find the maximum product among the nearest n numbers
'''
Write a function that wil receive a big number as a string
and a number of digits to multiply and will return the biggest
product contained in the number.
IO: NUMB (big number), int (number of digits to multiply
'''
def adjacent_digits_product(NUMB, n):
my_str = str(NUMB)
@alothings
alothings / primes.py
Created June 24, 2016 19:29
Give an integer n, find the next prime
__author__ = "Alonso Gutierrez"
# Give input integer n, find the next prime
def find_next_prime(n):
isprime = False
n += 1
while (not isprime):
# print n
isprime = True
if n % 2 == 0:
# print 'n is even'
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\someuser\Desktop\leven-1.0.4>python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to leven.egg-info\requires.txt
writing leven.egg-info\PKG-INFO
writing top-level names to leven.egg-info\top_level.txt
writing dependency_links to leven.egg-info\dependency_links.txt