{{ message }}

Instantly share code, notes, and snippets.

👨‍💻

Dedeco dedeco

👨‍💻
Created Aug 19, 2020
Anagram substring quantity
View anagram.py
 from collections import defaultdict def count_anagram(str): subs = defaultdict(int) for i in range(len(str)): for j in range(1, len(str) + 1): if j > i: subs[''.join(sorted(str[i:j]))] += 1 print(subs)
Created Feb 23, 2020
Poll in Elixir
View poll.ex
 defmodule Poll do defstruct candidates: [] #Public API def start_link() do poll = %Poll{} spawn_link(Poll, :run, [poll]) end def exit(pid) when is_pid(pid) do
Created Jan 14, 2020
Como computar o bit de paridade?
View parity.py
 def parity(x): result = 0 while x: result ^= x & 1 x >>= 1 return result if __name__ == "__main__": print(parity(42))
Created Jan 3, 2020
Como contar o número do bits 1 para um inteiro (não negativo)
View count_bits.py
 def count_bits(x): qty_ones = 0 while x: qty_ones += x & 1 x >>= 1 return qty_ones if __name__ == "__main__": print(count_bits(13))
Last active Dec 26, 2019
Rotate the letters of each city
View rotate_letters.py
 """ ['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris'] // YOUR ALGORITHM [ [ 'Tokyo', 'Kyoto' ], [ 'London', 'Donlon' ], [ 'Rome' ], [ 'Paris' ]
Created Nov 16, 2019
Example agnostic test
View test.py
 # -*- coding: utf-8 -*- import argparse import collections import copy import datetime import dateutil.parser import json from urllib import request, parse
Created Sep 24, 2019
View job.java
 package com.example.jobs; import java.util.ArrayList; import java.util.Arrays; public class job { public static void main(String[] args) { ArrayList> candidates = new ArrayList>(); String[] vaga = { "Java8", "Spring", "NoSQL", "Cloud", "Docker", "UnitTests", "TDD" };
Last active May 30, 2019
View 3.5-multiplex.py
 import logging import threading import time """ 3.5 Multiplex Puzzle: Generalize the previous solution so that it allows multiple threads to run in the critical section at the same time, but it enforces an upper limit on the number of concurrent threads.
Last active May 30, 2019
View 3.4-mutex.py
 import logging import threading import time """ 3.4 Mutex A second common use for semaphores is to enforce mutual exclusion. We have al-ready seen one use for mutual exclusion, controlling concurrent access to sharedvariables.
Created Jan 5, 2019 — forked from oblakeobjet/show_map.py
View show_map.py
 # More Info: http://davydany.com/post/32287214449/matplotlibs-basemap-plotting-a-list-of-latitude def show_map(self, a): # 'a' is of the format [(lats, lons, data), (lats, lons, data)... (lats, lons, data)] lats = [ x[0] for x in a ] lons = [ x[1] for x in a ] data = [ x[2] for x in a ] lat_min = min(lats) lat_max = max(lats)