Skip to content

Instantly share code, notes, and snippets.

View jmccardle's full-sized avatar

John McCardle Solders & Hacks jmccardle

View GitHub Profile
# See diagram: https://i.imgur.com/UWDrqcH.png
# We need 8 equations to solve the diagram, but I can only come up with 5.
# For three more equations, we will assume a value for X, A, and D.
# If sympy times out, we will cancel the attempt.
# Values for X: 7 choose 4, 35 possible values.
# Values for A: 7.
# (Naive) Maximum loops: 7*35 = 245.
# (actual) maximum loops: 4 * 35 = 140. A has to be in the circle for the solution for X we're using.
# See diagram: https://i.imgur.com/UWDrqcH.png
from itertools import permutations
for i, perm in enumerate(permutations([1,2,3,4,5,6,7])):
a, b, c, d, e, f, g = perm
if (a + d + g + f) / 2 == (b + d + e + g) / 3 == (c + e + f + g) / 4:
print(f"\n{i}. Solution: a = {a}, b = {b}, c = {c}, d = {d}, e = {e}, f = {f}, x = {(a+d+g+f)/2}")
else:
print(f"{i} ", end='')
# (Major issues) - not enough equations to solve this SOE!
# See diagram: https://i.imgur.com/UWDrqcH.png
# We need 7 equations to solve the diagram, but I can only come up with 5.
# For two more equations, we will assume a value for X and A.
# If sympy times out, we will cancel the attempt.
# Values for X: 7 choose 4, 35 possible values.
# Values for A: 7.
# (Naive) Maximum loops: 7*35 = 245.
import pandas as pd
def region(row):
#print(row)
state = row["state"]
if state in ("FL", "GA"): return "South"
elif state in ("CA", "WA"): return "West"
elif state in ("MT", "MN"): return "Central"
elif state in ("NY", "ME"): return "North"
else: return "Unknown"
# Pico W GPIO-over-website test
# thanks to https://www.petecodes.co.uk/creating-a-basic-raspberry-pi-pico-web-server-using-micropython/ for the kickstart
import network
import socket
import time
from machine import Pin
import secrets
# secrets.py defines SSID and PASSWORD variables, used on line 12 - don't expose your SSID/passphrase to github, please
import machine
wlan = network.WLAN(network.STA_IF)
# knights and knaves
class Meta(type):
def __repr__(cls):
return f'<{cls.__name__}>'
class Knight(metaclass = Meta):
pass
class Knave(metaclass = Meta):
// Python script engine includes
#include <Python.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
// SFML
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
// Python script engine includes
#include <Python.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
// SFML
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
// Python script engine includes
#include <Python.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
// SFML
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <Python.h>
#include <iostream>
// init_python - configure interpreter details here
PyStatus init_python(const char *program_name)
{
PyStatus status;
PyConfig config;
PyConfig_InitPythonConfig(&config);