Skip to content

Instantly share code, notes, and snippets.

View Wingless-Archangel's full-sized avatar
🏠
Working from home

Wingless-Archangel

🏠
Working from home
  • The Matrix
View GitHub Profile
2015-09-29 15:47:03 +0700
python
configure.py
--confirm-license
--bindir=/usr/local/Cellar/pyqt/4.11.3_1/bin
--destdir=/usr/local/Cellar/pyqt/4.11.3_1/lib/python2.7/site-packages
--sipdir=/usr/local/Cellar/pyqt/4.11.3_1/share/sip
Determining the layout of your Qt installation...
‪#‎include‬ <stdio.h>
‪#‎define‬ PRIME_SIZE 20
void primenum(int *pPrimeArray, int nSize)
{
pPrimeArray[0] = 2;
for (int i = 1; i<nSize; i++)
{
int j;
int n = pPrimeArray[i-1]; // last prime
do
@Wingless-Archangel
Wingless-Archangel / 100years.py
Created November 5, 2016 02:52
return year when you are 100
#!/usr/bin/python3
import datetime
def main():
age = input("Please enter your age : ")
print("You will be 100 years in %d" % (datetime.datetime.now().year+(100-age)))
if __name__ == '__main__':
main()
@Wingless-Archangel
Wingless-Archangel / oddeven.py
Created November 5, 2016 03:03
determine the odd and even number from input
#!/usr/bin/python3
import sys
def main():
num = input("please enter the number : ")
if num.isnumeric() != True:
print("Please enter the number")
sys.exit(1)
if num % 2 == 0:
print("this number is even")
@Wingless-Archangel
Wingless-Archangel / listless.py
Created November 5, 2016 06:34
return the element which less than the input number
#!/usr/bin/python3
# Take a list, say for example this one:
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# and write a program that prints out all the elements of the list that are less than 5.
# Extras:
# 1. Instead of printing the elements one by one, make a new list that has all the elements less than 5 from this list in it and print out this new list.
# 2. Write this in one line of Python.
@Wingless-Archangel
Wingless-Archangel / divisor.py
Created November 5, 2016 07:21
get the result of the element that could be divided by
#!/usr/bin/python3
def main():
ref = input("Please enter the divisor : ")
print([ans for ans in range(2,10) if ans % ref == 0])
if __name__ == '__main__':
main()
@Wingless-Archangel
Wingless-Archangel / overlap.py
Created November 5, 2016 07:41
return the list of element that exists in 2 list
#!/usr/bin/python3
def main():
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
ans = list(set([num for num in a if num in a and num in b]))
print(ans)
if __name__ =='__main__':
main()
@Wingless-Archangel
Wingless-Archangel / palindrome.py
Created November 6, 2016 06:11
find out the string is palindrome or not.
#!/usr/bin/python3
def main():
text = input("Please enter the text to test : ")
if text == text[::-1]:
print("This text is palindrome.")
else:
print("This text is not palindrome.")
@Wingless-Archangel
Wingless-Archangel / listcomprehension.py
Created November 6, 2016 06:12
one liner python with list
#!/usr/bin/python3
def main():
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
b = [i for i in a if i % 2 == 0]
print(b)
if __name__=='__main__':
@Wingless-Archangel
Wingless-Archangel / tapeequilibrium.py
Created November 6, 2016 16:42
find the least difference between 2 part of the same list
# you can write to stdout for debugging purposes, e.g.
# print "this is a debug message"
def solution(A):
# write your code in Python 2.7
# Split list into 2 list
if len(A) == 0:
return 0
if len(A) == 1:
return A[0]