A list of postcodes from an unnamed county appears on Santa's desk. Apparently, there is a clue in each postcode that allows Santa to deliver gifts in the most efficient way, without this, he'll be late home for his Christmas dinner.
The postcodes contain a letter and two numbers. If the letter is in the first half of the alphabet then you must gather the number found in the next location (or index) and add it to the total. If the number is in the second half of the alphabet you must gather the number found in the previous location (or index) and subtract this from the total.
If your final value is negative, just make this the positive version of itself!
Be careful, some of the elves turned off caps lock when entering some of the postcodes!
Iterate through the post codes. Consider the initial letter (ignoring case):
if this letter is in the first half of the alphabet (A-M), look at the next index and add the numbers found here to a total
if the letter found is in the second half of the alphabet (N-Z), look at the previous index and subtract the value found here from the total.
If the final answer is negative, turn it into its positive value.
exampleCodes = [ "A21" , "Z32" , "B24" , "Y10" ]
The first code shows A meaning we look to the index after --> Z32, we add 32 to a total
The next code shows Z meaning we look to the index behind --> A21, we subtract 21 from the total
The 3rd code shows B meaning we look to the index after --> Y10, we add 10 to the original total
The final code shows Y meaning we look to the index behind --> B19, we subtract 24 from the total
Final total = -3
Made positive = 3
postcodes=['A26', 'G32', 'C66', 'T53', 'J62', 'Y60', 'F19', 'K33', 'Q95', 'K58', 'P92', 'N47', 'S10', 'S23', 'X81', 'J16', 'Z46', 'W59', 'P92', 'W71', 'C85', 'O93', 'N16', 'B64', 'J81', 'O95', 'H46', 'N57', 'K92', 'A41', 'F14', 'X76', 'X77', 'H97', 'F56', 'P50', 'V56', 'F69', 'T67', 'F95', 'p79', 'I46', 'G96', 'H99', 'Z88', 'Y26', 'M61', 'V51', 'U68', 'Z62', 'H11', 'U69', 'H94', 'J79', 'J23', 'Y44', 'V88', 'N16', 'C35', 'T78', 'R11', 'B58', 'N33', 'M75', 'S84', 'G65', 'B72', 'K59', 'Y72', 't57', 'I30', 'N30', 'V31', 'D99', 'I27', 'H23', 'L20', 'H59', 'I24', 'H26', 'L71', 'Z89', 'Z30', 'D20', 'D20', 'F83', 'Q33', 'Y31', 'Z74', 'E33', 'Z63', 'T93', 'W60', 'D77', 'K16', 'E19', 'Z73', 'G85', 'V19', 'C49', 'D77', 'S49', 'N75', 'S96', 'U15', 'W96', 'X26', 'T84', 'C44', 'J40', 'Y66', 'O82', 'O72', 'O90', 'A20', 'B72', 'Y56', 'S15', 'O35', 'L90', 'J39', 'Y75', 'E39', 'I14', 'B34', 'T66', 'I22', 'N19', 'Z88', 'N22', 'M69', 'V49', 'Q70', 'F99', 'B61', 'X71', 'I72', 'T42', 'x85', 'C42', 'F29', 'R64', 'L24', 'W66', 's42', 'Z84', 'N75', 'Q92', 'C94', 'N70', 'E78', 'K18', 'B68', 'Z32', 'Q90', 'K80', 'D83', 'I96', 'Y49', 'P85', 'N60', 'I37', 'L92', 'U22', 'Q25', 'L69', 'F66', 'T15', 'V44', 'A25', 'F88', 'R79', 'Y85', 'I82', 'V46', 'J69', 'M76', 'H36', 'W44', 'W37', 'F43', 'D85', 'U88', 'B10', 'M92', 'C87', 'D92', 'A67', 'U71', 'Z52', 'K39', 'V27', 'S73', 'Q55', 'T96', 'V89', 'J52', 'V49', 'E86', 'Z40', 'T23', 'A89', 'V35', 'J81', 'B61', 'Y50', 'S78', 'A57', 'G52', 'N29', 'S56', 'M52', 'H85', 'J69', 'O48', 'T11', 'D45', 'F87', 'A37', 'Q46', 'K58', 'R35', 'Q61', 'F74', 'S32', 'M69', 'C42', 'B81', 'F82', 'I97', 'C56', 'T69', 'D99', 'X43', 'N77', 'G73', 'X35', 'P16', 'N31', 'W60', 'O27', 'I88', 'I13', 'D87', 'D66', 'V70', 'Z14', 'K41', 'N74', 'L51', 'E36', 'A54', 'P41', 'U89', 'K76', 'C39', 'g19', 'C95', 'T68', 'B45', 'K64', 'C29', 'X95', 'F76', 'Z72', 'V12', 'I54', 'N54', 'J35', 'X60', 'K82', 'O94', 'P33', 'V35', 'A12', 'R97', 'W97', 'O58', 'G16', 'W58', 'T59', 'U93', 'L52', 'S42', 'C19', 'M96', 'T91', 'W78', 'J47', 'K18', 'U75', 'B89', 'U79', 'M46', 'R21', 'N68', 'H51', 'V55', 'Q76', 'E41', 'D44', 'L23', 'S70', 'T28', 'V83', 'X41', 'A70', 'G42', 'H91', 'H22', 'H27', 'B83', 'D88', 'W46', 'B69', 'J32', 'K83', 'G64', 'J53', 'V76', 'J21', 'B64', 'I99', 'A66', 'L34', 'B20', 'K39', 'B65', 'Z21', 'T49', 'I30', 'S53', 'W96', 'F10', 'R81', 'Y17', 'Z32', 'O63', 'X95', 'L49', 'N16', 'X88', 'E54', 'P45', 'O80', 'W15', 'J59', 'O66', 'Q98', 'H63', 'X55', 'S10', 'T83', 'Y94', 'X38', 'E46', 'W77', 'W14', 'V18', 'P66', 'K26', 'O40', 'J74', 'I73', 'J16', 'Y76', 'R68', 'L95', 'R72', 'X33', 'V94', 'W34', 'X13', 'S30', 'S25', 'H23', 'U17', 'Z96', 'H52', 'N77', 'Z16', 'D41', 'H68', 'E74', 'S95', 'H18', 'N74', 'J48', 'M61', 'I99', 'L24', 'W25', 'M24', 'W25', 'T72', 'Y55', 'P22', 'J65', 'J43', 'A42', 'H94', 'K23', 'H28', 'B25', 'A16', 'A16', 'T95', 'N98', 'G18', 'W35', 'F54', 'P83', 'Q43', 'F61', 'F87', 'Z39', 'H17', 'Z74', 'A22', 'W74', 'N92', 'S69', 'X64', 'B31', 'E49', 'M43', 'A17', 'O41', 'J78', 'O68', 'T23', 'W21', 'A25', 'Y24', 'B11', 'W38', 'F92', 'X92', 'K80', 'Q94', 'V34', 'V48', 'K18', 'H70', 'O80', 'N50', 'B64', 'C89', 'P12', 'P21', 'O37', 'F71', 'K28', 'Q72', 'N36', 'S95', 'G51', 'D14', 'Y30', 'F58', 'Z31', 'B58', 'P83', 'W85', 'X93', 'Z41', 'J38', 'T88', 'Z26', 'd99', 'Z11', 'I18', 'L30', 'M61', 'X45', 'I21', 'U92', 'Q78', 'H21', 'M16', 'O60', 'B21', 'B35', 'E97', 'F55', 'E22', 'A83', 'V87', 'M17', 'u29', 'D47', 'J82', 'N38', 'R54', 'T81', 'P54', 'X21', 'W86', 'K44', 'Z84', 'Z89', 'L22', 'A30', 'C62', 'G93', 'H31', 'I53', 'W33', 'K57', 'T23', 'L12', 'A24', 'V63', 'Z30', 'N89', 'L45', 'P43', 'M38', 'E49', 'C89', 'P27', 'R45', 'N27', 'H34', 'K28', 'N25', 'j59', 'R63', 'U57', 'I57', 'X23', 'E29', 'J74', 'A30', 'V38', 'B11', 'J40', 'Q64', 'W54', 'W81', 'W20', 'A41', 'I97', 'V64', 'Y10', 'X66', 'L52', 'F36', 'I99', 'S24', 'P45', 'R35', 'W55', 'S66', 'S89', 'k80', 'M59', 'G39', 'P46', 'C30', 'Y19', 'T53', 'B78', 'Q71', 'X49', 'N23', 'P47', 'P20', 'A27', 'J30', 'I88', 'T31', 'U66', 'W88', 'U50', 'G19', 'T71', 'J62', 'U50', 'E99', 'H64', 'E24', 'F58', 'L68', 'V78', 'Z11', 'D87', 'S35', 'F46', 'J69', 'Z74', 'U15', 'U54', 'X72', 'P17', 'X53', 'Y44', 'A57', 'Y27', 'n57', 'B41', 'I48', 'I61', 'C69', 'T15', 'H14', 'X71', 'E58', 'T12', 'P39', 'W89', 'D65', 'L42', 'Z96', 'C88', 'U52', 'J90', 'O12', 'X17', 'U42', 'Q91', 'Z26', 'D96', 'Z99', 'O71', 'e49', 'E79', 'N49', 'V97', 'Y59', 'F64', 'Q57', 'U50', 'H71', 'Z32', 'W28', 'L94', 'P99', 'W50', 'A24', 'p67', 'H39', 'L84', 'I49', 'F52', 'X17', 'G54', 'V12', 'H87', 'M30', 'F48', 'F15', 'R49', 'B44', 'E35', 'G21', 'O96', 'Z24', 'D71', 'O82', 'A36', 'S77', 'N47', 'H70', 'C70', 'Q29', 'b52', 'N37', 'N22', 'U69', 'K98', 'R71', 'F26', 'Q78', 'S36', 'K83', 'Z22', 'R32', 'P39', 'V21', 'L83', 'O78', 'Z57', 'F67', 'U85', 'L84', 'G82', 'K79', 'l32', 'E74', 'Q34', 'P82', 'R87', 'Y99', 'e99', 'U97', 'T68', 'C65', 'W37', 'H93', 'J99', 'O91', 'Y41', 'N35', 'T25', 'F39', 'M65', 'A34', 'N74', 'K47', 'S49', 'B45', 'F22', 'Z45', 'C48', 'D19', 'R67', 'T71', 'K97', 'H55', 'P76', 'G57', 'E90', 'X76', 'C47', 'L18', 'T10', 'l14', 'M65', 'G91', 'S54', 'D47', 'I72', 'c35', 'C37', 'M41', 'R28', 'U26', 'J37', 'Y64', 'Y57', 'O50', 'R73', 'E93', 'G65', 'O23', 'C88', 'C54', 'B45', 'Z80', 'D63', 'K67', 'X79', 'L43', 'P85', 'H25', 'A87', 'A55', 'D95', 'S22', 'U94', 'V85', 'F38', 'M84', 'Z99', 'T19', 'U27', 'E18', 'C22', 'T29', 'T66', 'U13', 'X17', 'a11', 'R71', 'G47', 'U56', 'O52', 'P83', 'J31', 'K54', 'F11', 'D10', 'I11', 'W18', 'V88', 'V36', 'D13', 'F98', 'A31', 'H95', 'S51', 'T51', 'T32', 'C13', 'C88', 'D49', 'E75', 'M96', 'K90', 'M55', 'A41', 'P41', 'X50', 'Y63', 'L27', 'S11', 'N67', 'F62', 'P22', 'W49', 'B39', 'E65', 'L99', 'L29', 'K64', 'I75', 'T78', 'N82', 'B72', 'C99', 'S55', 'A71', 'V50', 'J53', 'K48', 'C15', 'I53', 'O89', 'K43', 'T36', 'A17', 'E81', 'A14', 'F51', 'O42', 'R69', 'X44', 'U54', 'C84', 'H30', 'S37', 'S76', 'Y26', 'L57', 'A88', 'H41', 'A61', 'W24', 'E90', 'T32', 'E21', 'L44', 'D21', 'A66', 'O40', 'B25', 'K33', 'R30', 'Q89', 'C86', 'D31', 'Y73', 'B70', 'A47', 'Z65', 'L38', 'W84', 'S47', 'F78', 'Y10', 'T53', 'D52', 'S19', 'G35', 'C51', 'K20', 'Q84', 'G67', 'U72', 'a50', 'R34', 'F22', 'V49', 'Y52', 'L74', 'F83', 'G74', 'F60', 'R69', 'N73', 'W18', 'R91', 'S74', 'B21', 'O17', 'K23', 'L51', 'K51', 'N61', 'G52', 'C38', 'A86', 'U78', 'J17', 'H58', 'A16', 'A81', 'K56', 'E26', 'F60', 'X88', 'Z64', 'I80', 'F72', 'D59', 'Q92', 'C48', 'Q59', 'P47', 'F82', 'S26', 'G65', 'X97', 'Q52', 'N79', 'D33', 'R31', 'O44', 'X99', 'O42', 'P87', 'N21', 'J37', 'P89', 'A41', 'R54', 'K49', 'R82', 'O28', 'X55', 'H51', 'W40', 'W29', 'H10', 'N59', 'J88', 'E50', 'I28', 'W22', 'L45', 'T59', 'R42', 'E88', 'T72', 'V19', 'H76', 'F55', 'J83', 'X86', 'I67', 'T67', 'D35', 'Y59', 'Z13', 'G37', 'V32', 'Q19', 'A10', 'H60', 'T53', 'Q21', 'Q83', 'T61', 'N16', 'L39', 'J72', 'P91', 'L92', 'T43', 'Q79', 'Y50', 'N76', 'W85', 'P30', 'T25', 'K56', 'Y24', 'U22', 'L58', 'O79', 'N60', 'D24', 'B26', 'S90', 'M17', 'S53', 'A60', 'Y87', 'Z79']