# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/1carlosd1/daa_2021_1/blob/master/Tarea5.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="dAFaBMl0G1Pk" outputId="d5c0978c-e1d1-4222-e6d9-32a3a1ba1c24" colab={"base_uri": "https://localhost:8080/", "height": 357}
from time import time
def ejemplo1( n ):
  start_time = time()
  c = n + 1
  d = c * n
  e = n * n
  total = c + e - d
  print(f"total={ total }")
  elapsed_time = time() - start_time
  print("Tiempo transcurrido: %0.10f segundos." % elapsed_time)
for entrada in range(100,1100,100):
  ejemplo1(entrada)


# + id="TP3qYxdNJeud" outputId="6e36f0ce-396f-40cb-c5fe-7f6174263077" colab={"base_uri": "https://localhost:8080/", "height": 187}
from time import time
def ejemplo2( n ):
  start_time = time()
  contador = 0
  for i in range( n ) :
    for j in range( n ) :
      contador += 1
  elapsed_time = time() - start_time
  print("Tiempo transcurrido: %0.10f segundos." % elapsed_time)
  return contador
for entrada in range(100,1100,100):
  ejemplo2(entrada)

# + id="Bm86b9e0MSFW" outputId="cff594e1-13c9-4264-c5f6-748eaa9d06d9" colab={"base_uri": "https://localhost:8080/", "height": 187}
from time import time
def ejemplo3(n):
  start_time = time()
  x=n*2 #x=8
  y=0
  for m in range(100):
    y=x-n 
  elapsed_time = time() - start_time
  print("Tiempo transcurrido: %0.10f segundos." % elapsed_time)  
  return y
for entrada in range(100,1100,100):
  ejemplo3(entrada)


# + id="PYUiIB75NSR-" outputId="64d743ee-8eef-4ff0-c895-bf9b2c52aaae" colab={"base_uri": "https://localhost:8080/", "height": 187}
from time import time
def ejemplo4( n ):
  start_time = time()
  x = 3 * 3.1416 + n
  y = x + 3 * 3 - n
  z = x + y
  elapsed_time = time() - start_time
  print("Tiempo transcurrido: %0.10f segundos." % elapsed_time)
  return z
for entrada in range(100,1100,100):
  ejemplo4(entrada)


# + id="B6x4HCKqOMwU" outputId="0028eec9-cf04-4d9b-b97f-75aa9ffc118d" colab={"base_uri": "https://localhost:8080/", "height": 187}
from time import time
def ejemplo5( x ):
  start_time = time()
  n = 10
  for j in range( 0 , x , 1 ):
    n = j + n
  elapsed_time = time() - start_time
  print("Tiempo transcurrido: %0.10f segundos." % elapsed_time)
  return n
for entrada in range(100,1100,100):
  ejemplo5(entrada)


# + id="66OCW4DaO3vo" outputId="a0665feb-245a-44a9-cf91-26b468f87091" colab={"base_uri": "https://localhost:8080/", "height": 187}
def ejemplo6( n ):
  start_time = time()
  data=[[[1 for x in range(n)] for x in range(n)]
        for x in range(n)]
  suma = 0
  for d in range(n):
    for r in range(n):
      for c in range(n):
        suma += data[d][r][c]
    elapsed_time = time() - start_time
    print("Tiempo transcurrido: %0.10f segundos." % elapsed_time)
    return suma

for entrada in range(100,1100,100):
  ejemplo6(entrada)

StarcoderdataJupyterScriptsDedupFiltered