Created
August 15, 2013 00:14
-
-
Save barnes7td/6237102 to your computer and use it in GitHub Desktop.
Indyrb Golf Problem 2
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 problem_2(s, t) | |
# a = 0; s.split.each_with_index { |c, i| a += 1 if t[i] != c }; a | |
# end | |
def problem_2(s, t) | |
(s.split("") & t.split("")).size | |
end | |
s = "AAABab" | |
t = "AAAAaa" | |
puts problem_2(s, t) | |
# require 'minitest/autorun' | |
# class ProblemTwoTest < MiniTest::Unit::TestCase | |
# def test_gets_it_right | |
# str1 = 'AGTTCAGAGACGGACTCTACGAGCATATTTGCTGTCTAATACTCTCAATGCCACGTTATTTATGTTTTACCAAGTTTCGGACTGGCGGATGCCGTCACATTCCCGGAACGTCCTGCAGATAATAAGCCGATGCAGAAGCTAGATCATTGATGTGACGGCAGGCATCAGTGTGGGCGACTGGGCTCCGCTGTTTACACCGAGATGGGATCGTTCCAGGACTGCTAAGACCTTCCCAGCTTGTGATCGAAAAAAGCAGCCTGACGCTACCCCAGGAGGAGCCCGTAGTGAGTCGAGCGCCAATTACTTGTTCTATAGAAATTGTAAGTGCTGTTAGCATGAATAACGCGTAGCCAGGAGGTTTTAAGATTAAAGTGCTTCATCCCCATTTATATACAGTCGACAAGTAGCCTTACGCGGATTCTCGGAGATGTTGGCGGTTTAATCGACTGGAAACCAGGAAAAGTTGTATGAGTGGTAACATGCTGGCTGAATCTAGGACGGTCTGGCACGTCCCCTGGGACCTTACGATGGGTGCGGTTCAATCTGTCATCGCGTCTCTACGCTGATGCCGCGAGAGCAAGAAGAACGACCCTAGCCCCGCGGATGTCCAGAGGGAATCGTTCCAGCGTGGCAACGTTAACCTACATTCCACAGAAGTTGAGTTAGATAGCGAATACCGGTGATTTACCCGAAGCAGTACTACTGTACTGACCGTGACGCTTGCGCATCAAGGCTCGAAAGTTGGCTATTGAGAAGTGCTCTCACATCCAGCAAACAGCTTTCAAGCATCCCGTATGCGGCCGTCGACGAATCCATCAAGATCCGAAGGGCTATGTTTCTGAAGGTGTCGCTCTGCATGATCCGAACAACCCCTGTACAGTCCCCTAGCGAAAGGTGATCACTTAGTAGGACTAAT' | |
# str2 = 'TGACGGCAGAAGGAAACTACGAGGTAATTGGTAGAAGGGACCTGGCAAAACACTGTACTTGCGTGTTTAGGAAGTGTCCGACAGTCGAGAAACGTCAGGTACTGCTAACGTCAAGCCGCCATCTAATAGATGTCTGATTTTTCTCATAATACACACTGCCGCCAGTATCGCGGTGGTTAGGCGCTCCCGTCATAAACCGGGACCTGCCGGGCTATGACCAGCGCAGTCCCGACCCGGACGTGCTGAATACCCGCACAAATTTTGGTCTCGTGTTAGAGTCCACAGTGAGTGTTTACTCAAAGACTAGCTCTGGGTCCCGTACCTGTGCAGTTGAAAGGTATCGTGTGGAGCCTTTAGTTCTTAAGCCGATTGGTTCCCCACCACAGTCATTTCCAGGTGATCAGCAGACTCACGTTGGTGTTATGTAAGCTACGCACATTCAGCCAATGGAACCCACGTATTTTAGGACTAGGGGCTATATGGTACCTTGCACGGCGACCGTTAGAGAGGACATCCCTGCCATTTGCCTTAATTCTCAACGAGCGGTTATTGAGGAGCGACGCGTAAGCCTAAAGAGTGGGAGAAGTTCCTCGAGCTCCGCGCAACGCGACTGTAAGTCCCTCGAAAGTGGCTAACTCAACTATGGTTCCGCGCTACTGGAGATGTATACAAAACACACGAGAAACCTCCGAAGCAGGGATTCATTTCTGATTTTGACGCTTACGCCTGCGTCCATGGTAGCTTTATTTGCGCACGTTGGCTCGCTGCCTAGTAGAACCTTACAAGCAGAGCGTGCGCGGAGGGAGACAAATACATGAAGACCCGGAATGAGCTCTTACTAGAATTCGCTACATCTGAGAAGCTCTCGAGTCTTGTATGTTTCCCGATGCAAGCCTTATCAGTCAGCAGGGCCCAG' | |
# result = problem_2(str1, str2) | |
# assert_equal 470, result | |
# end | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment