Skip to content

Instantly share code, notes, and snippets.

View prithajnath's full-sized avatar

Prithaj Nath prithajnath

View GitHub Profile
# Prithaj
# Problem URL : https://www.hackerrank.com/challenges/rust-murderer
from collections import deque
T = input()
# BFS
def return_nodes(N,a,edges):
for i in xrange(1,N+1):
if i != a and (i,a) not in edges and (a,i) not in edges:
yield i
points = {1.047:1.139,2.005:2.087,3.348:3.413,5.719:5.765,7.273:7.304,8.41:8.426,9.117:9.127}
avg,slopes = 0.0,set()
for i in points:
for j in points:
if i!=j and (i,j) not in slopes:
avg = avg + float(points[j]-points[i])/float(j-i)
slopes.add((i,j))
print avg/float(len(points))
def shopSmart(orderList, fruitShops):
"""
orderList: List of (fruit, numPound) tuples
fruitShops: List of FruitShops
"""
"*** YOUR CODE HERE ***"
costs = {}
for i in fruitShops:
cost = 0
for j in xrange(len(orderList)):
#!/bin/python
import sys
from collections import deque
def gen_nbrs(node,move,n):
x,y = move[0],move[1]
nbr = []
for i in [('+','-'),('-','+'),('-','-'),('+','+')]:
a,b = node[0],node[1]
if i[0] == '-':
a = a - x
def depthFirstSearch(problem):
"""
Search the deepest nodes in the search tree first.
Your search algorithm needs to return a list of actions that reaches the
goal. Make sure to implement a graph search algorithm.
To get started, you might want to try some of these simple commands to
understand the search problem that is being passed in:
import mechanize
import time
browser = mechanize.Browser()
print("EZ Verizon SMS Spammer \n")
x=0
numbofmessages = int(input("How many times do you want this message sent? "))
to = raw_input("To: ")
verizon = "@vtext.com"
#!/bin/python
import sys
from collections import Counter
n = int(raw_input().strip())
a = map(int,raw_input().strip().split(' '))
max_num = -1
freq = Counter(a)
new_arr = freq.keys()
def replaceWord(sentence,word):
words = sentence.split()
for i in range(len(words)):
if word == words[i]:
words[i] = "".join(['-' for _ in range(len(word))])
break
return " ".join(words)
def replaceMultiWords(sentence,words):
new_str = sentence
#!/bin/python
import sys
n = int(raw_input().strip())
for a0 in xrange(n):
grade = int(raw_input().strip())
# your code goes here
if grade < 100 and grade >= 38:
var j = JSON.parse('{"currentRow":-1,"rows":[[{"name":"sys_created_by","value":"admin"},{"name":"sys_created_on","value":"2017-06-02 17:47:50"},{"name":"sys_id","value":"e6f247eedb433200f93cddd0cf961923"},{"name":"sys_mod_count","value":"2"},{"name":"sys_updated_by","value":"admin"},{"name":"sys_updated_on","value":"2017-06-05 14:34:30"},{"name":"u_asset","value":"false"},{"name":"u_category","value":"Hardware"},{"name":"u_change","value":"false"},{"name":"u_customer_case","value":"false"},{"name":"u_hr_case","value":"false"},{"name":"u_incident","value":"true"},{"name":"u_problem","value":"false"},{"name":"u_subcategory","value":"CPU,GPU"},{"name":"u_task","value":"false"}]],"conditions":[{"name":"u_category","oper":"=","value":"Hardware"}],"encodedQuery":"","orderByFields":[],"orderByDescFields":[],"displayFields":[],"maxQuerySize":-1,"_wantSessionMessages":true,"tableName":"u_table_category"}');
var my_array = j['rows'][0];
var cpu;
for(var i=0;i<my_array.length;i++){
if(my_array[i]['value']==="CPU,GPU")