Skip to content

Instantly share code, notes, and snippets.

View lrlucena's full-sized avatar
🦐
Working on Potigol Language (potigol.github.io)

Leonardo Lucena lrlucena

🦐
Working on Potigol Language (potigol.github.io)
View GitHub Profile
//------------ GENERATOR ------------------
def fill(px: Int, py: Int)(word: String): Unit = {
var (x, y) = ind(px, py)(word)
for ((c, i) <- word.zipWithIndex) {
matrix(x + px * i)(y + py * i) = c
}
}
def ind(px: Int, py: Int)(word: String): (Int, Int) = {
class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
String s = "abc";
StringBuilder sb = new StringBuilder("`");
for(char c: s.toCharArray()){
sb.append(String.format("\\u%04X", (int)c));
}
sb.append('`');
System.out.println(sb.toString());
Empty file
import java.io.IOException;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
public class Principal {
private static ParseTree parse(String programa) {
@lrlucena
lrlucena / maior_menor.py
Created April 2, 2018 11:59
Aulas While
import random
numero = random.randint(1, 100)
print("Escolhi um numero entre 1 e 1000.")
print("Tente descobrir.")
palpite = int(input("Qual o seu palpite?"))
contador = 1
while palpite != numero:
@lrlucena
lrlucena / entrada.py
Last active April 9, 2018 11:20
Aula 09/04/2018
# Listas
# Lista literal
lista = list(map(int, input("Digite os numeros:").split()))
maior = lista[0]
menor = lista[0]
soma = 0
for x in lista:
print(x)
if x > maior:
# Append
#a = [1, 2, 4, 8]
#a.append(16)
#print(a) #[1, 2, 4, 8, 16]
#b = []
#for i in range(10):
# x = int(input())
# b.append(x)
@lrlucena
lrlucena / fatorial.py
Last active May 2, 2018 11:21
Funções
def fatorial(n):
resultado = 1
for i in range(2, n+1):
resultado = resultado * i
return resultado
a = int(input("Digite um número"))
print("O fatorial de", a, "é", fatorial(a))
M = input()
M1, M2, M3 = int(M[-3]),int(M[-2]),int(M[-1])
M1M3=M1*10+M3
M1M2=M1*10+M2
M2M3=M2*10+M3
M2M1=M2*10+M1
M3M1=M3*10+M1
M3M2=M3*10+M2
print(M1, M2, M3)
tentativa(palpites: Lista[Inteiro], número: Inteiro, saida: Lista[Texto]): Lista[Texto]
palpite = palpites.cabeça
se palpite <> número então
resp = se palpite < número então
"O número é maior do que {palpite}."
senão
"O número é menor do que {palpite}."
fim
tentativa(palpites.cauda, número, saida + [resp])
senão