Skip to content

Instantly share code, notes, and snippets.

@IanMcT
IanMcT / j3palindrome.py
Created January 26, 2017 03:13
Hidden palindrome solution.
"""J3 Hidden Palindrome
http://cemc.math.uwaterloo.ca/contests/computing/2016/stage%201/juniorEn.pdf
This strategy loops from the longest possible palindrome to the shortest"""
word=input()
#0-3
#1-2
foundpalindrome = True #sentinal value
keeplooping = True#Stop when palindrom found
#start with the longest possible, work in
for i in range(len(word),1,-1):
@IanMcT
IanMcT / hangman01.gif
Created November 13, 2016 11:03
Template for hangman game.
GIF89a,��3f���++3+f+�+�+�UU3UfU�U�U���3�f��������3�f��������3�fՙ������3�f������3333f3�3�3�3+3+33+f3+�3+�3+�3U3U33Uf3U�3U�3U�3�3�33�f3��3��3��3�3�33�f3��3��3��3�3�33�f3ՙ3��3��3�3�33�f3��3��3��ff3fff�f�f�f+f+3f+ff+�f+�f+�fUfU3fUffU�fU�fU�f�f�3f�ff��f��f��f�f�3f�ff��f��f��f�f�3f�ffՙf��f��f�f�3f�ff��f��f����3�f���̙��+�+3�+f�+��+̙+��U�U3�Uf�U��U̙U�����3��f�����̙������3��f�����̙������3��f�ՙ��̙������3��f�����̙����3�f�������+�+3�+f�+��+��+��U�U3�Uf�U��U��U�̀̀3̀f̀�̀�̀�̪̪3̪f̪�̪�̪�����3��f�ՙ����������3��f�����������3�f�������+�+3�+f�+��+��+��U�U3�Uf�U��U��U�����3��f�������������3��f�������������3��f�ՙ����������3��f���������!��,,��� H����*\Ȱ�Ç#J�H��ŋ3j�ȱ�Ǐ C�I��ɓ(S�\ɲ�˗0cʜI��͛8s��ɳ�ϟ@�
J��ѣH�*]ʴ�ӧP�J�J��իX�j�ʵ�ׯ`ÊK��ٳhӪ]˶�۷p�ʝK��ݻx���˷�߿� L���È+^̸��ǐ#K�L���˘3k��̹��ϠC�M�.�ӨS�^ͺ��װc˞���Eڸs��ͻ�튽� .�7E�ȓ+gm|���Ћ7���l����Վ�!��߻+ ����濦?Op}W�����:�|����翺z����T�V
@IanMcT
IanMcT / animation_if.py
Created October 11, 2016 02:10
Animates two balls that bounce on the screen.
#import libraries
#Uses http://stackoverflow.com/questions/13215215/python-tkinter-animation
import tkinter
#Set width, height, frames per second and how long to cross
CANVAS_WIDTH = 800
CANVAS_HEIGHT = 600
FPS = 120
SECONDS_TO_CROSS = 1.5
@IanMcT
IanMcT / bank_account.py
Created October 14, 2016 17:23
oop conceps
class BANK_ACCOUNT:
"""Bank account
has balance, and withdraw and deposit functions"""
def __init__(self):
self.balance = 0
def deposit(self, amount):
"""adds money to the balance"""
self.balance += amount
def __str__(self):
return "Balance is: $" + str(format(self.balance,".2f"))
@IanMcT
IanMcT / random_circles.py
Created October 19, 2016 14:38
Create random circles on the screen
#Name
#date
#goal: create a program that displays random circles on the screen
import tkinter#Library
import random #Library for random numbers
#Global variables
CANVAS_WIDTH = 800
CANVAS_HEIGHT = 600
@IanMcT
IanMcT / windowbutton.py
Last active September 26, 2020 22:01
Code for a windows program that takes input, runs code when button pressed output is created. Modify so anything over 300km has added output: Geez, that is far. Anything less than 50 km - Short trip!
#Ian McTavish
#July 26, 2016
#Create a window with an Entry widget
#import required libraries
import tkinter
import tkinter.messagebox #needed for messagebox
class MyGUI:
"""Graphics class"""
@IanMcT
IanMcT / favicon.ico
Created November 13, 2016 11:05
Template for hangman.
 hF ��00 �%V@@ (B�:(  @�������������������|||�ppp�fff�www駧�����U������������������������uVVV�AAA�����������������ddd�GGG��������#��������������Ǔ666���������������������������������]]]��������)���������cFFF�����������������������������������������ccc�������� ��� ���댌����������������������������������������������zzz����w���]<<<�|||���������������������������������zzz�zzz���������������ܟXXX�����bbb�###�����vvv�___�����FFF�����ttt�������������������̹hhh���������+++���������888�����~~~���������������������������йfff��������������������������%%%�ccc������������������������JJJ����������555�sss�������������@@@�����\\\�===������������]zzz�ddd�\\\���������bbb�����������������ooo����������������� ����jjj���������������������������������������������rrr����w������clll���������������������������������������������������� ���������jjj���������������������������������~~~��������)���������������u����MMM�����
@IanMcT
IanMcT / address_book.py
Created November 2, 2016 13:55
Modify based on comments
#Name
#Date
#Add global variable - a list of addresses
#open button should open a set text file
#and load addresses
#close should save using the list
#When open first item displayed
#next moves to next item
import tkinter
@IanMcT
IanMcT / hangman_template.py
Created November 7, 2016 11:02
Template for hangman game.
#I McTavish
#Nov 3, 2016
#Create a template for hangman game.
import tkinter
from tkinter import font
class MyGUI:
"""The class that handles the window"""
def __init__(self):
#main window
@IanMcT
IanMcT / hangman_template.py
Created November 7, 2016 11:04
Modified a comment.
#I McTavish
#Nov 3, 2016
#Create a template for hangman game.
import tkinter
from tkinter import font
class MyGUI:
"""The class that handles the window"""
def __init__(self):
#main window