#WSQ12

#include “BigIntegerLibrary.hh”
#include <iostream>
#include <string>
using namespace std;

BigInteger lychrel (BigInteger x){

string z = bigIntegerToString(x);
lychrel(z.begin(), z.end());
BigInteger lychrel = stringToBigInteger(z);
return lychrel;
}

int main() {
int inferior,superior, p, k, number, a=0;
int f=0, n=0;
BigInteger y, c=0, suma=0;

cout << “Dame el limite inferior”;
cin>>inferior;

cout<< “Dame el limite superior”;
cin>>superior;

for(c=inferior; c<=superior; c++){
for(BigInteger m=count; m<=count;m++){

y= lychrel(m); suma=y+c;}

if(c==y) {
n=n+1;
} else {
int times= 0;

BigInteger numero = c;
y=lychrel(numero);

while(times<30 && numero!=y){

number = numero+y;
y = lychrel(numero);
times = times+1;
}
if(times < 30){
a = a+1;
} else {
cout << “Lychrel found ” <<c<< endl;
f = f+1;
}
}
}

cout <<“The palindrom is: ” << n <<endl;
cout<<“Non lychrel become palindrom in one interacion: “<<a<<endl;
cout<<“The lychrel is: “<<f<<endl;

return 0;
}

WSQ12 – Word Count

average-word-count

Create a program that asks the user for a word which will be your search word and the name of a file to open and search for that word. Then create a function that will receive two parameters (both string) representing those two data points. This function returns the number of occurrences of that word in that file.

Instrucciones WSQ12 – Word Count

Este programa fue muy complicado de realizar, nuestro profesor Ken, nos otorgó un link el cual nos podría ayudar y así fue, no fue de mucha ayuda para mi, pero si aclaró unas cuantas dudas que yo tenía, pero como no pude entenderlo de todo, exploré por blogs de mis compañeros del curso y con ayuda personal de otros compañeros, pude realizar este programa.

Link otorgado por Ken

WSQ12 - WordCount

Link GitHub: WSQ12 – Word Count

Contador de palabras

Nosotros debimos preguntarle al usuario por una palabra que va a ser la palabra de búsqueda y un el nombre de un archivo donde se va a buscar la palabra. Después creamos una función que va a recibir dos parámetros que significan los dos puntos. La función va a regresar el numero de veces que se encontró la palabra en el archivo.

Las librerías que se utilizaron son iostream, string y fstream, en la función main se clararán las variables de tipo string. se le pregunta al usuario por la palabra que se quiere buscar y se va a guardar con el nombre de la variable “palabra”, después se le pregunta la usuario por el archivo en donde se va a hacerla búsqueda, y la respuesta se guardara en la variable “archivo”.

En la función externa se declaran las variables palabra y archivo. se iguala el count a cero. la libreria ifstream myfile.archivo buscara el archivo. si el archivo es encontrado por el codigo, lo va a abrir  y lo siguiente es usar un ciclo While en la cual va a leer linea por linea todo el archivo con Getline. si en la linea encuentra la palabra, se va a ir contando, y eso se va a repetir hasta que se acabe todo el archivo de analizar. Seguido de esto, se necesita cerrar el archivo con myfile.close(). Si no se encuentra ninguna palabra en el archivo, el archivo regresara al usuario que no se encontro nada. Por ultimo la funcion va a regresar el total del contador.

Captura de pantalla 2016-05-05 21.38.44

 

El link de Github es este: Codigo

WSQ12 – Word Count

Instruction:

Create a program that asks the user for a word which will be your search word and the name of a file to open and search for that word. Then create a function that will receive two parameters (both string) representing those two data points. This function returns the number of occurrences of that word in that file.

Here is a picture of the code:

WSQ12

 

Here is a link to the code in Github.

Python/WSQ-12 (Word Count)

Word count WSQ12

Here is my blog post for the WSQ 12.

Create a program that asks the user for a word which will be your search word and the name of a file to open and search for that word. Then create a function that will receive two parameters (both string) representing those two data points. This function returns the number of occurrences of that word in that file. Here is the link to my GitHub.

 

Captura de pantalla 2016-05-04 a las 11.14.45 p.m..png

Contador de palabras – #WSQ12

Aquí es cuando comenzamos a usar Python para cosas más interesantes y útiles en el mundo real. El problema a resolver en este #WSQ es indicarle a Python el nombre de un archivo, dejar que lo abra y posteriormente que busque cierta palabra dentro de el. Impresionante, ¿No es así?

palabras 1

Para resolver esta tarea Ken nos indicó un link que fue de muchísima ayuda, aunque si soy sincero, tengo que decir que mejor me vi el tutorial en Lynda.com ya que al ser más visuales hacen las cosas mucho más fáciles. Lamentablemente, sólo estaba disponible un tutorial orientado a Java pero me fue más que suficiente para poder aplicarlo a Python.

El código resultó en:

fname = input("Por favor, escribe el nombre del archivo que quieres buscar: ")
word = input("Exactamente, ¿Qué palabra estás buscando?: ").lower()
lower_case_word = word.lower()


def Counter(lower_case_word, fname):
counter = 0
with open(fname) as openfile:
for line in openfile:
line = line.lower()
counter += line.count(lower_case_word)
return(counter)

print("El numero total de la palabra " + str(word) + " en el archivo " + str(fname) + " es: " + str(Counter(lower_case_word, fname)))

Como siempre, si tienes alguna duda siempre puedes dejar un comentario o bien, checar mi código en Github, ahí está actualmente todo lo que hago. ¡Harías bien en darle un vistazo!

 

 

WSQ #12 Word Count

This one was very difficult so I asked my friend Christian for his help, he is going to be a programmer so I thought he could help me figure out what to do; therefore I saw the way he did it in order to do it, I basically do it with him the whole time, because I wasn’t sure how to do it. It was hard :O but I did it finally. Here is the CODE in case you might need it.

Screenshot19

Screenshot19.1

Anyways, it was hard, but Christian made it easier, so I thank BatmanTec for coding.