Skip to content

Instantly share code, notes, and snippets.

Avatar
😭
Sad and Brazilian

Ana Luiza Portello Bastos anabastos

😭
Sad and Brazilian
View GitHub Profile
@anabastos
anabastos / fermat.c
Last active Oct 2, 2016
Desafio Fermat
View fermat.c
#include <stdio.h>
int ehPrimo(long number) {
int i;
for (i=2; i<number; i++) {
if (number % i == 0 && i != number) return 0;
}
return 1;
}
View gist:ae9f7c34cb1e1c5f9f2f
piramid = map(lambda n: "/n".join([" "*(n-i-1)+"."+" ."*i for i in range(n) if n>1]))
def piradimidinha_rec(n):
if n < 1 return ["."]
map(lambda piramid2: piramid1(n-1)+" .")
return " "*n-1+"*"+
n= input("Numero de linhas: ")
if n>1:
View triangulinho.py
n= input("Numero de linhas: ")
if n>1:
for i in range(n):
n-=1
print " "*n+"."+" ."*i
else:
print(".")
@anabastos
anabastos / fermatgoto.c
Created Oct 3, 2016
Fermat usando goto q fico horrivel
View fermatgoto.c
#include <stdio.h>
int main () {
long n, pPrimo, qPrimo, p, q, e, x, y;
int i, j;
printf ("-----------");
printf ("\nF e R m A t");
printf ("\n-----------");
printf ("\nDigite um numero impar: "); scanf ("%ld", &n);
@anabastos
anabastos / gist:b98af2fd2cc881d14349faff7f4ec100
Last active Jan 22, 2017
Como instalar o ambiente do projeto no UBUNTU
View gist:b98af2fd2cc881d14349faff7f4ec100
Copie e cole esses comandos no terminal
Instalar python e pip(instalador do python):
sudo apt-get install python
sudo apt-get install python-pip
Instalar o banco de dados mongo:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get install -y mongodb-org
View Atv TDD
Entrar no repositorio do github e clicar no botao de fork. Isso vai criar um repositorio igual pra sua conta
Entrar nesse seu repositorio e clona-lo
git clone (link)
cd furlong
Instalações:
sudo apt-get install ruby
gem install rspec -v 3.4.0
Digite no terminal para rodar os testes
View desafio.js
//dado o array de dictionary abaixo some o total dos valores
let dictionary = [{ '5': 50, '6': 60 }, { 'A': 10 }, { 'YEEZY': 30 }]
dictionary.reduce((acc, val) => acc.concat(Object.values(val)), []).reduce((acc, val) => acc + val, 0)
View show-me.js
/**
* Show Me the Evens - Show me the Odds
* Diana is learning to count and she just learned the difference between odds and even numbers.
* She wants to have some fun, so she picks a random number.
* If that number is even, she decides to count all the even numbers up to it starting from 0 up to (but not including) the input.
* If not, she decides to count all the odd numbers up to that number starting from 1 (but not including) the input.
**/
const counting = (x) => {
return arrayFrom(x)
View Tabuada.java
class Tabuada {
private int row;
public Tabuada(int numero) {
this.numero = numero;
System.out.println("Tabuada do : " + this.numero);
}
void report(int multiplicador) {
public static int multiplicacao = numero * multiplicador
@anabastos
anabastos / reducedString.js
Created Jul 21, 2017
super reduced string
View reducedString.js
// versao one line
const str = 'aaabccddd'
str.split('').reduce((acc, res) => res == acc.slice(-1)[0] ? acc.slice(0, -1) : acc.concat(res), []).join('') || 'Empty String' //'abd'
//versao composed
const lastItem = arr => arr.slice(-1)[0]
const removeLast = arr => arr.slice(0, -1)
const reduceArray = arr => {
return arr.reduce((acc, res) => res == lastItem(acc) ? removeLast(acc) : acc.concat(res), [])