Skip to content

Instantly share code, notes, and snippets.

View jumbledtextdemo.py
import textjumbler
def main():
print("------------------")
print("| codedrome.com |")
print("| Jumbled Text |")
print("------------------\n")
View xor.py
a = 45 # 00101101 = 45
b = 99 # 01100011 = 99
a = a ^ b # 01001110 = 78 (irrelevant intermediate value)
b = a ^ b # 00101101 = 45
a = a ^ b # 01100011 = 99
View textjumbler.py
import random
from datetime import datetime
def jumble(text, amount):
"""
Jumbles the letters (except first and last) of the words
in text. Amount is a decimal between 0.0 and 1.0 and
specifies the amount of jumbling to be carried out.
View eratosthenes.py
import degree
def main():
print("------------------------")
print("| codedrome.com |")
print("| Eratosthenes and the |")
print("| Size of Planet Earth |")
print("------------------------\n")
View degree.py
class Degree(object):
def __init__(self, degrees = 0, minutes = 0, seconds = 0):
self._seconds = self._seconds_from_dms(degrees, minutes, seconds)
def __str__(self):
dms = self.get()
View baconscipherdemo.py
import baconscipher
def main():
print("------------------")
print("| codedrome.com |")
print("| Bacon's Cipher |")
print("------------------\n")
View baconscipher.py
def encipher(plaintext, target_text):
"""
Encipher plaintext to target text with binary 0
as lower case and binary 1 as upper case
"""
# remove all non-alphabetic characters
# from plaintext and convert to upper case
plaintext = ''.join([c for c in plaintext if c.isalpha()]).upper()
@CodeDrome
CodeDrome / quadrilateralareascoordinatesmain.py
Created Mar 30, 2022
quadrilateralareascoordinatesmain.py
View quadrilateralareascoordinatesmain.py
import quadrilateralareascoordinates
def main():
print("-----------------------------------")
print("| codedrome.com |")
print("| Calculating Areas of |")
print("| Quadrilaterals from Coordinates |")
print("-----------------------------------\n")
@CodeDrome
CodeDrome / quadrilateralareascoordinates.py
Created Mar 30, 2022
quadrilateralareascoordinates.py
View quadrilateralareascoordinates.py
def calculate_area(c):
'''
Calculates the area of any quadrivaletral
from a list of x,y coordinates in the following format:
[[x1,y1],[x2,y2],[x3,y3],[x4,y4]]
'''
first = c[0][0]*c[1][1] + c[1][0]*c[2][1] + c[2][0]*c[3][1] + c[3][0]*c[0][1]
View bretschneidersformulamain.py
import bretschneiderformula
def main():
print("---------------------------------------")
print("| codedrome.com |")
print("| Calculating Areas of Quadrilaterals |")
print("| With Bretschneider's Formula |")
print("---------------------------------------\n")