Ad
  • Custom User Avatar

    So the instructions don't mention anything about non-letter characters like full-stops being included in the test cases. Might be good to mention that since the directions seem to explicitly say otherwise.

  • Custom User Avatar

    Abishek21,
    elizabeth = (88 + len(elizabeth)) * 5 ==> 485;
    matthew = (90 + len(matthew)) * 5 ==> 485.

  • Custom User Avatar

    did get the answer for this one?

  • Custom User Avatar

    Ugly Kata

  • Custom User Avatar

    You should read the description once more.

  • Custom User Avatar

    I can't seem to pass the test case where Matthew and Elizabeth are supposed to evaluate to the same total value, and thus be sorted alphabetically.
    My issue here is that those two names don't amount to the same total value. I tore my logic apart and went through the hard way, matching chars up by their place value; I can't find a way where the two names would ever have the same value...
    I am operating under the assumption that both lowercase and uppercase letters are treated identically concerning value, as this appears to be made implicit through the examples given. (so "A" == 1 and "a" == 1, meaning that a downcased name is equivalent to the mixed case, or uppercase equivalent; so "Elizabeth" == "ELIZABETH" == "EliZabETh" etc etc)

    First, the letters and their associated values:
    alpha_value = {
    "a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5,
    "f"=>6, "g"=>7, "h"=>8, "i"=>9, "j"=>10,
    "k"=>11, "l"=>12, "m"=>13, "n"=>14, "o"=>15,
    "p"=>16, "q"=>17, "r"=>18, "s"=>19, "t"=>20,
    "u"=>21, "v"=>22, "w"=>23, "x"=>24, "y"=>25,
    "z"=>26}

    Elizabeth split into chars (downcased for ease) and valued out by char

    [["e", 5], ["l", 12], ["i", 9], ["z", 26], ["a", 1], ["b", 2], ["e", 5], ["t", 20], ["h", 8]]

    sum of letters:

    5 + 12 + 9 + 26 + 1 + 2 + 5 + 20 + 8 == 88 # true

    Matthew split into chars (downcased for ease) and valued out by char

    [["m", 13], ["a", 1], ["t", 20], ["t", 20], ["h", 8], ["e", 5], ["w", 23]]

    sum of letters:

    13 + 1 + 20 + 20 + 8 + 5 + 23 == 90 #true

    Given the names and weights for the test case

    "Elijah,Chloe,Elizabeth,Matthew,Natalie,Jayden"
    [1, 3, 5, 5, 3, 6]

    I would reason this out to be:

    names_array = ["Elijah", "Chloe", "Elizabeth", "Matthew", "Natalie", "Jayden"]
    weights = [1, 3, 5, 5, 3, 6]

    Which would mean that the respective "weights" of each name in question is 5

    So based on the weights, and the totals of the characters, they come out to

    different values...

    elizabeth = 88 * 5 ==> 440

    matthew = 90 * 5 ==> 450

    Based on this step by step, I can't see where I might be going wrong with the calculation. They have different total values based on the characters in the names and the assigned weights. Why would "Elizabeth" not be ordered after "Matthew" in this context?

  • Custom User Avatar

    Poor instruction around negatives and "weird" test cases.