# JUNTO Practice: Project Euler Problem 22

Discussed on August 20, 2018.

Project Euler Problem 22

## Solutions

Click to see:

### Oscar Martinez

``````#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 18 18:50:36 2018

@author: oscarmartinez
"""

#%%

"""Set Working Directory, change to your needs."""

import os

os.getcwd()
os.chdir("/Users/oscarmartinez/Master Files/JUNTO")

#%%

"""Read off the names, remove the quotation marks and split on commas"""
"""Sort the list in place as specified by problem"""

lstNames = strNamesList.split(sep=",")
lstNames.sort()

#%%

"""create Dict to map strings"""
"""NOTE: could use method .maketrans() and then str.translate() instead
in order to create a way to map name scores"""

import string

dictCharScore = {}
for i, char in enumerate(string.ascii_uppercase):
dictCharScore[char] = i + 1

#%%

"""manual sum over the list, could also use a list of numbers and then
sum over the list"""

fltTotalScore = 0.0
for row, name in enumerate(lstNames):
iBaseScore = 0
for char in name:
iBaseScore += dictCharScore[char]

iScore = iBaseScore * (row + 1)
fltTotalScore += iScore

print(fltTotalScore)
``````

### John Lekberg

``````#!/usr/bin/env python3

with open("names.txt", "r") as namefile: