Skip to content

Instantly share code, notes, and snippets.

@samorajp
samorajp / template.txt
Last active Oct 22, 2020
download and import linalg
View template.txt
!wget -N https://raw.githubusercontent.com/anagorko/linalg/main/linalg.py
import linalg
View pygame_vis.py
# encoding: utf-8
import pygame
from pygame.draw import circle, line
from pygame.locals import *
import misjonarze
# Initialize the game engine
pygame.init()
# Constants
@samorajp
samorajp / misjonarze.py
Created Feb 27, 2016
Program rozwiązujący zagadkę o misjonarzach i kanibalach dla ich dowolnej liczby oraz dowolnej pojemności łódki.
View misjonarze.py
def mutations(state, boat_size):
m_left, k_left, boat, m_right, k_right = state
sign, other_side = (-1, "R") if boat == "L" else (1, "L")
naive_mutations = [
(m_left + sign * m_diff, k_left + sign * k_diff,
other_side,
m_right - sign * m_diff, k_right - sign * k_diff)
for m_diff in range(boat_size + 1)
for k_diff in range(boat_size + 1)
View gradient.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.