User Tools

Site Tools


blog:spring2016:btaylo15:journal

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
blog:spring2016:btaylo15:journal [2016/03/08 01:38] btaylo15blog:spring2016:btaylo15:journal [2016/04/21 03:37] (current) btaylo15
Line 18: Line 18:
  
 ==== March 7, 2016 ==== ==== March 7, 2016 ====
-All I can say is that it is a big relief to not have to optimize every little thing in this week's program. After going a little overboard on the prime number project and winning, it feels nice to be able to take it easy on a project, but that doesn't mean I didn't do it the first day it was due. Since I did the multiply by eleven’s project like the first or second week using loops and arrays, redoing it to fit the specifications wasn’t hard. I had to change my math a bit to accommodate carries, but that wasn’t hard either after doing a binary calculator in problem solving. I made sure to accommodate the times that the final iteration has a carry, like 999 times 11. I think at this point I’m ready for the next project.+All I can say is that it is a big relief to not have to optimize every little thing in this week's program. After going a little overboard on the prime number project and winning, it feels nice to be able to take it easy on a project, but that doesn't mean I didn't do it the first day it was due. Since I did the multiply by eleven’s project like the first or second week using loops and arrays, redoing it to fit the specifications wasn’t hard. I had to change my math a bit to accommodate carries, but that wasn’t hard either after doing a binary calculator in problem solving. I made sure to accommodate the times that the final iteration has a carry, like 999 times 11. I think at this point I’m ready for the next project.\\ 
 + 
 +==== March 14, 2016 ==== 
 +This project was pretty fun. I learned about this project early as well, so I had a plan going in to it. Probably for the first and possibly last time I will ever use math outside of a math class, I harkened back to Pre-Calc (from high school and last semester) and remembered that the X,Y coordinates of points on a circle can be found using ( radius * cos(theta) ) and ( radius * sin(theta) ). By incrementing the angle, theta, and drawing the points, you can make a circle out of squares. By drawing more circles with different radii, you can draw concentric circles. By changing the radius while drawing a circle, you can draw spirals. I also was looking into a way to have these PNG files viewable in the terminal, which led me to explore PNM’s and libcaca. The version of libcaca I had only supported BMP files, so I wrote a bash script to convert PNG’s to PNM’s, then the PNM’s to BMP’s that can be viewed. Ascii-art has always been an interest of mine, so a way to put it to use was fun.\\ 
 + 
 +==== March 22, 2016 ==== 
 +Inputting a string and then shifting the letters to make it a secret message was a cool project to do. Loading from a file will be useful for many situations in the future. Changing how the program runs based on its compiled name was interesting. I learned about a lot of useful string functions (strtok, strlen and strcmp), and learning about function prototypes will be immensely helpful in the future. Probably the biggest help for me was the understanding of chars, that they are actually just a smaller type of integer unless called specifically using its value as an ASCII code. We had to write our own atoi function to read a number from a string from a file. For fun, I looked up how to color the output of the program, but I removed that at the end so that piping and such would work fluidly with the program. At first, I was shifting all characters with ASCII codes 32 through 126, so that symbols would work and the message was shifted using the ASCII table. However, what I needed to do was only shift letters, so I shifted uppercase letters in the uppercase range and lowercase in the lowercase range, leaving spaces and symbols alone so that the form of the message was intact.\\ 
 + 
 +==== April 4, 2016 ==== 
 +Making a hex viewer? No problem. Coloring in the lines? Problem. By using an array to temporarily store consecutive sets of 16 bytes from a file, and using the hexadecimal format specifiers, creating a program to open a file and display its contents in hexadecimal and ASCII was easy. I used code from previous projects to open the file and fgetc its contents. The hardest part of the main project was detecting EOF at the right time. To do this, I put the section for storing the data into the temporary array first in the “for” loop, and if feof was detected, a flag was set and the position of the last character in the file was set. Then I print the offset, hex and ASCII values. Then there’s adding color. I was able to figure out how to correctly store 6 pairs of extra arguments to be used as highlighted sections, but actually implementing it was difficult. By the end, for some reason, my program only correctly highlights when 4 or fewer pairs of arguments are present, any more than that and the program displays incorrectly. It also can only do 2 highlighted sections per line, cannot wrap around lines, and the start positions of the highlights have to be in ascending order. Basically, I’m content with just a plain hex viewer.\\ 
 + 
 +==== April 13, 2016 ==== 
 +This was a relatively easy week for me, since I did this project weeks in advance because I got bored. The project was to subtract any number from the power of ten with one more digit than the input number. You can easily do this by subtracting each number left to right by 9, then the last by 10. I got it working easily, however, upon further testing I found a very specific bug. Whenever the program did 10 – 0, it returned a 10 of course, but this means that 1000 – 100 = 8100, or 8 10 0. I fixed this by looping back through the result array and fixing the carries. Going back to mental math programs was a nice break and refresher on certain parts of code.\\ 
 + 
 +==== April 20, 2016 ==== 
 +This week’s project was pretty fun. We used the flattenstatus command to get our grade data and then display it in a readable way. For me, my grade in this class is about a 113/100 because of all the bonus I did, so that’s nice. I learned a bit about floats for this project, since I wanted to have the option of decimals instead of truncating every number into int form, and it was necessary for dividing my accumulated points by the total possible points. This project, at least the part where you read data with what are basically headers separating the sections, reminds me of my personal project I’ve been working on, Secret Picture Messages (spm0). My program encodes 24-bit bitmaps with a secret message, and the picture looks no different to the original. Anyway, I’m already thinking about how to solve the EOCE projects and I’m excited to try my ideas.
blog/spring2016/btaylo15/journal.1457401135.txt.gz · Last modified: 2016/03/08 01:38 by btaylo15