Skip to content

Instantly share code, notes, and snippets.

View DomNomNom's full-sized avatar

DomNomNom DomNomNom

View GitHub Profile
@DomNomNom
DomNomNom / light_horn.py
Created May 22, 2022 14:35
A visualization of a curve that tries to effectively trap light (slow it down quickly)
import pyqtgraph as pg
import numpy as np
import sys
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QApplication, QHBoxLayout, QLabel, QSizePolicy, QSlider, QSpacerItem, \
QVBoxLayout, QWidget
'''
This is a logic puzzle which allows you to check your solution using Python.
Alice and Bob have once again been imprisoned under the watch of a crazy logician warden
who promises to let them free if they can solve the puzzle or otherwise they face a terrible fate.
The warden picks five cards from a standard playing card deck and gives them to Alice.
Alice may stack the cards in any order then give them back to the warden.
The warden will give the top four cards of the stack to Bob.
Bob must now deduce which card the warden is still holding.

You enter the dungeon on via the west entrance and spot nine magical Torches in an arrangement like so

..T.T.T
.......
@.T.T.T
.......
..T.T.T

The walls rumble! You hear "Ignite all torches or the ceiling will crumble!"

You arrive to the island of New Three Land where King Threeodore has a peculiar problem: He likes to take a tour from his castle through the country by only taking alternating left and right turns at intersections. Due to the consitution (the Charters of Threedom) all intersections must have exactly three roads leading in/out and dead ends are forbidden. These tours have always lead him back to the castle and he is worried that changing his place of residency may mean an end to this tradition.

Can you assure King Theeodore that no matter where he starts, a left/right tour will return him to the same spot?

@DomNomNom
DomNomNom / coins_cover_points.md
Last active May 22, 2020 03:56
A deceptively hard circle covering puzzle

You play a game against Malory, in which you choose points on the 2D plane and Malory wins if she can cover them by using non-overlapping pennies (disks of radius 1). Show a minimal set of points that guarantees you a win.

Hint

At low numbers of dots, Malory is favoured (if there is 1 dot, just cover it with 1 circle), and at high numbers of dots you are favoured (e.g. by using a grid approach like https://www.desmos.com/calculator/gwwcn40xcp)

Here's something that'll let you test out your theories: https://www.desmos.com/calculator/ifhtfwhnqm

In some future time, once bars may open again, Alice and her partner Bob head over to indulge in this way of socializing again. There are four other couples in the bar which, eager for social contact, do these cute footshakes with each person they haven't met before. After this initial mingling, Alice asks everyone how many people they did footshakes with. As some people knew each other beforehand, she gets nine different answers back.

How many footshakes did Bob do?

@DomNomNom
DomNomNom / Murphy42_OO.cpp
Last active August 8, 2018 04:15
Accidentally breaks C++ Access Rights while computing The Answer to the Ultimate Question of Life, the Universe, and Everything. This one is coded in a more Object Oriented fashion
#include <iostream>
// This class was named X to be consistent with http://www.gotw.ca/gotw/076.htm
//
// Its primary purpose is to hold a private value which no one should be able
// to accidentally modify.
class X {
public:
X() : private_(1) { /*...*/ }
int getValue() { return private_; }
@DomNomNom
DomNomNom / Murphy42.cpp
Last active August 7, 2018 01:24
Accidentally breaks C++ Access Rights while computing The Answer to the Ultimate Question of Life, the Universe, and Everything.
#include <iostream>
// File x.h
// This class was named X to be consistent with http://www.gotw.ca/gotw/076.htm
//
// Its primary purpose is to hold a private value which no one should be able
// to accidentally modify.
class X
{
public:
@DomNomNom
DomNomNom / controller_input.py
Last active February 7, 2018 00:57
Controller input for RLBot
from inputs import get_gamepad # pip install inputs
import threading
def deadzone(normalized_axis):
if abs(normalized_axis) < 0.1: return 0.0
return normalized_axis
class ControllerInput:
def __init__(self):
# self.fThrottle = 0.0
@DomNomNom
DomNomNom / physics.md
Last active November 14, 2017 11:25
What would happen to the moon the density of earth was suddenly halved?

radius r =
       384000 km
       384000000 m

period p =
       27.3 days
       2358720 s

moon's speed =
       d / t