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
//Alessandro Stamatto, Advent of Code Day 19: http://adventofcode.com/2017/day/19 | |
//Mini-visualization at: https://www.youtube.com/watch?v=MhhD_BJ6sDs | |
import { readFileSync } from "fs" | |
import { setTimeout } from "timers" | |
const print = console.log.bind(console) | |
const abs = Math.abs.bind(Math), | |
min = Math.min.bind(Math), | |
max = Math.max.bind(Math) |
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
#include <string> | |
using namespace std; | |
//usando uma matriz de caracteres para representar o labirinto | |
//'p' = parede, 's' = saida, 'v' = visitado | |
void caminhar(Grafo, linha, coluna, percursoAtual) { | |
percursoAtual = "(" + to_string(linha) + "," + to_string(coluna) + ")"; //adicionamos o quadrado atual ao percursoAtual | |
if (Grafo[linha][coluna]=='s') { //se estamos no quadrado de término (saída), acabou: sucesso! |
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
from pathlib import Path | |
Matriz = [[int(c) for c in linha.split()] for linha in Path("arquivo.txt").read_text()] |
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
char linha[255]; | |
int matriz[i][j]; | |
for(int i = 0; i < nLinhas; ++i) { | |
fgets(linha, sizeof(linha), arquivo); | |
for(int j = 0; j < nColunas; ++j) { | |
sscanf(linha, " %d", &matriz[i][j]); | |
} | |
} |
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
string linha; | |
int matriz[nLinhas][nColunas]; | |
for(int i = 0; i < nLinhas; ++i) { | |
getline(arquivo, linha); | |
istringstream fluxo(linha); | |
for(int j = 0; j < nColunas; ++j) { | |
fluxo >> matriz[i][j]; | |
} | |
} |
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
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <sstream> //stringstreams | |
using namespace std; | |
int main() { | |
string linha; //variável para onde leremos cada linha |
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
#include <iostream> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
int main() { | |
string linha; //variável para onde leremos cada linha |
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
from hashlib import md5 | |
inp = "wtnhxymk" | |
#inp = "abc" | |
def parte1(): | |
i, index, psw = 0, 0, [] | |
while i < 8: | |
md = md5((inp + str(index)).encode("utf-8")).hexdigest() | |
if md.startswith("00000"): |
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
//linha 22 | |
int contar(map<int, arvore*>::iterator it); //faltou mudar a assinatura lá em cima | |
//linha 72 | |
cont = contar(mapa.find((*aux)->chave)); //Em C++ iterators são ponteiros, você precisa seguir o iterator/ponteiro, | |
// aí cai em um ponteiro para árvore, e segue de novo com a setinha |
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
for (i = 0; i < emprestimos.length; i++) { | |
if (emprestimos[i] != null && associado.getCodigo() == emprestimos[i].getAssociado().getCodigo()) { | |
lista += i + " - " + emprestimos[i].getLivro().getTitulo() + "\n"; | |
} | |
} |
NewerOlder