Skip to content

Instantly share code, notes, and snippets.

@mzdravkov
mzdravkov / needleman-wunsch.py
Created October 10, 2022 13:12
Needleman-Wunsch algorithm in Python
import sys
import pprint
from collections import defaultdict
if len(sys.argv) != 3:
print("Please pass two sequences as separate arguments. E.g. ./program TCAT CGAT")
exit(1)
seq1 = sys.argv[1].upper()
text1 = """
1.
When Zarathustra was thirty years old, he left his home and the lake of his home, and went into the mountains. There he enjoyed his spirit and solitude, and for ten years did not weary of it. But at last his heart changed,—and rising one morning with the rosy dawn, he went before the sun, and spake thus unto it:
Thou great star! What would be thy happiness if thou hadst not those for whom thou shinest!
For ten years hast thou climbed hither unto my cave: thou wouldst have wearied of thy light and of the journey, had it not been for me, mine eagle, and my serpent.
But we awaited thee every morning, took from thee thine overflow and blessed thee for it.
Lo! I am weary of my wisdom, like the bee that hath gathered too much honey; I need hands outstretched to take it.
I would fain bestow and distribute, until the wise have once more become joyous in their folly, and the poor happy in their riches.
Therefore must I descend into the deep: as thou doest in the evening, when thou goest behind the sea,
import re
text1 = """
It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.
However little known the feelings or views of such a man may be on his first entering a neighbourhood, this truth is so well fixed in the minds of the surrounding families, that he is considered as the rightful property of some one or other of their daughters.
“My dear Mr. Bennet,” said his lady to him one day, “have you heard that Netherfield Park is let at last?”
Mr. Bennet replied that he had not.
“But it is,” returned she; “for Mrs. Long has just been here, and she told me all about it.”
Mr. Bennet made no answer.
“Do not you want to know who has taken it?” cried his wife impatiently.
import re
text1 = """
I celebrate myself, and sing myself,
And what I assume you shall assume,
For every atom belonging to me as good belongs to you.
I loafe and invite my soul,
I lean and loafe at my ease observing a spear of summer grass.
@mzdravkov
mzdravkov / .py
Created March 1, 2021 21:38
Data structures excercise problems
class ListNode:
def __init__(self, value):
self.value = value
self.next_elem = None
class List:
def __init__(self):
self.head = None
def add(self, value):

Keybase proof

I hereby claim:

  • I am mzdravkov on github.
  • I am mzdravkov (https://keybase.io/mzdravkov) on keybase.
  • I have a public key whose fingerprint is AA97 9F69 1409 E50B 8E39 6412 67D5 A03D 0BDE D640

To claim this, I am signing this object:

@mzdravkov
mzdravkov / ecs2.go
Created May 24, 2016 11:29
test ecs idea
package main
import (
"math"
"sync"
)
type Component interface {
Name() string
}
package main
import (
"fmt"
"time"
)
func main() {
ch := make(chan int)
for i := 0; i < 100; i++ {
(defmacro pattern
[n predecessor]
(vec
(concat (repeat n '_)
predecessor
'(& r))))
(defmacro my-match
[state predecessor]
(let [diff (- (count state)
@mzdravkov
mzdravkov / generate.php
Created July 9, 2015 12:27
Basic web interface for the scheduling problem.
<?php
include 'schedule.php';
$day_start = (int)$_POST['day_start'];
$day_end = (int)$_POST['day_end'];
$positions = (int)$_POST['positions'];
$people = (int)$_POST['people'];
$position_hours = (int)$_POST['position_hours'];
$work_hours = (int)$_POST['work_hours'];
if ($day_start >= $day_end ||