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 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) |
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
| 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 |
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 parity(x): | |
| result = 0 | |
| while x: | |
| result ^= x & 1 | |
| x >>= 1 | |
| return result | |
| if __name__ == "__main__": | |
| print(parity(42)) |
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 count_bits(x): | |
| qty_ones = 0 | |
| while x: | |
| qty_ones += x & 1 | |
| x >>= 1 | |
| return qty_ones | |
| if __name__ == "__main__": | |
| print(count_bits(13)) |
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
| """ | |
| ['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris'] | |
| // YOUR ALGORITHM | |
| [ | |
| [ 'Tokyo', 'Kyoto' ], | |
| [ 'London', 'Donlon' ], | |
| [ 'Rome' ], | |
| [ 'Paris' ] |
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
| # -*- coding: utf-8 -*- | |
| import argparse | |
| import collections | |
| import copy | |
| import datetime | |
| import dateutil.parser | |
| import json | |
| from urllib import request, parse | |
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
| package com.example.jobs; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| public class job { | |
| public static void main(String[] args) { | |
| ArrayList<ArrayList<String>> candidates = new ArrayList<ArrayList<String>>(); | |
| String[] vaga = { "Java8", "Spring", "NoSQL", "Cloud", "Docker", "UnitTests", "TDD" }; |
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 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. | |
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 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. |
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
| # 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) |