Skip to content

Instantly share code, notes, and snippets.

@bzaczynski
bzaczynski / digram.py
Last active March 4, 2023 15:04
Digram Solution
from collections import defaultdict
def solve(S):
max_distance = -1
digrams = defaultdict(list)
for i in range(len(S) - 1):
digram = S[i:i + 2]
digrams[digram].append(i)
if len(digrams[digram]) > 1:
@bzaczynski
bzaczynski / focus.py
Created January 7, 2021 21:36
Blur detection with OpenCV
"""
Blur detection with OpenCV.
Installation:
$ pip install opencv-python
Sample usage:
$ python focus.py blurry.jpg
71.12557564908613
$ python focus.py sharp.png
@bzaczynski
bzaczynski / default-map.js
Created March 12, 2019 18:11
Python's defaultdict in ES6
class DefaultMap extends Map {
constructor(fn) {
super()
this.fn = fn
}
get(key) {
if (!this.has(key)) {
this.set(key, this.fn())

italic bold monospace

This is a block of code.

print('hello world')
package com.blogspot.syntaxcandy;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class A extends BaseClass {
@BeforeMethod
public void beforeMethod() {
System.out.println("A::@BeforeMethod");