(Optional: “The dog ran into the shoe store.”)
hint for Ruby: hash[key] = value
5) Write a program that will take a year and report “true” if it is a leap year and “false” if it isn’t.
Leap years are divisible by 4, not divisible by 100 unless that year is also divisble by 400.
1)Write a program takes two DNA strands(strings) and calculates the difference of characters between the two.
A =“ACTBF”
B = “GCABA”
Should output 3 because there are 3 differences
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
[21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
[31, 32, 33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48, 49, 50],
[51, 52, 53, 54, 55, 56, 57, 58, 59, 60],
[61, 62, 63, 64, 65, 66, 67, 68, 69, 70],
[71, 72, 73, 74, 75, 76, 77, 78, 79, 80],
[81, 82, 83, 84, 85, 86, 87, 88, 89, 90],
[91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
that takes a sentence as a string as input,
and returns the frequency of each word in that sentence as a hash,
whose key is the word
and whose value is the number of times that word appears in that sentence.
Here is the input:
“The quick brown fox jumped over the moon.
This mammal did not jump over the sun.
It jumped over the moon. And it was quick about it.”
The output should be:
{"the"=>4, "quick"=>2, "brown"=>1, "fox"=>1, "jumped"=>2, "over"=>3,
"moon"=>2, "this"=>1, "mammal"=>1, "did"=>1, "not"=>1, "jump"=>1,
"sun"=>1, "it"=>3, "and"=>1, "was"=>1, "about"=>1}
return a sorted array of all the unique numbers that can be formed with those digits.
ie, given 123, return [123, 132, 213, 231, 312, 321]
(can use to the permutation method)