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
{ | |
"RS": { | |
"estado": "RIO GRANDE DO SUL", | |
"validacao": "###-#######" | |
}, | |
"SC": { | |
"estado": "SANTA CATARINA", | |
"validacao": "###.###.###" | |
}, | |
"PR": { |
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
def validaQMagico(QMagico): | |
if len(QMagico) == 0 or len(QMagico) != len(QMagico[0]): return False | |
linhasOK = not sum([ True if sum(linha) != sum(QMagico[0]) else False for linha in QMagico ]) | |
colunasOK = not sum([ sum([ linha[i] for linha in QMagico ]) != sum(QMagico[0]) for i in range(len(QMagico[0])) ]) | |
diagonaisOK = True | |
for i in range(len(QMagico[0])): | |
if (sum( [linha[i] for linha in QMagico] )!=sum(QMagico[0])): diagonaisOK = False | |
i+=1 | |
return linhasOK and colunasOK and diagonaisOK |
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
<?php | |
foreach(json_decode(file_get_contents("http://worldcup.sfg.io/matches")) as $jogo) { | |
echo $jogo->status == 'completed' ? $jogo->home_team->country . '(' . $jogo->home_team->goals . ') x (' . $jogo->away_team->goals . ')' . $jogo->away_team->country . '<br>' : ''; | |
} |
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 urllib.request | |
import json | |
import time | |
url = 'http://api.icndb.com/jokes?limitTo=[nerdy]' | |
resp = urllib.request.urlopen(url).read() | |
data = json.loads(resp.decode('utf-8')) | |
for d in data['value']: | |
print (d['joke']) |