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 / desafio.js
Last active August 4, 2019 03:23
Dado o array de dictionary abaixo some o total dos valores (https://gist.github.com/anabastos/fbdfef7fcc64105e76e5e26218ebf7e6)
const
composeN = (...fs) => x =>
fs.reduceRight((x, f) => f(x), x)
, map = f => xs =>
xs.map(f)
, reduce = f => xs =>
xs.reduce(f)
@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 / ascend.js
Last active March 18, 2017 23:46
Given an index `n` and an array, return a new array with the nth value on the head
const clamp = l => h => x =>
x > h
? h
: x < l
? l
: x
const
ascend = i => xs => {
let
@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 / matrix-multiplication.js
Last active March 18, 2017 14:23
Multiply two matrices
const
id = x =>
x
, always = x => () =>
x
, not = prop =>
!prop
@lubien
lubien / help.md
Last active March 28, 2017 21:33
Sum a dimension N square matrix main and anti diagonal values

Sum a dimension N square matrix main and anti diagonal values.

Given the Matrix:

[ [ 1,  2,  3,  4]
, [ 5,  6,  7,  8]
, [ 9, 10, 11, 12]
, [13, 14, 15, 16]
]
@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.