# Final Project: Sudoku

#TC1017

I choose this project because when I was still in high school I saw some dude programming this and thought it was very cool and just as a personal challenge I tried to figure out on my own if I could make such a programm. Turns out I can!

While there are still some flaws or things I would still change, such as have colored output and make some functions smarter, it still is completely playable and you can download any sudoku text file and try to solve it using my code.

I learned a lot while making this game, specially how easy vectors are to use, as opposite to arrays, which just passing as paramaters is a nightmare. Also reading and opening files was another skill I developed while programming this.

The hardest bit was coming up with a function that would check for repetitions inside a matrix, and I think just doing that was maybe like 6o% of the whole work.

Many ideas and insipration came from this guy’s code online:

Sudoku Program in C++

only I decided to do it my way using something simpler but not as fancy. His code just gave me an idea of the kinds of functions I had to implement, how to implement them was completely up to me.

I have to say I feel satisfied with this project since it was a great way to summarize most of the content of the course.

Screenshot:

GitHub link with code and txt file: https://github.com/diegodamy/Sudoku

# WSQ14: SciLab

#Tc1017 #SciLab

SciLab is a numerical computation software which is quite handy and also easier to understand than C++ in my opinion, its graphic options are very useful as well, and the handling of matices is definitely more intuitive than in C++.

Understanding SciLab:

1. On the console screen, we can use the arrows to change instructions and find the history of used commands, kinda like how we use the arrow keys in the compiler.
2. When using the console we have to input first –> before any command
3. Basic operations and inserting comments remain the same as in C++.
4. We can use %e, %pi and %i to represent euler’s constant, pie and complex numbers.
5. The semicolon is used to avoid any result from beign displayed, no compiling error will occur here.
6. More useful than the console screen is the editor, which is basically a word processor in which coding becomes easier.

Plotting in SciLab:

1. Command: plot.
2. clf menas clear plot, while scf opens another window.
3. Colors can be added to curves: letter enclosed by “” –> “b” makes blue
4. Point styles work the same
5. Segments go in square brackets, point go in round ones.
6. Statistics: useful for creating bar graphs
7. Use bar command –> bar (x,n,color)

Creating functions:

1. Begin: function
2. End: endfunction
3. Variables must always have a value, but we don´t have to declare them in advanced😀
4. Function’s parameters work the same as in C++
5. Logical operators remain the same, only != becomes <>

Matrices and vectors:

1. Al operations are done with matrices.
2. A space or coma separates columns.
3. Semicolons separate rows.

Loops:

1. Beggining:step: value –> this way is much simpler than C++
2. For and while finish with an end.

# Course Review

#TC101 #CourseReview

Programming in C++: Course Review

As we steadily approach the end of the semester, we can now look back on the experiences gained throughout this course and reflect about them.

Since I´m taking this course for the second time now, the experience miaght have been a little different for me than for everyone else, since I was already familiarized with all of the content, yet I didn´t have a perfect understanding of quite a few things.

Before I get into the course topics themselves, I’d like to talk about this new teaching method, the so called “Flipped-Classroom”. For me it was a great idea, it meant I could do my programming whenever I wanted and use the time in class to work on other projects or homework, which I really appreciated since. This had a bad side effect towards the end of the second parcial but I´ll talk about that later.

The fact that we had to upload our Blogs was also a good idea since it forced us to explain ourselves what our programms did, and sometimes that led to us finding mistakes within our codes or a better way to do something. And by making everyone´s code available, it was easy to get past beign stuck by looking at other classmate´s codes.

Now about the bad side effects I mentioned earlier. Since I didn´t go to class all that much, I didn´t get to know many of my classmates, so that really took a hit on the whole social aspect for me. Part of me just wanted to be alone to prove myself I can get this course done by myself, kind of the reason I did the final Project alone, and the less-tech savvy part of myself just wasn´t used to the whole blogging-twitting thing.

# QUIZ 7: Dot product

#TC1017 #QUIZ 7

The last of the quizzes. I wanted to import the lists from text files just to practice doing that, but I had a problem with the unknown sizes of the lists, turns out I only managed to get it working properly if I specify before hand how big each list is. Other wise it was a simple quiz for me since I was also working on my sudoku.

Source Code:

#include <iostream>
#include <fstream>
#include <vector>
#include <string>

using namespace std;

int CheckIfFirstOpen(string list1){
ifstream ListOne;
ListOne.open(list1.c_str());

if (ListOne.is_open()){
return 1;
} else {
return 0;
}
}

int CheckIfSecondOpen(string list2){
ifstream ListTwo;
ListTwo.open(list2.c_str());

if (ListTwo.is_open()){
return 1;
} else {
return 0;
}
}

vector<int>List1(4);
ifstream ListOne;
ListOne.open(list1.c_str());

for (int i = 0; i < List1.size(); i++) {
ListOne >> List1[i];
}
return List1;
ListOne.close();
}
vector<int>List2(4);
ifstream ListTwo;
ListTwo.open(list2.c_str());

for (int i = 0; i < List2.size(); i++){
ListTwo >> List2[i];
}
return List2;
ListTwo.close();
}

int DotProduct (vector<int>List1, vector<int>List2){
int size = 4;
int sum;

for (int i = 0; i < size; i++){
sum += List1[i] * List2[i];
}
cout << “Dot product is ” << sum;
}

int main(){
string list1;
string list2;

cout << “Please enter the name of the first list:” << endl;
cin >> list1;
cout << “Please enter the name of the second list:” << endl;
cin >> list2;

while (CheckIfFirstOpen(list1) == 0) {
cout << “Unable to open first file.” << endl;
cout <<“Please enter the name of the first text:” << endl;
cin >> list1;
}
cout << endl;

while (CheckIfSecondOpen(list2) == 0) {
cout << “Unable to open second file.” << endl;

# WSQ13: Exam corrections

#TC1017 #WSQ13

Q1:

For this first question we had to print out a kind of rotated pyramid, which I must say I found somewhat complicated because of the nested ifs. All important notes can be found in the source code:

Q2:

The superpower one. We had already done this as a quiz, but I didn´t realize my old code wasn´t really working so it took me a while to realize what I was doing wrong. It turned out I had to multiply the result by the base, and I was doing some weird additions. But now it works perfectely.

Q3:

The fibonacci series was also already done before, it is quite simple.

Q4:

This last problem I could not complete, but here is my source code:

#include <iostream>
#include <string>

using namespace std;

int FindPali(string word){
int i, j;
int size = word.size();

/*This cycle should compare all indices to their opposites to chech for symmetry and decide wheter it is a palindrome or not, however it is not doing anything it seems.*/
for (i=0; i<size; i++){
} cout << word[i];
for (j=size; j>0; j–){
} cout << word[j];
if (word[i] == word[j]){
return 1;
}

}

int main(){
string word;
cout << “Please enter the word:” << endl;
getline (cin, word);

if (FindPali(word)==1){
cout << “Palindrome!” << endl;
} else {
cout << “Not a palindrome.”<< endl;
}

}

GitHub link including all questions: https://github.com/diegodamy/Exam2-Q1

# Course Review TC101

Este es el trabajo final de esta materia llamada Solución de problemas con programación con el profesor Ken Bauer.

A pesar de haber batallado bastando al principio del curso por dificultades al programar y al organizar bien mi tiempo, terminé disfrutando este curso, por el ambiente que se vivía durante el salón de clases y por la nueva experiencia que me llevo con el modelo de aprendizaje TEC21 o Flipped Learning.

Llevo conmigo muchas cosas aprendidas en este curso acerca de programar en C++, le di continuidad por primera vez a un blog creado por mi durante todo un semestre que espero y pueda ser de utilidad en un futuro para alumnos que cursen esta materia.

Agradezco al profesor Ken Bauer y a mis compañeros por todo el apoyo que me brindaron al momento de cursar esta materia.

# WSQ14 – Scilab

Scilab es un software para análisis numérico, con un lenguaje de programación de alto nivel para cálculo científico. Es desarrollado por Scilab Enterprises, bajo la licencia CeCILL, compatible con la GNU General Public License.

Las características de Scilab incluyen análisis numérico, visualización 2-D y 3-D, optimización, análisis estadístico, diseño y análisis de sistemas dinámicos, procesamiento de señales, e interfaces con Fortran, Java, C y C++. Mientras que la herramienta Xcos permite una interfaz gráfica para el diseño de modelos.

Wikipedia

Para este último WSQ, se instaló este programa llamado Scilab con el propósito de conocer las utilidades que podemos encontrar en Scilab y probarlo un poco.

Para no estar tan desubicados con este programa, se nos proporcionó 2 manuales tutoriales, uno en inglés y otro en español.

Aquí les dejo un vídeo, el cual es una introducción a Scilab:

Lo primero que hice con el programa abierto por primera vez, fueron unas operaciones muy sencillas, declaramos una variable “x” y una variable “y”, las cuales las multiplicamos entre si, y por ultimo, el resultado fue multiplicado por otro número.

Espero que este programa me pueda ser de utilidad en un futuro cercano en mis estudios, ya que es una herramienta muy completa a la cual se le puede sacar mucho provecho.

Link de descargar OFICIAL Scilab: Descargar Scilab

# WSQ12 – 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 GitHub: WSQ12 – Word Count

# Quiz #7

## PRODUCTO ESCALAR

“El producto escalar y el producto vectorial son las dos formas de multiplicar vectores que vemos en la mayoría de las aplicaciones de Física y Astronomía. El producto escalar de dos vectores se puede construir, tomando la componente de un vector en la dirección del otro vector y multiplicandola por la magnitud del otro vector”

http://hyperphysics.phy-astr.gsu.edu/hbasees/vsca.html

Este programa trata de poder calcular escalares, el producto punto o producto escalar consiste en la multiplicación de vectores para dar resultado un escalar, precisamente esto es lo que realizamos en este programa.

Hay 2 listas de números, la primera lista se trata de las componentes en “x” de los vectores, y la segunda lista se trata de las componentes en “y” de los vectores.

La función de este programa dentro del código se llama dot_product. El tamaño de los vectores tienen que ser del mismo tamaño.

# WSQ13 – Exam 2nd Partial

El propósito de este post, es publicar los enlaces de los códigos realizados en el examen del segundo parcial de esta materia.

## Programa 1

Write a function called triangles which receives a single parameter (int) which represents the size of a triangle as explained below. The function should print a triangle using loops (for or while). The only characters printed here are ‘T’ and the new-line character. The first line is length one, the middle line is length size and the last line is length one. The example below is for size 6.

Link GitHub: Exam 2 – Prog 1

## Programa 2

Write a function called superpower that has two parameters of type long and returns a long which is first parameter raised to the power of the second, which is to say it returns a b So, superpower(3,4) would return 81. long superpower(long a, long b){

}

Link GitHub: Exam 2 – Prog 2

## Programa 3

NOTE: for full 5 points, use a loop (not recursion). Write a function called fibonacci which receives a long “n” and returns a long which is the value of the nth number in the fibonacci series which is: 0,1,1,2,3,5,8,13,21,34,55,89………… So, fibonacci(0) would return 0. fibonacci(5) would return 5, fibonacci(8) would return 21. Note that the first two fibonacci numbers are 0 and 1. All others are the sum of the previous two fibonacci numbers.

Link GitHub: Exam 2 – Prog 3

## Programa 4

Write a function called isPalindrome which receives a string “x” and returns true if the string x is a palindrome, otherwise false.

Link GitHub: Exam 2 – Prog 4