Skip to content

Instantly share code, notes, and snippets.

View 4Kaylum's full-sized avatar

Kae Bartlett 4Kaylum

View GitHub Profile
def get_value(captcha:int) -> int:
'''
Gets the captcha value for the given integer
Advent of Code day 1
A captcha value is determined by the value of n being added to a total if
n+1 is the same number as n. This wraps round back to the start, so the end
value can be equal to the first.
Parameters:
captcha: int
from sys import argv
from random import randint
def dice_compiler(string:str) -> tuple:
'''
Compiles a string (XdN+C) into tuple (X, N, +C). Works when X is not present, or when C is not present
(by inserting 1 and +0 respectively)
Does not give the actual roll of the dice
Works only with strings that match the regex "^\d*d\d+([+-]\d+)?$"
<img id="embeddedImage" src="placeholder.png" />
<select id="genderDropdown" onchange="changeImage(this)">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
<script type="text/javascript">
void buttonToMotor(TVexJoysticks buttonPlus, TVexJoysticks buttonMinus, tMotor motorName, int ifPressed, int ifUnpressed, int ifOtherPressed) {
if ( vexRT[buttonPlus] ) {
motor[motorName] = ifPressed;
} else if ( vexRT[buttonMinus] ) {
motor[motorName] = ifOtherPressed;
} else {
motor[motorName] = ifUnpressed;
};
}
void buttonToMotor(TVexJoysticks buttonPlus, TVexJoysticks buttonMinus, tMotor motorName) { buttonToMotor(buttonPlus, buttonMinus, motorName, 127, 0, -127); }
import discord
from discord.ext import commands
from asyncio import sleep
me = commands.Bot(command_prefix='.', self_bot=True)
@me.event
async def on_ready():
import discord
import asyncio
import sys
from discord.ext import commands
bot = commands.Bot(command_prefix=']',self_bot=True)
non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
@bot.event
async def on_ready():
@4Kaylum
4Kaylum / MysticRoseMaker.py
Created October 17, 2016 16:55
Uses Pygame to generate a mystic rose image
import sys # Args from cmd - sys.argv[1]
import pygame # Display graphically
import math # Position stuff correctly
import random # Shuffle thingies.
class Window:
def __init__(self, *, dimensions=[700, 700], title="Mystic Rose"):
pygame.init()
@4Kaylum
4Kaylum / FizzBuzz.py
Last active September 12, 2016 11:34
Says 'fizz' on multiples of 3, 'buzz' on multiples of 5, and 'fizzbuzz' on both.
def checkNum(number):
if number % 3 == 0 and number % 5 == 0:
return "FizzBuzz"
elif number % 3 == 0:
return "Fizz"
elif number % 5 == 0:
return "Buzz"
return number
for i in range(101):