Skip to content

Instantly share code, notes, and snippets.

@Hwatwasthat
Hwatwasthat / main.py
Created February 21, 2018 10:54
List comparison created by Hwatwasthat - https://repl.it/@Hwatwasthat/List-comparison
import random
# Generate Lists
list1 = random.sample(range(50), 20)
list2 = random.sample(range(50), 20)
lists_compared = []
# Compare list a and b, put into a list from a set (compares as a set)
@Hwatwasthat
Hwatwasthat / main.py
Created February 21, 2018 10:55
Divisors created by Hwatwasthat - https://repl.it/@Hwatwasthat/Divisors
#Enter number for divisors here
Num = int(input("What number do you want Divisors for?"))
#Ensure number is positive
if Num <= 0:
print("Number must be positive")
quit()
#create range to work in
range_nums = range(1, Num)
@Hwatwasthat
Hwatwasthat / main.py
Last active February 21, 2018 10:56
List manipulation created by Hwatwasthat - https://repl.it/@Hwatwasthat/List-manipulation
# Initiating variables, list is fixed, value is an input from the console
# and result is an empty list to be filled with results
list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
value = int(input("what would you like to count to?"))
result = []
# For loop that compares values in list to value from beginning to end of the list.
# if the value in list is smaller than value then it is appended to the empty list result
for i in range(len(list)):
if list[i] <= value:
@Hwatwasthat
Hwatwasthat / Palindrome check.py
Created February 21, 2018 14:13
Palindrome check created by Hwatwasthat - https://repl.it/@Hwatwasthat/Palindrome-check
# Input from console for word to check
word = input("What would you like to check if its a Palindrome?")
#initialise variables
x = 0
reverse_word = ''
# loop over word until all letters are done
for i in word:
# increment counter
x += 1
# extend reverse_word with next letter from word (reversed)
@Hwatwasthat
Hwatwasthat / XOR.py
Created February 21, 2018 15:13
Hex to base64 created by Hwatwasthat - https://repl.it/@Hwatwasthat/Hex-to-base64
import base64
def hex_to_base64(input):
result = bytearray.fromhex(input)
result = base64.b64encode(result)
result = str(result).strip("'b'")
return result
@Hwatwasthat
Hwatwasthat / XOR two hex values.py
Created February 21, 2018 16:02
XOR two hex values created by Hwatwasthat - https://repl.it/@Hwatwasthat/XOR-two-hex-values
# Values entered must be hex encoded, preface with 0x if not already
def hex_xor(first, second):
result = (first ^ second)
return result
@Hwatwasthat
Hwatwasthat / List no duplicates.py
Created February 22, 2018 11:10
List no duplicates created by Hwatwasthat - https://repl.it/@Hwatwasthat/List-no-duplicates
import random
list = []
i = 0
while i < 100:
list.append(random.randrange(1,40))
i += 1
# creating a list with no duplicates using a for loop
def list_no_duplicates(list):
# sorting list to make it pretty
import string, random
from collections import OrderedDict
from itertools import count
# creating numerically linked dictionaries to pull characters from
lower = OrderedDict(zip(count(1), string.ascii_lowercase))
upper = OrderedDict(zip(count(27), string.ascii_uppercase))
symbols = OrderedDict(zip(count(53), (string.punctuation)))
length = int(input("How many characters would you like in your password?"))
i = 0
import random, time
k = 0
def sorted_list(a, b):
test = random.sample(range(a), b)
test.sort()
return test
def binary_search(sorter, num_find):
print (sorter)
word = input("In:")
sumof = 0
x = 0
for i in word:
if word[x] == "a" or word[x] == "e" or word[x] == "i" or word[x] == "o" or word[x] == "u":
sumof += 1
x += 1
print(sumof)