Skip to content

Instantly share code, notes, and snippets.

@popey456963
popey456963 / project.md
Last active October 31, 2015 00:50
AQA Coursework Project
@popey456963
popey456963 / countingup.md
Last active November 2, 2015 16:46
Counting Up

#Title

Counting Up

#Statement Write a program that takes a {{String}} as it's input and outputs a [[String]] as output based on several factors:

  • If the [[character]] is an upper-case letter [A-Z] then print out the letters [A-[[character]]].
  • If the [[character]] is a lower-case letter [a-z] then print out the letters [a-[[character]]].
  • If the [[character]] is a digit [0-9], then print out the numbers [0-[[character]]]
@popey456963
popey456963 / mostcommon.py
Created October 29, 2015 09:53
Most Common (Collections)
import collections
s = "".join(input().split())
print(collections.Counter(s).most_common(1)[0][1])
@popey456963
popey456963 / stringreplace.py
Created October 28, 2015 17:41
Replace One String with Another
string="zyxwvutsrqponmlkjihgfedcba"
string2="abcdefghijklmnopqrstuvwxyz"
a=""
for i in input():
a+=string[string2.index(i)]
print(a)
@popey456963
popey456963 / vigenere.py
Created October 28, 2015 15:33
Vigenere Cipher Solver
from itertools import starmap, cycle
i,o=input,ord
def d(c,k):return(chr(((o(c)-o(k))%26)+o('a'))," ")[c==" "]
print("".join(starmap(d,zip(i(),cycle(i())))))
@popey456963
popey456963 / octant.py
Created October 28, 2015 15:11
Octant
def get_octant(x,y):
try:
if abs(x)/abs(y) == 1:
return "undefined"
except:
return "undefined"
dx, dy = x,y
octant = 0
if dy < 0:
dx, dy = -dx, -dy # rotate by 180 degrees
@popey456963
popey456963 / freecoffee.py
Created October 28, 2015 14:56
Testing if Coffee is Free
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
id_badge =[]
seen = []
n = int(input())
for i in range(n):
id_badge.append(input())
@popey456963
popey456963 / onlyone.py
Created October 28, 2015 14:51
Only Ones
x=int(input())
if bin(x)[2:].count("1") == len(bin(x))-2:
print("true")
else:
print("false")
@popey456963
popey456963 / pattern.py
Created October 28, 2015 14:23
Printing a Pattern
n,d=int(input()),"123456789"
for i in range(n):print("+"*i+d[:n-i])
@popey456963
popey456963 / duplicates.py
Created October 28, 2015 14:17
Remove Duplicates, Preserve Order
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
x=[]
n = int(input())
for i in range(n):
x.append(int(input()))
def f7(seq):