Skip to content

Instantly share code, notes, and snippets.

View 4Kaylum's full-sized avatar

Kae Bartlett 4Kaylum

View GitHub Profile
@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):
@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()
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():
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():
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); }
<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">
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+)?$"
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
def get_checksum(spreadhseet:str) -> int:
spreadhseet = [[int(val) for val in row.split('\t') if val] for row in spreadhseet.split('\n')]
val = 0
for row in spreadhseet:
val += max(row) - min(row)
return val
def get_checksum_part_2(spreadhseet:str) -> int:
spreadhseet = [[int(val) for val in row.split('\t') if val] for row in spreadhseet.split('\n')]
def validate_passphrase(passphrases:str) -> int:
'''
Counts the number of valid passphrases
'''
passphrases = [[item for item in row.split(' ')] for row in passphrases.split('\n')]
valid = 0
for row in passphrases:
counter = 0
for item in row: