Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammedAl-Rasheed authored Mar 28, 2021
1 parent ea49868 commit 10843c2
Show file tree
Hide file tree
Showing 17 changed files with 491 additions and 1 deletion.
39 changes: 39 additions & 0 deletions 2019-s1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# made by mohammed
rotate = str(input())

V = 0
H = 0

stack = []

stack.append(1)
stack.append(2)
stack.append(3)
stack.append(4)

temp = stack


for i in range(0, len(rotate)):
if(rotate[i] == 'V'):
V = V + 1
elif(rotate[i] == 'H') :
H = H + 1

count = 0

while count != H:
stack[0], stack[2] = stack[2], stack[0]
stack[1], stack[3] = stack[3], stack[1]
count = count + 1

count = 0

while count != V:
stack[0], stack[1] = stack[1], stack[0]
stack[2], stack[3] = stack[3], stack[2]
count = count + 1


print(str(stack[0]) + " " + str(stack[1]))
print(str(stack[2]) + " " + str(stack[3]))
17 changes: 17 additions & 0 deletions 2020-j1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Problem J1: Dog Treats
#Problem Description

#Barley the dog loves treats. At the end of the day he is either happy or sad depending on the number and size of treats he receives throughout the day. The treats come in three sizes: small, medium, and large. His happiness score can be measured using the following formula:1 × S + 2 × M + 3 × L where S is the number of small treats, M is the number of medium treats and L is the number of large treats. If Barley’s happiness score is 10 or greater then he is happy. Otherwise, he is sad. Determine whether Barley is happy or sad at the end of the day


#1 × S + 2 × M + 3 × Ls = 3
s = int(input())
m = int(input())
l = int(input())

if 1*s+2*m+3*l < 10:
result = "sad"
else:
result = "happy"

print(result)
20 changes: 20 additions & 0 deletions 2020-j2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
p = int(input())
n = int(input())
r = int(input())
total = n
new_infections = n
day = 0
while (True):
#print("new infections on day"+ str(day) + ": " + str(new_infections))
#print("total:" + str(total))

if total > p:
print(day)
break

new_infections = new_infections*r

total += new_infections

day += 1

32 changes: 32 additions & 0 deletions 2020-j3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#made by mohammed

first = int(input())
drops = []

for i in range(first):
drop = {}
dropinput = list(map(int, input().split(',')))
drop['x'] = dropinput[0]
drop['y'] = dropinput[1]
drops.append(drop)

lowX = None
highX = None
lowY = None
highY = None

for co in drops:
x = co['x']
y = co['y']

if not lowX or x < lowX:
lowX = x
if not highX or x > highX:
highX = x
if not lowY or y < lowY:
lowY = y
if not highY or y > highY:
highY = y

print(str(lowX - 1)+ ',' + str(lowY - 1))
print(str(highX + 1)+ ',' + str(highY + 1))
20 changes: 20 additions & 0 deletions 2020-j4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#made by mohammed
string = input()
answer = input()

list = []

for i in range(len(answer)):
list.append(answer[i:]+answer[:i])

state = 0

for s in list:
if s in string:
state = 1
break

if state == 0:
print("no")
else:
print("yes")
38 changes: 38 additions & 0 deletions 2020-j5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
m = int(input())
n = int(input())
#grid = [ [3, 10, 8, 14], [1, 11, 12, 12], [6, 2, 3, 9] ]
grid = []

for i in range(m):
line = input().split()
line = [int(i) for i in line]
grid.append(line)

end_cell = (m,n)

visited = set([(1, 1)])

stack = [[1,1]]

while stack:
(r, c) = stack.pop()
#print("Popped: ", (r, c))
x = grid[r-1][c-1]
for i in range(1, x+1):
mod = x % i
if mod == 0:
new_cell = (i, x//i)
if new_cell [0] <= m and new_cell[1] <= n:
if new_cell == end_cell:
print("Yes")
exit()
if new_cell not in visited:
stack.append(new_cell)
#print("Appended: ", new_cell)

visited.add(new_cell)
#print("Visited: ", visited)


print("no")

31 changes: 31 additions & 0 deletions 2020-s1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#made by marwan and mohammed
from operator import itemgetter

#done
n = int(input())
m = []

#done
for i in range(n):
line = input().split()
line = [int(i) for i in line]
m.append(line)

a = m
m = sorted(a)

PP = m[0][1] #100
PT = m[0][0] #0
max_speed = 0
for i in range(len(m) - 1):
if m[i+1][1] < PP:
temp_speed = (PP - m[i + 1][1] ) / (m[i + 1][0] - PT)
else:
temp_speed = (m[i + 1][1] - PP) / (m[i + 1][0] - PT)
PT = m[i + 1][0]
PP = m[i + 1][1]
if temp_speed > max_speed:
max_speed = temp_speed


print(max_speed)
46 changes: 46 additions & 0 deletions 2020-s1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Refinment #1

take in number of lines
declare a mesurements list

for loop through the number of lines
take in the line and split it since its seperated by a space
convert line to int
add line to mesurements lists

sort mesurements
https://www.kite.com/python/answers/how-to-sort-a-list-of-lists-by-an-index-of-each-inner-list-in-python


Refinment #2
take in number of lines
declare a mesurements list

for loop through the number of lines
take in the line and split it since its seperated by a space
convert line to int
add line to mesurements lists

sort mesurements
https://www.kite.com/python/answers/how-to-sort-a-list-of-lists-by-an-index-of-each-inner-list-in-python

PP = mesurements[0][1]
PT = mesurements[0][0]
max_speed = 0

for i in range(len(mesurements)):
temp_speed = (mesurements[i + 1][1] - PT) / (mesurements[i + 1][0] - PT)
PT = mesurements[i + 1][0]
PP = mesurements[i + 1][1]
if temp_speed > max_speed:
max_speed = temp_speed

FORUMULA:
(next position - previous position) / (next time - previous time) = speed

(120 - 100) / 10
# since 120 is bigger than 50 we subtract previous position by next position
(120 - 50) / (20 - 10)



16 changes: 16 additions & 0 deletions 2020-s3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from itertools import permutations

str1 = input()
perms = [''.join(p) for p in permutations(str1)]
perms = list(set(perms))
#print(perms)
str2 = input()
#points = 0
#for i in range(len(perms)):
# if perms[i] in str2:
# points = points + 1

#print(points)
print(sum(substring in str2 for substring in perms))


2 changes: 2 additions & 0 deletions 2020-s3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
this one is actually really ez you find all the permutations
of the first string and add that to a list than make sure that none of the permutations in the list are in the second string
15 changes: 15 additions & 0 deletions 2021-j1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
b = int(input())

p = 5*b-400

print(p)

if p < 100:
result = 1
elif p == 100:
result = 0
elif p > 100:
result = -1


print (result)
15 changes: 15 additions & 0 deletions 2021-j2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
number = int(input())

names = []

bids = []

for i in range(number):
name = input()
bid = int(input())
scores.append(bid)
names.append(name)

highbid = bids.index(max(bids))

print(names[highbid])
19 changes: 19 additions & 0 deletions 2021-j3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
number = int(input())
number = [int(x) for x in str(number)]
sum = number[0] + number[1] + number[2] + number[3] + number[4]
direction = 0
sum1 = 0

while sum != 45:
sum1 = number[0] + number[1]
if (sum1 == 0):
print(previous + str(number[2]) + str(number[3]) + str(number[4]))
elif (sum1 % 2) == 0:
print("right " + str(number[2]) + str(number[3]) + str(number[4]))
previous = "right "
elif (sum1 % 2) == 1:
print("left " + str(number[2]) + str(number[3]) + str(number[4]))
previous = "left "
number = input()
number = [int(x) for x in str(number)]
sum = number[0] + number[1] + number[2] + number[3] + number[4]
14 changes: 14 additions & 0 deletions 2021-j4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import math

def split(word):
return [char for char in word]
string = input()
sortedL = sorted(string)
string = split(string)
counter = 0

for x in range(len(sortedL)):
if string[x] != sortedL[x]:
counter = counter + 1

print(math.ceil(counter/2))
Loading

0 comments on commit 10843c2

Please sign in to comment.