Consider the keybase command line program.
# look me up
Consider the keybase command line program.
# look me up
-- 1. What are the top 50 worst rated movies? The results should | |
-- include the movie title and rating and be sorted by the worst | |
-- rating first. | |
SELECT title as movie_title, rating | |
FROM movies | |
ORDER BY rating | |
LIMIT 50; | |
-- movie_title | rating |
def dictionary_sort arr | |
rec_dict_sort arr, [] | |
end | |
def rec_dict_sort unsorted, sorted | |
if unsorted.length <= 0 | |
return sorted | |
end | |
smallest = unsorted.pop | |
still_unsorted = [] |
def shuffle arr | |
shuf = [] | |
while arr.length > 0 | |
rand_index = rand(arr.length) | |
curr_index = 0 | |
new_arr = [] | |
arr. each do |item| | |
if curr_index == rand_index | |
shuf.push item |
def sort arr | |
rec_sort arr, [] | |
end | |
def rec_sort unsorted, sorted | |
if unsorted.length <= 0 | |
return sorted | |
end | |
smallest = unsorted.pop | |
still_unsorted = [] |
def | |
thous = (num /1000) | |
hunds = (num % 1000/ 100) | |
tens = (num % 100 / 10) | |
ones = (num % 10 ) | |
roman = 'M' * thous | |
if hunds == 9 | |
roman = roman + 'CM' | |
elsif hunds == 4 |
def old_roman_numeral num | |
roman = '' | |
roman = roman + 'M' * (num /1000) | |
roman = roman + 'D' * (num % 1000/ 500) | |
roman = roman + 'C' * (num % 500/ 100) | |
roman = roman + 'L' * (num % 100/ 50) | |
roman = roman + 'X' * (num % 50/ 10) | |
roman = roman + 'V' * (num % 10/ 5) | |
roman = roman + 'I' * (num % 5/ 1) |
def ask question | |
while | |
puts question | |
reply = gets.chomp.downcase | |
if reply == yes | |
return true | |
end | |
if reply == no | |
return false | |
end |
title= 'Table of Contents' | |
chapters= [['Unoriginal Title', 1],['Less Unoriginal Title', 10],['Least Unoriginal Title', 25]] | |
puts title.center(100) | |
puts | |
chapter_num=1 | |
chapters.each do |chap| |
array= [] | |
puts 'Type as many words as you want. When you\'re done press enter' | |
while true | |
word= gets.chomp | |
array.push word.downcase | |
if word == '' | |
break | |
end | |
end | |
puts array.sort |