This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
def expand_cluster(D, labels, point_idx, neighbors, cluster_id, eps, min_pts): | |
queue = deque(neighbors) | |
labels[point_idx] = cluster_id | |
while queue: | |
current_point = queue.popleft() | |
if labels[current_point] == -1: # previously marked as noise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice | |
features_raw = """ | |
Length of bio INT | |
Number of emoji in bio INT | |
Number of hashtags in first post INT | |
Number of hashtags in bio INT | |
Has mentions in first post Boolean | |
Has mentions in bio Boolean | |
“Has URL in first post” Boolean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python3 my_secret_santa_last_year.py --number_of_users=10 | |
from faker import Faker | |
from uuid import uuid4 | |
import itertools | |
import argparse | |
fake = Faker() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS "auth_group" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(150) NOT NULL UNIQUE); | |
CREATE UNIQUE INDEX "auth_group_permissions_group_id_permission_id_0cd325b0_uniq" ON "auth_group_permissions" ("group_id", "permission_id"); | |
CREATE INDEX IF NOT EXISTS "auth_group_permissions_group_id_b120cbf9" ON "auth_group_permissions" ("group_id"); | |
CREATE INDEX IF NOT EXISTS "auth_group_permissions_permission_id_84c5c92e" ON "auth_group_permissions" ("permission_id"); | |
CREATE UNIQUE INDEX "auth_user_groups_user_id_group_id_94350c0c_uniq" ON "auth_user_groups" ("user_id", "group_id"); | |
CREATE INDEX IF NOT EXISTS "auth_user_groups_user_id_6a12ed8b" ON "auth_user_groups" ("user_id"); | |
CREATE INDEX IF NOT EXISTS "auth_user_groups_group_id_97559544" ON "auth_user_groups" ("group_id"); | |
CREATE UNIQUE INDEX "auth_user_user_permissions_user_id_permission_id_14a6b632_uniq" ON "auth_user_user_permissions" ("user_id", "permission_id"); | |
CREATE INDEX IF NOT EXISTS "auth_user_user_permissions_user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import sys | |
from datetime import datetime | |
cases_til_date = int(sys.stdin.read()) | |
first_us_case_date = datetime.strptime("01-19-20", "%m-%d-%y") | |
today = datetime.now() | |
# Using 2 as base | |
num_of_doubled = math.log(cases_til_date, 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pairs = {")":"(","}":"{","]":"["} | |
stack = [] | |
x = raw_input() | |
balanced = True | |
for i in x: | |
if i in pairs.values(): | |
stack.append(i) | |
else: | |
top = stack.pop() | |
if top == pairs[i]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
NewerOlder