This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import degree | |
def main(): | |
print("------------------------") | |
print("| codedrome.com |") | |
print("| Eratosthenes and the |") | |
print("| Size of Planet Earth |") | |
print("------------------------\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import baconscipher | |
def main(): | |
print("------------------") | |
print("| codedrome.com |") | |
print("| Bacon's Cipher |") | |
print("------------------\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import quadrilateralareascoordinates | |
def main(): | |
print("-----------------------------------") | |
print("| codedrome.com |") | |
print("| Calculating Areas of |") | |
print("| Quadrilaterals from Coordinates |") | |
print("-----------------------------------\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bretschneiderformula | |
def main(): | |
print("---------------------------------------") | |
print("| codedrome.com |") | |
print("| Calculating Areas of Quadrilaterals |") | |
print("| With Bretschneider's Formula |") | |
print("---------------------------------------\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
import math | |
def calculate_area(sides, opposite_angles_degrees): | |
''' | |
Calculate the area of a quadrilateral using Bretschneider's Formula | |
from the lengths of the sides and either pair of OPPOSITE angles. | |
Arguments:- |