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 sys | |
# Solve https://www.hackerrank.com/challenges/magic-square-forming/problem | |
matrix_list = [[[8, 1, 6], [3, 5, 7], [4, 9, 2]], | |
[[6, 1, 8], [7, 5, 3], [2, 9, 4]], | |
[[4, 9, 2], [3, 5, 7], [8, 1, 6]], | |
[[2, 9, 4], [7, 5, 3], [6, 1, 8]], | |
[[8, 3, 4], [1, 5, 9], [6, 7, 2]], | |
[[4, 3, 8], [9, 5, 1], [2, 7, 6]], | |
[[6, 7, 2], [1, 5, 9], [8, 3, 4]], |
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 merge_sort(v: list) -> list: | |
if len(v) < 2: | |
return v | |
middle = int(len(v) / 2) | |
left = deque(merge_sort(v[:middle])) | |
right = deque(merge_sort(v[middle:])) | |
out = [] |
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
_db = couchdb.Server("http://user:[email protected]:5984/")['base_de_datos_loca'] | |
def get_all_views(db: couchdb.Server) -> list: | |
views_raw = _db.view('_all_docs', startkey="_design/", endkey="_design0", include_docs=True) | |
return [view.id.split('/')[1] for view in views_raw.rows] | |
return views | |
if __name__ == '__main__': | |
print(get_all_views(_db)) |
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
@staticmethod | |
def get_system_timezone() -> str: | |
""" | |
Retorna el timezone del sistema | |
:return: Ej: America/Caracas | |
""" | |
str_timezone = subprocess.getoutput('ls /etc/ -l | grep localtime | awk \'{print $11}\'') | |
assert str_timezone is not None and len(str_timezone) and \ | |
str_timezone.find('../usr/share/zoneinfo/') != -1, "TIMEZONE_GET_ERROR:" | |
str_timezone = str_timezone.replace('../usr/share/zoneinfo/', '') |
NewerOlder