A Pen by Jothin kumar on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
if [ -d "build" ] | |
then | |
cd build | |
git pull | |
cd ../ | |
else | |
git clone https://github.com/Jothin-kumar/build.git | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import factorial | |
def word_rank(word: str) -> int: | |
rank = 1 | |
L = len(word) | |
for i, l in enumerate(word): | |
k = 0 | |
for r in word[i+1:]: | |
if r < l: | |
k += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_letters(name): | |
letters = [] | |
for letter in name.lower(): | |
if letter.isalpha(): | |
letters.append(letter) | |
return letters | |
name1_letters = get_letters(input("Enter name 1: ")) | |
name2_letters = get_letters(input("Enter name 2: ")) | |
# cancel common letters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rows_count = int(input("Enter no.of rows to display: ")) # (first row is not counted) | |
result = [[1]] | |
for i in range(rows_count): | |
r = [1, 1] | |
prev = result[-1] | |
for i in range(len(prev)-1): | |
r.insert(i+1, prev[i] + prev[i+1]) | |
result.append(r) |