Skip to content

Instantly share code, notes, and snippets.

Avatar
🐯

myke MikulasZelinka

🐯
  • Prague
View GitHub Profile
@MikulasZelinka
MikulasZelinka / marching_band.py
Created Aug 5, 2020
MPMP: The Marching Band Problem
View marching_band.py
# python one-liner solution to https://www.youtube.com/watch?v=5GZ5IqxAt30
print(next(x for x in range(1_000_000) if len([y for y in range(1, x + 1) if x % y == 0]) == 64))
@MikulasZelinka
MikulasZelinka / th_before_last_fr.txt
Created Jun 29, 2020
The Thursday before the last Friday in each month
View th_before_last_fr.txt
# https://jakubroztocil.github.io/rrule/
RRULE:FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=-8,-7,-6,-5,-4,-3,-2
{
freq: RRule.MONTHLY,
byweekday: [RRule.TH],
bymonthday: [-8, -7, -6, -5, -4, -3, -2]
}
@MikulasZelinka
MikulasZelinka / pytorch_pad_pack_minimal.py
Last active Jun 25, 2020
pytorch: handling sentences of arbitrary length (dataset, data_loader, padding, embedding, packing, lstm, unpacking)
View pytorch_pad_pack_minimal.py
"""
sort-of minimal end-to-end example of handling input sequences (sentences) of variable length in pytorch
the sequences are considered to be sentences of words, meaning we then want to use embeddings and an RNN
using pytorch stuff for basically everything in the pipeline of:
dataset -> data_loader -> padding -> embedding -> packing -> lstm -> unpacking (~padding)
based mostly on: https://github.com/HarshTrivedi/packing-unpacking-pytorch-minimal-tutorial
pytorch version 1.4.0
gist url: https://gist.github.com/MikulasZelinka/9fce4ed47ae74fca454e88a39f8d911a
"""
@MikulasZelinka
MikulasZelinka / coingame.py
Created Sep 20, 2017
Infinitely many people gather to wrap their heads around a coin-flipping game
View coingame.py
# Game: n people, each person flips a coin until they get heads
# Question: what is the ratio of heads after the game ends?
n = 1024
heads = 0
tails = 0
# how many rounds does each game last on average (just for fun):
iterations = 0
You can’t perform that action at this time.