{{ message }}

Instantly share code, notes, and snippets.

# Jonarzz

Created Nov 7, 2015
View primes.py
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
 import unittest def is_prime(n): if n <= 1: return False if n == 2 or n == 3: return True
Created Nov 7, 2015
View prod_of_big_number.py
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
 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]
Created Nov 7, 2015
View find_anagrams.py
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
 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:
Created Nov 14, 2015
View Find PI to the Nth (N = precission) Digit
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
 # 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
Created Nov 14, 2015
View Alarm Clock
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
 #coding=utf-8 import pyaudio import wave import time from datetime import datetime import sys def main():
Last active Nov 19, 2015
The script takes N as number of lines to read; then takes N lines and checks if the line is IPv4, IPv6 or neither.
View IP Address Validation (Hacker Rank)
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
 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:
Last active Dec 5, 2015
View Evolution of text
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
 import string import random ALL_CHARS = string.ascii_letters + string.digits + string.punctuation target = input('Enter your target text: ') output_list = [] for _ in target:
Created Dec 5, 2015
View Game of life (random)
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
 import time import copy import os import random N = 20 M = 20 ALIVE = '#'
Last active Jul 17, 2016
View file_sorter.py
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
 """ 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
Last active Dec 9, 2019
View smak-piwa-untappd.js
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
 // 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); });