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 socket | |
import sys | |
def socket_client(host: str, port: int): | |
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_client: | |
dest = (host, port) | |
print(f"Connected to: {host}:{port}") | |
msg = input() | |
while msg != '\x18': |
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
use chrono::{ | |
Timelike, | |
Utc, | |
}; | |
use std::{ | |
io::{ | |
self, | |
Read, | |
Error as IoError, | |
ErrorKind, |
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
# https://leetcode.com/problems/find-median-from-data-stream/ | |
# Work in progress | |
class MedianFinder: | |
def __init__(self): | |
""" | |
initialize your data structure here. | |
""" | |
self.number_count: Dict[int, int] = {} | |
self.size = 0 | |
self.sorted_keys = None |
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
namespace multi { | |
using System; | |
using System.Linq; | |
public class MultiEntryPointSmartContract : SmartContract { | |
public object Main (string name, params object[] parameters) { | |
if (name == null || name.Trim().Length == 0) { | |
throw new ArgumentNullException("The method name parameter can not be empty"); | |
} | |
var methods = this.GetType().GetMethods().Where(x => x.Name == name && x.GetParameters().Length == parameters.Length); | |
if (methods.Count() == 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
# Complete the minimumBribes function below. | |
def minimumBribes(q): | |
soma = 0 | |
for i in xrange(len(q) - 1, -1, -1): | |
if q[i] - (i + 1) > 2: | |
print("Too chaotic") | |
return | |
for j in xrange(max(0, q[i] - 2), i): | |
soma += q[j] > q[i] | |
print soma |
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
# Complete the minimumBribes function below. | |
def minimumBribes(q): | |
soma = 0 | |
for i in xrange(len(q) - 1, -1, -1): | |
if q[i] - (i + 1) > 2: | |
print("Too chaotic") | |
return | |
for j in xrange(max(0, q[i] - 2), i): | |
soma += q[j] > q[i] | |
print soma |