This file contains hidden or 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 hashed_table | |
| hashed_data_table = Array.new(4) | |
| hashed_data_table[0] = ["Number", "Name", "Position", "Points per Game"] | |
| hashed_data_table[1] = ["12", "Joe Schmo", "Center", "[14, 32, 7, 0, 23]"] | |
| hashed_data_table[2] = ["9", "Ms. Buckets", "Point Guard", "[19, 0, 11, 22, 0]"] | |
| hashed_data_table[3] = ["31", "Harvey Kay", "Shooting Guard", "[0, 30, 16, 0, 25]"] | |
| hashed_data_table[4] = ["18", "Sally Talls", "Power Forward", "[18, 29, 26, 31, 19]"] | |
| hashed_data_table[5] = ["22", "MK DiBoux", "Small Forward", "[11, 0, 23, 17, 0]"] | |
| index = 1 | |
| player_info = [] |
This file contains hidden or 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 birthday_timestamp(date) | |
| date = date.split('/') | |
| month, day, year = date.pop(3) | |
| birthday = Time.mktime(year, month, day) | |
| time_now = Time.now | |
| years = time_now.year - birthday.year | |
| months = time_now.month - birthday.month | |
| days = time_now.day - birthday.day | |
| puts "#{years} years #{-months} months #{-days} day old" if days < 2 | |
| puts "#{years} years #{months} months #{days} days old" if days > 2 |
This file contains hidden or 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 print_and_sort(array) | |
| output_string = "" | |
| array.map!(&:to_s).each do |element| | |
| output_string = output_string + " " + element | |
| end | |
| puts output_string | |
| array.sort | |
| end |
This file contains hidden or 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 print_and_sort(array) | |
| output_string = "" | |
| array = array.map! {|str| str.to_s } | |
| array.each do |element| | |
| output_string = output_string + " " + element | |
| end | |
| puts output_string | |
| array.sort | |
| end |
This file contains hidden or 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 deaf_grandma | |
| returns = 0 | |
| until returns == 2 | |
| print "Say something to grandma: " | |
| response = gets.chomp | |
| if response.empty? | |
| returns += 1 | |
| elsif response.match(/[A-Z]/) | |
| puts "NO, NOT SINCE 1938!" | |
| else |
This file contains hidden or 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! |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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"); |