This file contains 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
#!/usr/env python | |
def merge_and_count_split_inversions(A, B, C): | |
""" O(n)""" | |
i = 0 | |
j = 0 | |
inv = 0 |
This file contains 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
3 | |
9 | |
8 | |
4 | |
6 | |
10 | |
2 | |
5 | |
7 | |
1 |
This file contains 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
#!/usr/env python | |
def merge(A, B, C): | |
""" O(n)""" | |
i = 0 | |
j = 0 | |
for k in range(len(A) + len(B)): |
This file contains 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
1 37 79 164 155 32 87 39 113 15 18 78 175 140 200 4 160 97 191 100 91 20 69 198 196 | |
2 123 134 10 141 13 12 43 47 3 177 101 179 77 182 117 116 36 103 51 154 162 128 30 | |
3 48 123 134 109 41 17 159 49 136 16 130 141 29 176 2 190 66 153 157 70 114 65 173 104 194 54 | |
4 91 171 118 125 158 76 107 18 73 140 42 193 127 100 84 121 60 81 99 80 150 55 1 35 23 93 | |
5 193 156 102 118 175 39 124 119 19 99 160 75 20 112 37 23 145 135 146 73 35 | |
6 155 56 52 120 131 160 124 119 14 196 144 25 75 76 166 35 87 26 20 32 23 | |
7 156 185 178 79 27 52 144 107 78 22 71 26 31 15 56 76 112 39 8 113 93 | |
8 185 155 171 178 108 64 164 53 140 25 100 133 9 52 191 46 20 150 144 39 62 131 42 119 127 31 7 | |
9 91 155 8 160 107 132 195 26 20 133 39 76 100 78 122 127 38 156 191 196 115 | |
10 190 184 154 49 2 182 173 170 161 47 189 101 153 50 30 109 177 148 179 16 163 116 13 90 185 |
This file contains 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 os | |
import ast | |
import marshal | |
import uuid | |
import meta | |
def pyc2py(pyc_file, path='/tmp'): |
This file contains 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 gevent | |
from gevent import monkey; monkey.patch_all() | |
from gevent_zeromq import zmq | |
import simplejson as json | |
import threading | |
import time | |
def server(context): | |
poll = zmq.Poller() |
This file contains 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 gevent | |
from gevent import monkey; monkey.patch_all() | |
from gevent_zeromq import zmq | |
import simplejson as json | |
import threading | |
import time | |
def server(context): | |
""" server routine """ |
This file contains 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
# Class for managing multiple servers or anything with start() and stop() methods | |
class ServerRack(object): | |
def __init__(self, servers): | |
self.servers = servers | |
def start(self): | |
started = [] | |
try: |