Quiz 5

Hey there, I am finally uploading all the Quiz, here I leave you the explanation for each one of the 2 problems of the Quiz 5 and how I solve it.

Part 1:

The part one of the Quiz was a little bit like the #YoSoy196 but it was a little bit different because for flipping the word I look on the internet for a different method because the one I use on the program that look for Lychrel numbers it uses a function to flip number using mod, but this time it was completely different, but in the process of checking it was the same as the #YoSoy196.

Here is what our teacher asked for:

  • Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).

You can check the hall assignment on this link: http://kenscourses.com/tc101winter2016/2016/03/quiz-05/

Here is the link for the program: https://gist.github.com/batmantec/24c127e27fef36fed4d21c167b529ec5

Here is the pictures of the program running:

Quiz5-1

Part 2:

For the part 2 it was somehow easier for me to get it done, because I didn’t need to look on the internet  for doing it. I just recall some knowledge that I had before it from other programs.

Here is what our teacher asked for:

  • Create a function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors,
    Quiz5-2

    Continue reading “Quiz 5”

QUIZ#5, Palindromos ydivisiones de numeros multiplos de 3

quiz5
EJERCICIO NO.1 DEL QUIZ: se trata de hacer palindromos, trata de hacer un programa, donde al escribir cualquier palabra pueda decirnos si esta se lee de la misma forma al derecho y al revéz, lo cual quiere decir que una palabra palindroma, es aquella que la lees de izquiera a derecha y se lee de una manera y al leerla de derecha a izquierda, se lle exactamente igual
compilequiz5
la palaba arroz, no es palindroma. como bien lo dice el programa.
compilequiz55
Como podemos ver la palabra oso si es palindroma, pues se lee igual de derecha a izquierda, que al revés.
quiz5ej2
Este programa. nos sirve para dar una cantidad de números (especificandolos) y desués solo se sumarán los que sean múltiplos de 3 y te dará un total.

compilequiz5ej2

CÓDIGO 1.

#include <iostream>
using namespace std;
bool palindrome(string word){
int c=1;
string invert=string(word.rbegin(), word.rend());
int z=word.size();
for(int i=0; i<z; i=i+1){
if (word[i]==invert[i]) {
return true; }
else {
return false; }
return 0; } }
int main(){
string word;
cout<<“This program calculate if a single word is a palondrome or not”;
cout<<“Give the word to prove if its a palindrome or not”<<endl;
cin>>word;
if(palindrome(word)==false) {
cout<<word<<” “<<“Its NOT palindrome”<<endl; }
else{
cout<<word<<” “<<“It´s a Palindrome”<<endl; }
return 0;
}

CÓDIGO 2.

#include <iostream>
using namespace std;

int threesAdd(int range[], int numOfNum) {
int total=0;
int divi=0;
int val;
for(int i=0; i<numOfNum; i=i+1){
val=range[i];
if(val%3==0){
cout<<val<<” “<<“Is divisible so it goes to the addition”<<endl;
divi=divi+1;
total=total+val;}
else { } }
cout<<“The total divisble numbers:”<<” “<<divi<<” “;
return total; }

int main() {
int values;
cout<<“This program evaluates a range of numbers and make a total addition”<<endl;
cout<<“But it only add the ones which are divisibles by 3″<<endl;
cout<<“How many values you will type?”<<” “;
cin>>values;
int range[values];
for(int

Continue reading “QUIZ#5, Palindromos ydivisiones de numeros multiplos de 3”

Neil, an Alien #Quiz5

Este Quiz en especial fue uno de los más divertidos ya que encontré una imagen en Google me dio muchísima ternura y es la siguiente:

714e13b6-07eb-4ff2-9311-7cb8db52dd88

Cásate conmigo, Internet.

Si soy honesto, este Quiz me dió un poco de batalla, es decir… No fui capaz de resolverlo en clase y tuve que recurrir a la pagina de StackOverflow por enésima vez en el curso, pero al final de todo creo que fue la mejor idea que se me pudo haber ocurrido. Y mi código quedó de la siguiente manera:


# ------------------- Primera parte del código -------------------

def is_palindrome(word):
 mi = word.lower()
 temp = mi.replace(' ', '')
 if temp == temp[::-1]:
 print("¡Esta palabra es un palíndromo!")
 else:
 print("Lo sentimos, esto no es un palíndromo :(")

is_palindrome(word=str(input("Introduce una palabra para revisar si es un palíndromo o no: ")))

# ------------------- Segunda parte del código -------------------

lista_cool = int(input("Ingresa datos a esta lista (<=0 para terminar): "))
ins = []
while lista_cool > 0:
ins.append(lista_cool)
lista_cool = int(input("Ingresa datos a esta lista (<=0 para terminar): "))

print("Esta es la lista con los datos que introdujiste: ", ins)


def find_threes(x):
div = []
for i in x:
if i % 3 == 0:
div.append(i)
sum = 0
for i in range(0, len(div)):
sum = sum + div[i]
print("Estos son los números divisibles entre 3 de tu lista: ", div)
print("Y esta es la suma los numeros divisibles entre 3: ", sum)

find_threes(ins)

Aquí esta, como siempre, mi código en Github, dénse.

cara_enojada_emoji_pegatina_redonda-r064e88c660674edd9cc4110375f13d6d_v9waf_8byvr_324

Hey Ken, quiero mis puntos extra.

Quiz 5

Hello everyone! Quiz 5 has 2 really fun exercises to develop,  here is the description:

  1. Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).
  2. Create a function called find_threes that receives as a parameter a list of numbers and returns the sum of all numbers in that list that are evenly divisible by 3.  So if the list was [0,4,2,6,9,8,3,12], the function would return 30 (0+6+9+3+12)

Exercise 1

Here’s the first code. Don’t freak out, I’ll explain each line.

quiz501

First, we define the function. Remember that capital letters shouldn’t be considered, so we convert all the letters to lowercase. I got the advice of how to do this here.

Then, in line 4, we reverse the string. stackoverflow might help you out with this step.

Then an ‘if’ and an ‘else’ clause are inserted, because we need to compare if the string is equal to the reversed one, and determine if it’s a palindrome or not.

The rest is a piece of cake. We need an input (line 10) to ask the user for the string and we print the function.

Now let’s try the code. quiz502

GIVE ME 5, it worked.

 

Exercise 2

This code is really easy. Let’s develop it fast and efficiently.

quiz6

I’m creating a list so I can save every number divisible by 3 in that list. This list will be used in line 12, where our function called ‘find_threes’ will do it’s work.

In line 2, we have

quiz61

Continue reading “Quiz 5”

Quiz 5 (._.)/

Photograpch Credit

Hello guys, this blog is for the two functions we had to make in quiz five. The second function is really easy so I won’t explain much in the video. The first one was a little harder but not that much. We had to use something called the ascii table. Basicly we know that computers only understand binary. So in the end every character has a number and if we add or subtract to that number then we get a different character. I’ll explain how to use this to ignore case sensitive in our program.Screen Shot 2016-03-11 at 1.05.31 AM

Alright so here is the code:

Palindrome.cpp

FindThrees.cpp

Here is the tutorial for the first function of the quiz: Palindrome.

And here is the tutorial for the second function of the quiz: FindThrees.cpp

Made by Orlando Lara

Another one? Yes 💀

Quiz 05 was about

  1. Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).

 

Captura de pantalla 2016-04-07 a las 8.35.02 p.m.

 

2. Create a function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors, you will need an additional parameter to represent the number of numbers in the array. So if the list was [0,4,2,6,9,8,3,12], the function would return 30 (0+6+9+3+12)

Captura de pantalla 2016-04-07 a las 8.58.07 p.m.

To do this quiz I had to read my classmates quizzes and asked for help to a friend that already have done this last semester.

Anyway those are the screenshots for each one.

And here are both codes.

 

 

 

Quiz 05

My reaction when trying to find out the correct way to program the second part of this quiz:

gato duda

For this Quiz we had two assignments. In the first  one, we had to make a program that let the user know if the word submited is a palindrome or not. I used the [:: -1] to reflect the complete word and then compare the reflection with the original word. I also used the s.lower, so the program ignores capital letters. However, as a cool feature, I made the program ignore spaces since there exist palindromes with spaces. Such as the famous spanish sentence “Anita lava la tina”.

Here is how it looks, and here is how it looks in my GitHub.

quiz05part1

The next step was to do a program similar to the WSQ10. Create a list were the user submits the numbers and play with those numbers. However, the difference was that the operations would only considerate the numbers that are divisable by 3, no remainder.

(Click here for the GitHub of this part)

Several people did this by let the user submit the list as a string separated by commas. That is why I had the reaction of the picture. Yet, with the help of Arturo Fornes, I managed to make eat simplier since he assisted me by correcting what I had done. Just a simple conditional were if i % 3 = 0 then the program appends that number to a separate list.  Then I print the list to let the user know which ones are going to be used for the sum. Finally, just make a simple sum then print it. Such as this:

quiz05part2

Let’s talk about this 80’s oldie. “Maneater” by Daryl Hall & John Oates. A song I first listened to in Metal Gear

maneater

Continue reading “Quiz 05”

Quiz 5

 

Finally, I switched from CodeBlocks to Cygwin and Notepad++.

For this quiz, we were required to make two programs. One had to verify if a word was a palindrome or not, and the other had to make the summatory  of all the numbers evenly divisible by three, from a list of numbers provided by the user.

The second problem was way easier for me than the first one, since I had never used strings in my life. After doing some research on strings, I tried my first version, which did not work. Today, Salvador Ibarra´s blog was updated with a really helpful video on the subject, in Spanish. Also, his code on github helped me a lot. So basically, thank you Salvador, I owe you one.

But the thing is not only to copy, but to understand, so here I´ll explain you my version of the palindrome program.

First of all, a palindrome is a word or a number that can be read normally or backwards and yoy get the same word. For example Anna, read it backward and it is the same word. 111 is a palindrome number.

In order to make a program to capable of deciding if a word is a palindrome or not, I had to use strings in C++. I made four strings and a string function.  Two were really important, string palabra and string backwards. On string palabra the program stores the word provided by the user, and on string backwards it stores it backwards.

The process made to store the word backwards was done with a for loop. The parameter to continue the for loop was the length of the string palabra, which I stored on an integer variable called largo. To get that value, you just write the name of the

for loop

Continue reading “Quiz 5”