Skip to content

Instantly share code, notes, and snippets.

import unittest
def is_prime(n):
if n <= 1:
return False
if n == 2 or n == 3:
return True
import unittest
import re
def adjacent_digits_product(numb_str, digits_count):
max_product = 0
numb_str = re.sub('[\s+]', '', numb_str)
for i in range(len(numb_str) - digits_count):
sub_str = numb_str[i:i+digits_count]
import unittest
def find_anagrams(list_of_strings, word):
anagrams = []
for str_element in list_of_strings:
if len(word) == len(str_element):
list_of_chars = list(str_element)
for char in word:
# Bailey-Borwein-Plouffe formula for calculating Pi
N = 15
def calculate_pi():
pi = 0
for k in range(0, N):
dividend = dividend_for_k(k)
divider = pow(16, k)
pi += dividend/divider
#coding=utf-8
import pyaudio
import wave
import time
from datetime import datetime
import sys
def main():
@Jonarzz
Jonarzz / IP Address Validation (Hacker Rank)
Last active November 19, 2015 22:03
The script takes N as number of lines to read; then takes N lines and checks if the line is IPv4, IPv6 or neither.
import re
n = int(input())
for _ in range(n):
output = 'Neither'
line = str(input())
match = re.match(r'^(\d{0,3})\.(\d{0,3})\.(\d{0,3})\.(\d{0,3})$', line)
if match is not None:
import string
import random
ALL_CHARS = string.ascii_letters + string.digits + string.punctuation
target = input('Enter your target text: ')
output_list = []
for _ in target:
import time
import copy
import os
import random
N = 20
M = 20
ALIVE = '#'
"""
https://github.com/qofnaught/wykop_wyzwaniepython/tree/master/edycja1
Otrzymujesz katalog zawierający 1000 plików o losowych nazwach które są wypełnione
3 losowymi znakami. Twoim zadaniem jest:
Wersja łatwa
- Odczytać rok i miesiąc modyfikacji pliku
- skopiowac wszystkie pliki z danego roku do do jednego katalogu a poźniej to samo dla miesięcy
Wersja trudna
- To co łatwa
// appends an Untappd link to each of search results on SmakPiwa.pl site
const titles = Array.from(document.querySelectorAll('h3.abs-product-name'));
titles.forEach(title => {
const untappdLink = document.createElement('a');
untappdLink.innerText = '[UT]';
untappdLink.target = '_blank';
const name = title.innerText.replace(/[^\S ]+/g, ' ').replace('(puszka)', '').replace(/\d+( ml)?/g, '');
untappdLink.href = 'https://untappd.com/search?q=' + name.split(' ').join('+');
title.appendChild(untappdLink);
});