Skip to content

Instantly share code, notes, and snippets.

View vikychoi's full-sized avatar
💭
I am trying to be a script kiddie

Viky vikychoi

💭
I am trying to be a script kiddie
View GitHub Profile
@vikychoi
vikychoi / python Ex14
Last active January 30, 2018 09:34
List remove duplicates
def removeduplicates_v1(lst):
lst = set(lst)
return list(lst)
def removeduplicates_v2(lst):
new_lst = []
for i in range((len(lst)-1)):
if (lst[i] not in new_lst):
new_lst.append(lst[i])
return new_lst
eg = [1,2,3,4,1,2,3,4]
@vikychoi
vikychoi / python Ex13
Created January 30, 2018 09:11
Returns value of requested term of Fibonacci number
def fibonnaci(x):
if(x == 1):
return 1
elif(x == 0):
return 0
else:
return fibonnaci(x -1) + fibonnaci(x -2)
number = int(input("Please entre the number of term of fibonnaci number"))
print("The number of ", number,"term of fibonnaci number is ", fibonnaci(number))
@vikychoi
vikychoi / Python Ex12
Created January 27, 2018 16:32
List list ends
def listEnds(list_x):
b = [0,0]
b[0]= list_x[0]
b[1] = list_x[len(list_x)-1]
return b
a = [5, 10, 15, 20, 25]
array = []
array = listEnds(a)
@vikychoi
vikychoi / Python Ex11
Created January 27, 2018 15:49
Check Primality Function
def checkprime(input):
counter = 0
for i in range(1, input+1):
result = input // i
print(result, counter)
if (result * i == input):
counter += 1
if (counter > 2):
return False
return True
#include <stdio.h>
int main()
{
int a, b, c, d;
printf("Enter fraction 1(numerator denominator) \n");
scanf("%d %d", &a,&b);
printf("Enter fraction 2(numerator denominator) \n");
scanf("%d %d", &c, &d);
if (b == 0 || d == 0){
@vikychoi
vikychoi / gist:682091f70bf1bfa7549a9781531ef6a3
Created January 4, 2018 13:53
C for multiplying string
#include <stdio.h>
main()
{
int i;
int p;
for(i = 1; i <=16; i++)
{
for (p=1; p<=i; p++)
{
printf("**");
#include <stdio.h>
main()
{
printf("input x\n");
int x;
scanf("%d", &x);
printf("input y\n");
int y;
scanf("%d",&y);
int i;
import random
a=[]
b=[]
c=[]
for i in range (random.randint(10,20)):
a.append(random.randint(1,100))
import random
number = random.randint(1,9)
print("type exit to leave")
attempt = 1
while True:
guess = input("please guess a number from 1 to 9")
if guess != "exit":
# i will do player vs comp
import random
will = 1
while will == 1:
player = input("rock, paper, scissors")
comp = random.randint(1,3)
if comp ==1:
comp = "rock"