Skip to content

Instantly share code, notes, and snippets.

View tomanistor's full-sized avatar
💻
Learning

Toma Nistor tomanistor

💻
Learning
View GitHub Profile
@tomanistor
tomanistor / problem.md
Last active September 20, 2024 09:24
Tribonacci Sequence

Well met with Fibonacci bigger brother, AKA Tribonacci.

As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to generate the next. And, worse part of it, regrettably I won't get to hear non-native Italian speakers trying to pronounce it :(

So, if we are to start our Tribonacci sequence with [1,1,1] as a starting input (AKA signature), we have this sequence:

[1,1,1,3,5,9,17,31,...]

But what if we started with [0,0,1] as a signature? As starting with [0,1] instead of [1,1] basically shifts the common Fibonacci sequence by once place, you may be tempted to think that we would get the same sequence shifted by 2 places, but that is not the case and we would get:

@tomanistor
tomanistor / problem.md
Last active January 17, 2024 23:53
Multi-tap Keypad Text Entry on an Old Mobile Phone

Prior to having fancy iPhones, teenagers would wear out their thumbs sending SMS messages on candybar-shaped feature phones with 3x4 numeric keypads.

------- ------- -------
|     | | ABC | | DEF |
|  1  | |  2  | |  3  |
------- ------- -------
------- ------- -------
| GHI | | JKL | | MNO |
| 4 | | 5 | | 6 |
@tomanistor
tomanistor / problem.md
Created June 22, 2017 17:38
Sum of Digits / Digital Root

In this kata, you must create a digital root function.

A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has two digits, continue reducing in this way until a single-digit number is produced. This is only applicable to the natural numbers.

Here's how it works (Ruby example given):

digital_root(16)
=> 1 + 6
=> 7
@tomanistor
tomanistor / problem.md
Created June 22, 2017 17:40
Find the missing letter

Find the missing letter

Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array.

You will always get an valid array. And it will be always exactly one letter be missing. The length of the array will always be at least 2. The array will always contain letters in only one case.

Example:

@tomanistor
tomanistor / .bash_aliases
Created September 20, 2021 16:48
Git alias to prune all merged branches
alias git-prune='git branch --merged | grep -v "\*" | grep -Ev "(\*|production|master|staging|development)" | xargs -n 1 git branch -d'
@tomanistor
tomanistor / package.json
Created August 21, 2020 22:55 — forked from mallendeo/package.json
Record gsap animations frame by frame with puppeteer
{
"name": "gsap-to-video",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"fs-extra": "^7.0.0",
"puppeteer": "^1.7.0"
}
}
@tomanistor
tomanistor / problem.md
Created June 22, 2017 17:41
Format a string of names like 'Bart, Lisa & Maggie'.

Given: an array containing hashes of names

Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.

Example:

list([ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Maggie'} ])
# returns 'Bart, Lisa & Maggie'
@tomanistor
tomanistor / README
Last active August 5, 2019 20:50
Remove files and folders mentioned in .gitignore
git ls-files --ignored --exclude-standard -z | xargs -0 git rm --cached
@tomanistor
tomanistor / .eslintrc.json
Created March 1, 2019 19:28
ESLint Config
{
"extends": "standard",
"parserOptions": {
"ecmaVersion": 5
},
"rules": {
"indent": ["error", 2, {
"ArrayExpression": 1,
"ObjectExpression": 1,
"VariableDeclarator": { "var": 2, "let": 2, "const": 3 }
@tomanistor
tomanistor / .csscomb.json
Last active April 16, 2018 19:35
CSS Style Guide
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "upper",
"block-indent": " ",
"color-shorthand": true,
"element-case": "lower",
"eof-newline": true,
"leading-zero": false,
"quotes": "double",