Skip to content

Instantly share code, notes, and snippets.

View lubien's full-sized avatar
💭
Teaching people 🔥🦩 LiveView 🔥🦩

Lubien lubien

💭
Teaching people 🔥🦩 LiveView 🔥🦩
View GitHub Profile
@lubien
lubien / show-me.js
Last active March 14, 2017 17:26 — forked from ronaiza-cardoso/show-me.js
Show Me the Evens - Show me the Odds
/**
* 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
range = x => y =>
@lubien
lubien / show-me.js
Last active March 14, 2017 04:30 — forked from anabastos/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.
**/
function counting(x){
return [...Array(x).keys()]
@lubien
lubien / primeNumbers.js
Last active March 14, 2017 19:40 — forked from Woodsphreaker/primeNumbers.js
Dado um número aleatório, retornar todos os números PRIMOS entre 0 e o número escolhido
const
range = x => y =>
Array.from({length: y - x})
.map((_, i) => x + i)
, {ceil, sqrt} = Math
, lt = y => x =>
x < y
@lubien
lubien / negative-number-matrix.js
Last active March 21, 2017 00:09 — forked from ronaiza-cardoso/negative-number-matrix.js
Count Negative Integers in Matrix
const
composeN = (...fs) => y =>
fs.reduceRight((x, f) => f(x), y)
, flatten = xs =>
xs.reduce((acc, x) => acc.concat(x))
, filter = pred => xs =>
xs.filter(pred)
@lubien
lubien / operators.js
Last active March 16, 2017 20:03 — forked from Woodsphreaker/operators.js
Basic Operators Challenge
const
composeN = (...fs) => y =>
fs.reduceRight((x, f) => f(x), y)
, concat = ys => xs =>
xs.concat(ys)
, flatten = xs =>
reduce(uncurry2(concat))(xs)
@lubien
lubien / help.md
Last active March 30, 2017 01:27 — forked from beatorizu/obmep.js
OBMEP 2015 - 2ª Fase - Data - https://www.youtube.com/watch?v=XxceY97NjEU
  1. Think in a two-digit number.
  2. Subtract by it's digits sum. Ex.: 13 - (1 + 3).
  3. Sum it's digits. Ex.: 13 => 1 + 3.
  4. Sum by 4.
  5. Multiply by it's reversed digits number. Ex.: 31 * 13.
  6. Multiply by 3.
  7. Should be equal 1209.
  • Pense em qualquer número de DOIS dígitos, por exemplo 47

  • Subtraia a soma dos algarismos. Ex.: 47 - (4 + 7) = 36

  • Depois some os algarismos resultantes da subtração anterior, adicionando 4. Ex.: 3 + 6 + 4 = 13

  • Multiplique o resultado pelo inverso do número. Ex.: 13 x 31 = 403

  • E por último, multiplique por 3 o resultado anterior. Ex. 403 x 3 = 1209

  • Obs.: Qualquer número de 2 algarismos (entre 10 e 99) terão o mesmo resultado.

  • Não acredita ? Faça o teste !!!!

crie uma função chamada MaiorPalavra(str) que recebe um parâmetro do tipo string e retorna a maior palavra.
tenha como casos de entrada os exemplos abaixo:
"Olá mundo"
"Letra após letra"
"uma confusa /:cadeia de caracteres:/[ isso não é!!!!!!!~"
"uma bonita sequência^&"
@lubien
lubien / excercicio.txt
Last active March 27, 2017 18:34 — forked from rafaelassumpcao/excercicio.txt
Exercicio - transformar string
Transformar uma string em outra na qual cada letra do alfabeto deve ser a proxima mantendo o resto igual. ex: a -> b, z -> a, f -> g.
Após a transformação gerar uma nova string onde toda vogal deve ser maiúscula.
exemplos:
Input:"hello*3"
Output:"Ifmmp*3"
Input:"fun times!"
@lubien
lubien / info.md
Last active March 30, 2017 03:57 — forked from Woodsphreaker/info.md

Recuperar todos os números de um array

Recupera todos arrays e retorna somente um com o valores.

No primeiro método há uma recursividade.

No segundo método, uma conversão para string, split e finalmente converte para um array final de números

Acho que pode ser útil também.