Skip to content

Instantly share code, notes, and snippets.

@barnes7td
Created August 15, 2013 00:14
Show Gist options
  • Save barnes7td/6237102 to your computer and use it in GitHub Desktop.
Save barnes7td/6237102 to your computer and use it in GitHub Desktop.
Indyrb Golf Problem 2
# 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