Skip to content

Instantly share code, notes, and snippets.

View libert-xyz's full-sized avatar
🗽
/dev/urandom

Libert Schmidt libert-xyz

🗽
/dev/urandom
View GitHub Profile
square = [X**2 for x in range(10)]
@libert-xyz
libert-xyz / Guest the Number
Created December 30, 2015 05:52
A simple Guest the Number Game
#!/usr/bin/env python
from random import randint
opt = 3
rn = (randint(100,199))
while opt >= 0:
if opt == 0:
print "You Lost, the number was: ", rn
##Libert R Schmidt
##rschmidt@libert.xyz
##List Overlap Comprehensions http://www.practicepython.org/exercise/2014/04/10/10-list-overlap-comprehensions.html
import random
a = random.sample(range(1,50),10)
b = random.sample(range(1,50),10)
common = [i for i in a if i in b]
##Libert R Schmidt
##rschmidt@libert.xyz
##http://www.practicepython.org/exercise/2014/04/16/11-check-primality-functions.html
def divisors(num):
c = 0
for i in range(1,num+1):
if num % i == 0:
c = c + 1
return c
#Libert R Schmidt
#rschmidt@libert.xyz
#http://www.practicepython.org/exercise/2014/04/25/12-list-ends.html
def listEnds():
n = 0
a = [5, 10, 15, 20, 25]
newList = []
for i in range(0,2):
#Libert R Schmidt
#http://www.practicepython.org/exercise/2014/04/30/13-fibonacci.html
def fibo(num):
s1 = 0
s2 = 1
l = []
for i in range(num+1):
s2 = s2 + s1
#rschmidt@libert.xyz
#http://www.practicepython.org/exercise/2014/07/05/18-cows-and-bulls.html
import random
def start():
num = input('Enter a 3 digit number: ')
return num
@libert-xyz
libert-xyz / avg_dic.py
Created June 27, 2016 15:48
Finding the percentage
#Finding the percentage
#6/27/16
#https://www.hackerrank.com/challenges/finding-the-percentage
avg = {}
number = input(('Number of students: '))
for i in range(number):
name_marks = raw_input(str('Name and Marks: '))
@libert-xyz
libert-xyz / list_hacker.py
Created June 28, 2016 17:06
Each command will be of the commands given above. The extend(L) method will not be used. Each command will have its own value(s) separated by a space.
#6/28/16
#python 3
#https://www.hackerrank.com/challenges/python-lists
for i in range(n):
command, *args = input().split()
if 'print' in command:
print (N)
#https://www.hackerrank.com/challenges/python-tuples
#06/29/16
#map(function, iterable, ...)
#Return an iterator that applies function to every item of iterable, yielding the results. If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see itertools.starmap().
input()
print (hash(tuple(map(int, input().split(" ")))))