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
@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))
# 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 / 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:
@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:
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) {
Empty file
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());
//------------ 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) = {
@lrlucena
lrlucena / d3.poti
Created November 3, 2017 19:40
Desafio 03 - Os Programadores
# Usando a linguagem Potigol: potigol.github.io
palindromos(min, max: Inteiro) =
para i de min até max se i.texto == i.texto.inverta gere i fim
testes = [(0, 20), (3000, 3010), (0, 1000), (1000, 2000), (2000, 3000)]
para teste em testes faça
min, max = teste.primeiro, teste.segundo
escreva "{min} - {max}: {palindromos(min, max).junte(", ")}
|=========="
@lrlucena
lrlucena / texto1.poti
Last active October 19, 2017 19:00
Aula Texto
# Texto
a = "IFRN"
b = "TADS"
c = a + b # "IFRNTADS"
d = a * 2 # "IFRNIFRN"
x = 10
escreva "Alagoas {x}."