Satanic route stage 2 Bilbo to Gasteiz

So after spending the night in Bilbo and having breakfast at the hostel it was time to head to Gasteiz. Difficult part was leaving the city, there were many options and I didn’t knew which one to take so I ended up asking to a couple of ertzaintzas. Once on route to Gasteiz I met a couple of cyclists on their Sunday morning ride. I asked them about the road to Gasteiz, if there was a lot of traffic, if the road was good and more things which I don’t remember. They told me to take N-240, the road was good and there wasn’t a lot of traffic. The only difficulty was Barazar, afterwards it was mostly flat to Gasteiz.

So after leaving the cyclists we pass through Lemoa, Igorre and other small towns we start to climb Barazar. There is not a lot of traffic and there are a lot of trees. Didn’t noticed any fountain through the climb. Had to make a stop to drink some water and get some rest around 2500 mts from the top. Picture below.
IMG_20150621_124257

Around two kms from the top there is this amazing view.
IMG_20150621_124943

And after two more kms you reach the summit.
IMG_20150621_130604

From now on mostly flat till Gasteiz. Crossing into Arava.
IMG_20150621_132957

Not much from here on. Different views from coastal Euskal Herria, more dry and hot. Careful when arriving to Gasteiz, don’t get inside the highway. You enter GAsteiz through and industrial park, nothing worth seeing there.

Had to ask a local cop for the hostel. After the check-in and a lovely shower, well deserved shower I went for out for lunch. Pintxos and Txakoli was once again what I had for lunch. Took a short walk through the old town, but went back to the hostel because there was too much heat. Some pictures from the old town below.
Virgen Blanca square below.
IMG_20150621_164945

IMG_20150621_171106

At around 1900 I had to share the room with a pilgrim going to Compostela on a MTB. Nice guy, told him to give me a call when he arrives at Compostela. We started talking about the route and went out for beer and dinner. Bocatas at El Siete were excellent. At around 2230 we went back to the hostel. Monday ride was not gonna be short, around 130 kms. Heading to Burgos, Castille.

Strava file here.

Satanic route stage 1 Donosti to Bilbo

So on June 20 I started what I chose to call satanic route. Something like the way to Santiago, but basically cycling with a 5Kg backpack. First stage will take us from Donosti to Bilbo, Basque Country main cities.

Having arrived to Donosti train station on June 19, forty minutes later than expected. I basically unpacked my Ridley Orion and headed to the hostel to make the reservation. After all set and done went to old town to have dinner at Bar Etxaniz in Fermin Calbeton street.

Woke up early on June 20 and had breakfast at Pasteleria Oiartzun breakfastafterwards went to Jaia Bicicletas to get my bike set up. Once done went to La Concha beach to take a picture for the start of the route.
bike

So we started going up to Igueldo, amazing day and amazing view up there.
igueldo
Many cyclist going up that route, almost no traffic. Spoke to a cyclist who told me how to go to Bilbo. Really nice.

Once Igueldo you go down to the coast and pass through Zarautz.
zarautz
Nice beach, but looks like too cold for me. After we head to Zumaia and start heading to Eibar, leaving the basque coast behind. Found this nice view after Itziar climb.
view
In Eibar we pay a short visit to Ipurua.
ipurua
And after Eibar we enter Bizkaia through Ermua. After Ermua its all going downhill to Bilbo mostly.

I had to stop in Amorebieta(around 25 kms away from Bilbo) to have a beer, heat was hitting me hard and I needed a rest. There was traffic when getting near to Bilbo, but there is a lot of respect for cyclist in Basque Country.

So we arrive to Bilbo and head to the hostel along the river. View of Guggenheim Museum.
guggenheim
New San Mames stadium. House of Athletic Club.
sanmames

After finding the hostel and having a WELL deserved shower I went to the old town to have dinner. Pintxos mostly.
pinchos
Pintxos in Basque Country are amazing. After having dinner I took the subway to head back to the hostel. It was early, but Sunday I was going to Gazteiz.

Here is my strava.

Project Euler number 11

Below is my solution to Poject Euler number eleven. I created back ordered array with the number and its positions on a 2D 20×20 array. The 4 corners 4×4 array products only the vertical and horizontal products where calculated since the diagonal products are calculated previously with the 16×16 array.

#!/usr/bin/env python

import time

start = time.time()
f = open("grid.txt", "r")
i = 0
j = 0
newList = []
List = []

# Create and array 20x20 converting members to int
for line in f:
        List.append(line.split())
        List[i] = map(int, List[i])
        i = i + 1

# Create an ordered array starting by highest number and writing also position
i = 0
j = 0
for i in range(len(List[i])):
        for j in range(len(List[i])):
                newList.append([List[i][j],[i,j]])
sortedList = sorted(newList)
# backorderdList is an array containing an ordered number with its positions in array second entry.
backorderedList = sortedList[::-1]

max = 0
for member in backorderedList:
        if ((member[1][0] == 0) and (member[1][1] == 0)):
                # Multiply upper corner first four lines
                for x in range(4):
                        # Line multiplication
                        newmax = List[x][0]*List[x][1]*List[x][2]*List[x][3]
                        if (newmax > max):
                                max = newmax
                        # Column multiplication
                        newmax = List[0][x]*List[1][x]*List[2][x]*List[3][x]
                        if (newmax > max):
                                max = newmax

        elif ((member[1][0] == 0) and (member[1][1] == 16)):
                # Multiply upper right corner
                for x in range(4):
                        # Line multiplication
                        newmax = List[x][16]*List[x][17]*List[x][18]*List[x][19]
                        if (newmax > max):
                                max = newmax
                        # Column multiplication
                        newmax = List[0][x+16]*List[1][x+16]*List[2][x+16]*List[3][x+16]
                        if (newmax > max):
                                max = newmax

        elif ((member[1][0] == 16) and (member[1][1] == 0)):
                # Multiply lower left corner
                for x in range(4):
                        # Line multiplication
                        newmax = List[x+16][0]*List[x+16][1]*List[x+16][2]*List[x+16][3]
                        if (newmax > max):
                                max = newmax
                        # Column multiplication
                        newmax = List[16][x]*List[17][x]*List[18][x]*List[19][x]
                        if (newmax > max):
                                print max

        elif ((member[1][0] == 16) and (member[1][1] == 16)):
                # Multiply lower right corner
                for x in range(4):
                        # Line multiplication
                        newmax = List[x+16][16]*List[x+16][17]*List[x+16][18]*List[x+16][19]
                        if (newmax > max):
                                max = newmax
                        # Column multiplication
                        newmax = List[16][x+16]*List[17][x+16]*List[18][x+16]*List[19][x+16]
                        if (newmax > max):
                                max = newmax

        elif ((member[1][0] >= 3) and (member[1][0] <= 16) and (member&#91;1&#93;&#91;1&#93; >= 3) and (member[1][1] <= 16)):
                # column numbers from numbers not on edges
                newmax = List&#91;member&#91;1&#93;&#91;0&#93;-3&#93;&#91;member&#91;1&#93;&#91;1&#93;&#93;*List&#91;member&#91;1&#93;&#91;0&#93;-2&#93;&#91;member&#91;1&#93;&#91;1&#93;&#93;*List&#91;member&#91;1&#93;&#91;0&#93;-1&#93;&#91;member&#91;1&#93;&#91;1&#93;&#93;*List&#91;member&#91;1&#93;&#91;0&#93;&#93;&#91;member&#91;1&#93;&#91;1&#93;&#93;
                if (newmax > max):
                        max = newmax
                newmax = List[member[1][0]+3][member[1][1]]*List[member[1][0]+2][member[1][1]]*List[member[1][0]+1][member[1][1]]*List[member[1][0]][member[1][1]]
                if (newmax > max):
                        max = newmax
                # line numbers
                newmax = List[member[1][0]][member[1][1]-3]*List[member[1][0]][member[1][1]-2]*List[member[1][0]][member[1][1]-1]*List[member[1][0]][member[1][1]]
                if (newmax > max):
                        max = newmax
                newmax = List[member[1][0]][member[1][1]+3]*List[member[1][0]][member[1][1]+2]*List[member[1][0]][member[1][1]+1]*List[member[1][0]][member[1][1]]
                if (newmax > max):
                        max = newmax
                # diagonal numbers
                newmax = List[member[1][0]-3][member[1][1]-3]*List[member[1][0]-2][member[1][1]-2]*List[member[1][0]-1][member[1][1]-1]*List[member[1][0]][member[1][1]]
                if (newmax > max):
                        max = newmax
                newmax = List[member[1][0]+3][member[1][1]+3]*List[member[1][0]+2][member[1][1]+2]*List[member[1][0]+1][member[1][1]+1]*List[member[1][0]][member[1][1]]
                if (newmax > max):
                        max = newmax
                newmax = List[member[1][0]-3][member[1][1]+3]*List[member[1][0]-2][member[1][1]+2]*List[member[1][0]-1][member[1][1]+1]*List[member[1][0]][member[1][1]]
                if (newmax > max):
                        max = newmax
                newmax = List[member[1][0]+3][member[1][1]-3]*List[member[1][0]+2][member[1][1]-2]*List[member[1][0]+1][member[1][1]-1]*List[member[1][0]][member[1][1]]
                if (newmax > max):
                        max = newmax

print "Max is: %d." % (max)
elapsed = (time.time() - start)
print "Elapsed time: %s seconds." % (elapsed)

f.close()

Took the execution time idea from here.

Execution:

user@server1: ~ $ python euler_11.py ; uname -a
Max is: 70600674.
Elapsed time: 0.0441608428955 seconds.
Linux server1 2.6.32-042stab106.4 #1 SMP Fri Mar 27 15:19:28 MSK 2015 x86_64 GNU/Linux
user@server1: ~ $

Small script to calculate future value

Heres a small script I wrote to calculate the future value.

#!/usr/bin/env python

# This script calculate the future value

iv = float(raw_input("Enter initial value: "));
rate = float(raw_input("Enter interest rate: "));
times = int(raw_input("Enter the amount of years: "));

fv = iv*((1 + (rate/100))**times)

print "Final amount is: %.2f." %fv