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
gem install sqlite3 | |
ERROR: Could not find a valid gem 'sqlite3' (>=0), here is why: | |
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/specs.4.8.gz) |
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 twosum nums | |
idx = 0 | |
idx2 = idx + 1 | |
while idx < nums.length | |
n = nums[idx] | |
i = nums[idx2] | |
sum = n + i | |
if sum == 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 threesum | |
end |
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 rev(str) | |
a = 0 | |
reverse = "" | |
while a < str.length | |
reverse = str[a] + reverse | |
a += 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 cap(str) | |
words = str.split(" ") | |
idx = 0 | |
while idx < words.length | |
word = words[idx] | |
word[0] = word[0].upcase # change the word within array | |
idx += 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 common(str) | |
most = nil | |
mcount = nil | |
idx1 = 0 | |
while idx1 < str.length | |
char = str[idx1] | |
count = 0 | |
idx2 = 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 skipMultiples | |
i = 0 | |
range = (2...50).to_a | |
while i < range.length | |
if range[i] % 7 != 0 | |
puts range[i] | |
else | |
range[i] = "Love conquers all!" | |
puts range[i] |
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 word_unscrambler(str, words) | |
idx = 0 | |
matches = [] | |
while idx < words.length | |
sorted = words[idx].chars.sort.join | |
match = str.chars.sort.join | |
word = words[idx] | |
if sorted == match |
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 sums = function(num) { | |
myNum = 0; | |
for (var i = 0; i <= num; i++) { | |
myNum += i; | |
} | |
console.log(myNum); | |
} | |
sums(3); |
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 longestWord = function(myString) { | |
words = myString.split(" "); | |
longest = ""; | |
for (var word = 0; word < words.length ; word++) { | |
if (words[word].length > longest.length) { | |
longest = words[word] | |
} | |
} | |
return longest; |
OlderNewer