Skip to content

Instantly share code, notes, and snippets.

View Irene-123's full-sized avatar
🎯
Focusing

kirti purohit Irene-123

🎯
Focusing
View GitHub Profile
@Irene-123
Irene-123 / selective.py
Created December 23, 2020 13:17
selective copy
import shutil,os
def selectiveCopy(folder,extensions,destFolder):
folder=os.path.abspath(folder)
print(folder)
destFolder=os.path.abspath(destFolder)
print(destFolder)
print('Looking in '+ folder+ ' for files with extensions of ', ','.join(extensions))
for foldername,subfolders,filenames in os.walk(folder):
print("***",foldername, "**", subfolders , "*",filenames)
@Irene-123
Irene-123 / regex.py
Created December 23, 2020 13:16
ATBS2
#!usr/bin/python3
import re
file=open('mad.txt')
text=file.read()
file.close()
regex=re.compile(r'(NOUN) | (ADJECTIVE) | (VERB)')
@Irene-123
Irene-123 / quiz.py
Created December 23, 2020 13:15
ATBS
import random
capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix',
'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver',
'Connecticut': 'Hartford', 'Delaware': 'Dover', 'Florida': 'Tallahassee',
'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinois':
'Springfield', 'Indiana': 'Indianapolis', 'Iowa': 'Des Moines', 'Kansas':
'Topeka', 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine':
'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', 'Michigan':
'Lansing', 'Minnesota': 'Saint Paul', 'Mississippi': 'Jackson', 'Missouri':
@Irene-123
Irene-123 / transpose.m
Created December 23, 2020 05:06
Octave experiment
a=magic(4);
fprintf('The original matrix is:\n');
disp(a);
b=a.';
fprintf('\n');
fprintf('The transposed matrix is :\n');
disp(b)
@Irene-123
Irene-123 / day12part2.py
Created December 21, 2020 12:49
Advent of code day12 part 2
import math
def rotate(origin, point, angle):
# source: https://stackoverflow.com/a/34374437
ox, oy = origin
px, py = point
qx = ox + math.cos(angle) * (px - ox) - math.sin(angle) * (py - oy)
qy = oy + math.sin(angle) * (px - ox) + math.cos(angle) * (py - oy)
return int(round(qx)), int(round(qy))
@Irene-123
Irene-123 / day12.py
Created December 21, 2020 12:48
Advent of Code Day-12 part 1
with open("day12.txt", "r") as file:
lines = [(line.rstrip()[0], int(line.rstrip()[1:])) for line in file.readlines()]
dirs = ["E", "S", "W", "N", "L", "R", "F"]
curr_dir = "E"
curr_state = {"E":0, "W":0, "N":0, "S":0}
for line in lines:
if line[0] == "F":
curr_state[curr_dir] += line[1]
@Irene-123
Irene-123 / sudan.py
Last active December 6, 2020 10:07
Sudan Neighbouring countries
data = dict(type = 'choropleth',
locations = ['Egypt','Eritrea','Ethiopia',
'Central African Republic','Chad','Libya',
'South Sudan','Sudan'],
locationmode = 'country names',
colorscale= 'Portland',
text= ['EG','ER','ET','CF','TD','LBY','SDN','SD'],
z=[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0],
colorbar = {'title':'Country Colours', 'len':200,'lenmode':'pixels' })
col_map = gobj.Figure(data = [data])
@Irene-123
Irene-123 / car_fueling.py
Created November 27, 2020 04:26
The car Fueling problem
def car_fueling(dist,miles,n,gas_stations):
num_refill, curr_refill, limit = 0,0,miles
while limit < dist:
# While the destination cannot be reached with current fuel
if curr_refill >= n or gas_stations[curr_refill] > limit:
# Cannot reach the destination nor the next gas station
return -1
# Find the furthest gas station we can reach
@Irene-123
Irene-123 / hulk.py
Created November 7, 2020 03:00
Codeforces- 705A Hulk problem
# KIRTI PUROHIT
# [email protected]
n=int(input())
hate=''
for i in range(1,n):
if i%2==0:
hate+=' I love that'
else:
hate+=' I hate that'
@Irene-123
Irene-123 / coinGuessing.py
Created October 1, 2020 14:09
Guess the coin Project-Automate the boring stuff
import random
guess=''
while guess not in ('head','tail'):
print('Guess the coin Toss ! heads or tails ?!')
guess=input()
toss=random.randint(0,1)
if toss:
tt='head'
else: