-
Given the array ["pizza", "cheese", "steak"] Use .each to print out each word capitalized.
-
Given the array [1,2,3,4,5], use .each to create an array of each number doubled.
-
Given the array ["apple", "pie", "ice cream"], use .each to determine which string is the longest.
-
Given the array [1,2,3,4,5], use .each to give us an array consisting of only even numbers.
def validator(card) | |
card.chars | |
.map { |n| n.to_i } | |
.map.with_index { |n, index| index.even? ? n * 2 : n } | |
.map { |n| n.to_s.length == 2 ? n.to_s[0].to_i + n.to_s[1].to_i : n } | |
.reduce(:+) % 10 == 0 ? "Valid" : "Invalid" | |
end |
class Centaur | |
attr_reader :name, | |
:breed | |
def initialize(name, breed) | |
@name = name | |
@breed = breed | |
@actions = 0 | |
@standing = true | |
end |
1. Check to see if application is registered | |
2. Check to see if payload is present | |
3. Check to see if request is a duplicate one. | |
4. Sanitize payload | |
5. Insert payload into database. |
Get all requests that match :identifier | |
get matching user_agent_ids | |
get matching user_agent | |
os = user_agent.split(' ')[1] | |
count requests that match os | |
create hash {os => count } | |
display os[1..-2] + count |
Public Key Cryptography | |
The Problem: How do we communicate securely on the internet? | |
- We have to encrypt our communications. | |
- How do two parties who have never met, agree on a key when all of their communications are public? | |
- The answer: Diffie Hellman Key Exchange. -Whitfield Diffie, Martin Hellman | |
- The first implementation of public key cryptography as envisioned by Ralph Merkle. | |
The Setup: | |
- Alice wants to Talk to Bob. |
During online gaming (or any video game that requires teamwork) , there is often times that you need to speak to your teammates. Given the nature of the game, it may be inconvenient to say full sentences and it's for this reason that a lot of games have acronyms in place of sentences that are regularly said.
gg : expands to 'Good Game' brb : expands to 'be right back' and so on... This is even evident on IRC's and other chat systems. However, all this abbreviated text can be confusing and intimidating for someone new to a game. They're not going to instantly know what 'gl hf all'(good luck have fun all) means. It is with this problem that you come in.
ISBN's (International Standard Book Numbers) are identifiers for books. Given the correct sequence of digits, one book can be identified out of millions of others thanks to this ISBN. But when is an ISBN not just a random slurry of digits? That's for you to find out.
Given the following constraints of the ISBN number, you should write a function that can return True if a number is a valid ISBN and False otherwise. An ISBN is a ten digit code which identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct. To verify an ISBN you :- obtain the sum of 10 times the first digit, 9 times the second digit, 8 times the third digit... all the way till you add 1 times the last digit. If the sum leaves no remainder when divided by 11 the code is a valid ISBN. For example : 0-7475-3269-9 is Valid because
class Phoenix | |
attr_reader :name, :age, :lives, :revives | |
def initialize(name, age=0) | |
@name = name | |
@age = age | |
@alive = true | |
@lives = 0 | |
@revives = 0 | |
end |