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
// http://modularscale.com/scale/?px1=16&px2=12&ra1=1.618&ra2=0 | |
// == || MODULAR SCALE || == | |
$base-text-size: 1em | |
$important-number: 0.75em | |
$omicron: golden-ratio($base-text-size, 5) // 177.425 | |
$xi: golden-ratio($important-number, 5) // 133.066 |
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
// | |
// APIHandler.h | |
// Orakuru | |
// | |
// Created by Mitrmitri on 11/19/2557 BE. | |
// Copyright (c) 2557 Codemy. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import <AFNetworking/AFNetworking.h> |
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
var pancake = function pancake(inputArray) { | |
return inputArray.reduce(function (accumulation, value) { | |
if(Array.isArray(value)) { | |
return accumulation.concat(pancake(value)); | |
} else { | |
return accumulation.concat(value); | |
} | |
}, []); |
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 solution(N): | |
max_value = 2147483647 | |
min_value = 1 | |
if (N < min_value or N > max_value): | |
return 0 | |
binary = bin(N) | |
return find_gaps(list(binary)) | |
def find_gaps(binary_list, gaps=[]): | |
first_index = 0 |
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 solution(A): | |
result = 0 | |
for num in A: | |
result ^= num | |
return result |
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
# Naive approach - O(n) | |
def twoNumberSum(array, targetSum): | |
for num in array: | |
if num == 0: | |
return sorted([num, targetSum]) | |
if (num < targetSum): | |
diff = targetSum - num | |
if diff in array: | |
if array.index(diff) != array.index(num): | |
result = [num, diff] |
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
# O(n) time | O(n) space | |
def getNthFib(n): | |
memo = {1: 0, 2: 1} # start of with initial values in cache | |
if n in memo: | |
return memo[n] | |
else: | |
memo[n] = calcFib(n) # store result in cache | |
return memo[n] | |
# O(n) time | O(1) space |
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 binarySearch(array, target): | |
# Array has to be sorted in order to check surrounding elements | |
left = 0 | |
right = len(array) - 1 | |
while left <= right: | |
mid = (left + right) | |
guess = array[mid] | |
if guess == target: | |
return mid | |
if guess > target: |
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
# O(n) | |
def isPalindrome(string): | |
left = 0 | |
right = len(string) - 1 | |
while left < right: | |
if string[left] == string[right]: | |
left += 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 caesarCipherEncryptor(string, key): | |
alphabet = list("abcdefghijklmnopqrstuvwxyz") | |
tmp = "" | |
for char in string: | |
idx = (alphabet.index(char) + key) % len(alphabet) | |
tmp += alphabet[idx] | |
OlderNewer