initial commit

This commit is contained in:
Chris Cromer 2018-12-04 14:40:14 -03:00
commit 948c51ada1
14 changed files with 515 additions and 0 deletions

12
LICENSE Normal file
View File

@ -0,0 +1,12 @@
Copyright 2018 Chris Cromer
Copyright 2018 Rodolfo Cuevas
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

35
Makefile Normal file
View File

@ -0,0 +1,35 @@
CC=gcc
CFLAGS=-Wall -Isrc/include -DDEBUG -g
LDFLAGS=-lm
SRC=src/points.c src/timer.c src/random.c
OBJ=$(SRC:.c=.o)
all: points informe
points: $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
informe:
# if pdflatex is installed create the informe
ifneq (, $(shell which pdflatex))
make -C doc
mv doc/Informe.pdf Informe.pdf
endif
test:
make -C test
test/test
clean: cleanpoints cleaninforme cleantest
cleanpoints:
rm -f src/*.o points
cleaninforme:
make -C doc clean
rm -f Informe.pdf
cleantest:
make -C test clean
.PHONY: all points informe test clean cleanpoints cleaninforme cleantest

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# Points
Una programa que deja encontar un par de puntos más cercano.
[points](https://git.cromer.cl/UBB/points)
## Autores
Christopher Cromer
Rodolfo Cuevas
## Compilar
Hay tres blancos disponible para usar con GNU Make:
make points
Compilar el programa
make test
Comprobar que los algoritmos y programa corren como esperado
make informe
Compilar el informe si pdflatex está disponible en el sistema
## Correr el programa
./points

125
doc/Informe.tex Normal file
View File

@ -0,0 +1,125 @@
\author{}
\date{\today}
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc} %\ This allows spanish tildes
\usepackage[spanish]{babel}
\usepackage{array}
\usepackage{adjustbox}
\usepackage{titling}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm,a4paper]{geometry}
\usepackage{amsmath}
\title{Tarea 2: Encontrar el par de puntos más cercano}
\usepackage{listings}
\lstset{
basicstyle=\small\ttfamily,
columns=flexible,
breaklines=true,
inputencoding=utf8,
extendedchars=true,
literate={á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 {ñ}{{\~n}}1 {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 {Ñ}{{\~N}}1
}
\usepackage{hyperref}
\hypersetup{colorlinks=true,allcolors=black,pdftitle={Tarea 1: Ordenamiento}}
\usepackage{hypcap}
\pretitle{%
\begin{center}
\LARGE
\includegraphics[width=4cm]{ubblogo.png}\\[\bigskipamount]
\Large
\textbf{Análisis y Diseño de Algoritmos}\\[\smallskipamount]
}
\posttitle{\end{center}}
\begin{document}
\hypersetup{pageanchor=false}
\clearpage\maketitle
\thispagestyle{empty}
\begin{flushright}
\textbf{Integrantes:}\\
Christopher Cromer\\
Rodolfo Cuevas
\end{flushright}
\begin{flushright}
\textbf{Profesor:}\\
Pedro Rodríguez
\end{flushright}
\begin{flushright}
\textbf{Ayudantes:}\\
Carlos Faúndez\\
Xavier Canales
\end{flushright}
\newpage
\clearpage
\thispagestyle{empty}
\tableofcontents
\newpage
\hypersetup{pageanchor=true}
\pagenumbering{arabic}
\section{Pseudo código}
\subsection{Brute Force}
\newpage
\subsection{Divide and Conquer}
\newpage
\section{Resultados}
\subsection{Análisis temporal}
\subsubsection{Brute Force}
\underline{Caso Promedio:} $ \Theta(n log n)) $ \\
\bigskip
\underline{Peor Caso:} $ O(n log n) $ \\
\bigskip
\underline{Mejor Caso:} $ \Omega(n log n)$ \\
\bigskip
\subsubsection{Divide and Conquer}
\underline{Caso Promedio:} $ \Theta(n log n)) $ \\
\bigskip
\underline{Peor Caso:} $ O(n log n) $ \\
\bigskip
\underline{Mejor Caso:} $ \Omega(n log n)$ \\
\bigskip
\newpage
\subsection{Datos}
La siguiente tabla contiene los resultados de las pruebas de los 2 algoritmos medidos en segundos. Para las pruebas usábamos un computador que tiene 4 núcleos de 3.2GHz y 16GB de memoria RAM.
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
\multicolumn{3}{|c|}{Algoritmos para encontrar los 2 puntos más cercano} \\
\hline
\rule[-1ex]{0pt}{3.5ex} & Brute Force & Divide and Conquer \\
\hline
\rule[-1ex]{0pt}{3.5ex} 1.000.000 & 0[s] & 0[s] \\
\hline
\rule[-1ex]{0pt}{3.5ex} 5.000.000 & 0[s] & 0[s] \\
\hline
\end{tabular}
\end{center}
\newpage
\subsection{Gráfico}
\newpage
\section{Conclusiones}
\end{document}

9
doc/Makefile Normal file
View File

@ -0,0 +1,9 @@
informe:
# we do this twice to make sure the toc is updated
pdflatex -synctex=1 -interaction=nonstopmode "Informe.tex"
pdflatex -synctex=1 -interaction=nonstopmode "Informe.tex"
clean:
rm -f *.log *.toc *.gz *.aux *.out Informe.pdf
.PHONY: informe clean

BIN
doc/tar2-ada-2018-2.pdf Normal file

Binary file not shown.

BIN
doc/ubblogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

19
src/include/random.h Normal file
View File

@ -0,0 +1,19 @@
/*
* Copyright 2018 Christopher Cromer
* Copyright 2018 Rodolfo Cuevas
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _POINTS_RANDOM
#define _POINTS_RANDOM
int gen_rand(int min, int max);
#endif

22
src/include/timer.h Normal file
View File

@ -0,0 +1,22 @@
/*
* Copyright 2018 Christopher Cromer
* Copyright 2018 Rodolfo Cuevas
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _POINTS_TIMER
#define _POINTS_TIMER
void start_timer();
void stop_timer();
void print_timer();
long int get_timer();
#endif

94
src/points.c Normal file
View File

@ -0,0 +1,94 @@
/*
* Copyright 2018 Christopher Cromer
* Copyright 2018 Rodolfo Cuevas
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include "timer.h"
#define POINTS_VERSION "1.0.0"
/**
* Imprimir el uso del programa
*/
void print_usage() {
fprintf(stdout, "uso: points [OPCIÓN]\n");
fprintf(stdout, " -a, --all usar todos los algoritmos de ordenamentio\n");
fprintf(stdout, " -b, --brute usar brute force\n");
fprintf(stdout, " -d, --divide usar divide and conquer\n");
fprintf(stdout, " -h, --help mostrar como usar el programa\n");
fprintf(stdout, " -v, --version mostrar la versión del programa\n");
}
/**
* La entrada del programa
* @param argc La cantidad de argumentos pasado al programa
* @return Retorna el codigo de error o 0 por exito
*/
int main (int argc, char **argv) {
int brute = 0;
int divide = 0;
int opt;
int long_index = 0;
static struct option long_options[] = {
{"all", no_argument, 0, 'a'},
{"brute", no_argument, 0, 'b'},
{"divide", no_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
if (argc == 1) {
print_usage();
return 0;
}
while ((opt = getopt_long(argc, argv, "abdhv", long_options, &long_index)) != -1) {
switch (opt) {
case 'a':
brute = 1;
divide = 1;
break;
case 'b':
brute = 1;
break;
case 'd':
divide = 1;
break;
case 'h':
print_usage();
return 0;
case 'v':
printf("points versión: %s\n", POINTS_VERSION);
return 0;
break;
default:
print_usage();
return 1;
}
}
if (!brute && !divide) {
fprintf(stderr, "Error: No se seleccionó un algoritmo valido!\n");
print_usage();
return 4;
}
return 0;
}

36
src/random.c Normal file
View File

@ -0,0 +1,36 @@
/*
* Copyright 2018 Christopher Cromer
* Copyright 2018 Rodolfo Cuevas
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include <time.h>
/**
* Flag para inicilizar srand solo una vez
*/
static int sort_rand_initialized = 0;
/**
* Generar un númer al azar entre un mínimo y máximo
* @param min El limite míninmo
* @param max El limite máximo
* @return Retorna el número generado
*/
int gen_rand(int min, int max) {
if (sort_rand_initialized == 0) {
srand((unsigned int) time(NULL));
sort_rand_initialized = 1;
}
return rand() % (max + 1 - min) + min;
}

86
src/timer.c Normal file
View File

@ -0,0 +1,86 @@
/*
* Copyright 2018 Christopher Cromer
* Copyright 2018 Rodolfo Cuevas
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <time.h>
#include <math.h>
/**
* Cuando empezó el timer
*/
static struct timespec start_time;
/**
* Cuando terminó el timer
*/
static struct timespec stop_time;
/**
* Empezar el timer
*/
void start_timer() {
clock_gettime(CLOCK_MONOTONIC, &start_time);
stop_time.tv_nsec = 0;
}
/**
* Terminar el timer
*/
void stop_timer() {
if (start_time.tv_nsec == 0) {
fprintf(stderr, "Error: El temporizador no ha comenzado todavía!\n");
}
else {
clock_gettime(CLOCK_MONOTONIC, &stop_time);
}
}
/**
* Imprimir el tiempo de ejecución
*/
void print_timer() {
if (start_time.tv_nsec == 0) {
fprintf(stderr, "Error: El temporizador no ha comenzado todavía!\n");
}
else if (stop_time.tv_nsec == 0) {
fprintf(stderr, "Error: El temporizador no ha terminado todavía!\n");
}
else {
time_t seconds = stop_time.tv_sec - start_time.tv_sec;
unsigned long long milliseconds = round((stop_time.tv_nsec - start_time.tv_nsec)/ 1.0e6); // Convert nanoseconds to milliseconds
if (milliseconds > 999) {
seconds++;
milliseconds = 0;
}
unsigned int minutes = 0;
unsigned int hours = 0;
if (seconds >= 3600) {
hours = seconds / 3600;
seconds = seconds - (hours * 3600);
if (seconds >= 60) {
minutes = seconds / 60;
seconds = seconds - (minutes * 60);
}
fprintf(stdout, "Tiempo de ejecución: %d horas, %d minutos y %ld.%lld segundos\n", hours, minutes, seconds, milliseconds);
}
else if (seconds >= 60) {
minutes = seconds / 60;
seconds = seconds - (minutes * 60);
fprintf(stdout, "Tiempo de ejecución: %d minutos y %ld.%lld segundos\n", minutes, seconds, milliseconds);
}
else {
fprintf(stdout, "Tiempo de ejecución: %ld.%lld segundos\n", seconds, milliseconds);
}
}
}

16
test/Makefile Normal file
View File

@ -0,0 +1,16 @@
CC=gcc
CFLAGS=-Wall -I../src/include -DDEBUG -g
SRC=test.c
OBJ=$(SRC:.c=.o)
OBJ+=../src/random.o
all: test
test: $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
clean:
rm -f *.o test
.PHONY: all test clean

38
test/test.c Normal file
View File

@ -0,0 +1,38 @@
/*
* Copyright 2018 Christopher Cromer
* Copyright 2018 Rodolfo Cuevas
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/**
* El programa de test
*/
int main(int argc, char **argv) {
int pass;
int passed = 0;
int failed = 0;
fprintf(stdout, "%d tests passed\n", passed);
fprintf(stdout, "%d tests failed\n", failed);
if (failed == 0) {
return 0;
}
else {
return 1;
}
}