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 mode(array) | |
array.drop_while {|x| array.count(x) < array.count(x + 1) }.select {|x| array.count(x) > 1}.uniq | |
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 count_between(array, lower_bound, upper_count) | |
times = [] | |
until array.size == 0 | |
check_num = array.pop | |
if check_num.between?(lower_bound, upper_count) | |
times « check_num | |
end | |
end | |
times.length | |
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 median(array) | |
sorted_array = array.sort | |
if array.length % 2 != 0 | |
index = sorted_array.length / 2 | |
median = sorted_array[index] | |
else | |
index = sorted_array.length / 2 | |
median = (sorted_array[index].to_f + sorted_array[index-1].to_f) / 2 | |
end | |
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
<html> | |
<head> | |
<title>RPN Calculator</title> | |
<style type="text/css"> | |
body { | |
color: white; | |
background-color: blue; | |
font-weight: bold; | |
font-size: 24px; | |
text-align: center; |
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
<html> | |
<head> | |
<title>Leap Year in JavaScript</title> | |
<style type="text/css"> | |
* { margin: 0 auto; width: 960px; background-color: blue; } | |
#text_where { | |
color: white; | |
font-weight: bold; | |
text-align: center; | |
font-size: 40px; |
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
$name = function($name) { | |
echo "Hello $name"; | |
} | |
$name("A name"); |
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
Script: Covert sentences | |
Get a sentence from user input. | |
If the sentence length is greater than 20, randomize the sentence | |
Else take the 2nd letter of each word and change it to the letter P | |
ENDIF | |
PRINT the new sentence |
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
Script: CONVERT EVERY OTHER LETTER OF A SENTENCE TO CAPITAL LETTERS | |
GET a sentence from user input | |
IF the word starts with a capital letter, don't change it | |
ELSE convert every other letter to capital letters | |
ENDIF | |
PRINT the formatted sentence | |
def new_pseudo | |
sentence = gets.chomp |
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 primes(input) | |
primes = [] | |
number = 2 | |
(number..input).each do | |
if input % number == 0 | |
primes << number | |
input /= number | |
else | |
number += 1 | |
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
# Put your answers here! |
OlderNewer