I've been pretty busy with life lately, haven't been able to pay as much attention to this kind of stuff as I would have liked.
Long story short, I took too many credits. Pretty sure I failed the math class I needed to get into the next class (no worries, there's a way around it that involves the exact same amount of work and will probably end up being easier on me).
I did give up on the long addition program after making a little more headway. Turns out that the end of line marker flipped out when the string was full, so I needed to call the skip_line function. That was all I got before giving up on it though, because the next project was much more difficult. The final project of the class was to read in an external file containing a partially completed Sudoku puzzle and solve it with algorithms.
Sounds fun, but I couldn't even read in the external file and so Me => Not turning it in. I skipped the study sessions because I wanted to get it by myself. A bad idea in retrospect and hopefully it doesn't drop my grade so low I can't move on. That would be discouraging enough to have to drop CS as a major (which doesn't leave me with a whole lot of options incidentally).
Oh well though. Somehow I don't think a 10-week course on a new (and basically first) programming language can cover enough about file i/o and multidimensional arrays (and the manipulation thereof) well enough to solve this problem. The study guides I skipped out on were provided by a student who probably wasn't new to programming (or Ada) so I am confident that without his help at least 50% of the class is with me. Still kicking myself for skipping, but oh well.
Next quarter will be much more focused for me: one math class and two CS classes (computer organization and programming II (with more Ada)). Basically this just means I won't have to write a paper all quarter. Fucking awesome.
In other news, I downloaded Visual Studio 2008 from the CS MSDN and I plan to finish my "Learn Visual C# in 24 Hours" book over Winter break. I'm only a chapter in but I can already tell that if I (God willing) stick with this, I'll learn a lot about the .NET framework and object-oriented programming. Plus it's a C derivative, which should be fun.
That's it for now, just keeping my fingers crossed for my final grades.
Showing posts with label CSCI. Show all posts
Showing posts with label CSCI. Show all posts
Thursday, December 13, 2007
Sunday, November 18, 2007
Giving Up
Wow, I've really hit a wall on this one. Assignment's due tomorrow at 5 pm so unless I can get an answer from the professor or TA, I'm shit outta luck.
The assignment is called "Long Integer Addition" and the idea is to take two numbers (up to but not exceeding 30 digits) and add them together. Things to keep in mind:
-The "long integers" are not numeric data types (they are too long to be represented on 32 (or 64) bit machines). They are strings. What the fuck.
-Ada is very strongly typed, meaning casting (conversion) can't be done from integer to string. VB6's CInt and CStr will not work here.
-How do you add two values from a string literal and come up with their sum? You don't.
Well it would be nice if I could get far enough to do that, but I can't even get the basic input to go through. It'll take the first variable just fine, but freaks out when it comes to deux. Code:
Ada.Text_IO.Put(Item => "Enter a nonnegative long integer(30 digits maximum) >");
Ada.Text_IO.New_Line;
Ada.Text_IO.Get_Line(Item => X, Last => StrLenX);
Ada.Integer_Text_IO.Put(Item => StrLenX);
Ada.Text_IO.New_Line(2);
FOR Idx IN REVERSE 1 .. StrLenX LOOP
ArrayX(Idx) := X(Idx);
END LOOP;
That seems to work just fine. X is a 30-character length string and StrLenX is the length of the string. The For..Next loop at the bottom assigns the contents of the string to an array holding characters '0' through '9', the idea being that since each character will be stored as such in the string X, nothing outside that range will ever need to be represented.
A conditional would catch when the sum was over 9 and would carry the one, but I never got far enough to be concerned with that.
That first block works fine, but an identical block below it to correspond to Y variables (all declared as used obviously, the compiler would never let me get away with something stupid like that). It raises a data error when it goes to get string Y, which means that somewhere the data types are being misrepresented or mismatched through some bizarre and presently incomprehensible means.
That's all OK though, I don't know how to do this without casting the characters to integers and back.
The assignment is called "Long Integer Addition" and the idea is to take two numbers (up to but not exceeding 30 digits) and add them together. Things to keep in mind:
-The "long integers" are not numeric data types (they are too long to be represented on 32 (or 64) bit machines). They are strings. What the fuck.
-Ada is very strongly typed, meaning casting (conversion) can't be done from integer to string. VB6's CInt and CStr will not work here.
-How do you add two values from a string literal and come up with their sum? You don't.
Well it would be nice if I could get far enough to do that, but I can't even get the basic input to go through. It'll take the first variable just fine, but freaks out when it comes to deux. Code:
Ada.Text_IO.Put(Item => "Enter a nonnegative long integer(30 digits maximum) >");
Ada.Text_IO.New_Line;
Ada.Text_IO.Get_Line(Item => X, Last => StrLenX);
Ada.Integer_Text_IO.Put(Item => StrLenX);
Ada.Text_IO.New_Line(2);
FOR Idx IN REVERSE 1 .. StrLenX LOOP
ArrayX(Idx) := X(Idx);
END LOOP;
That seems to work just fine. X is a 30-character length string and StrLenX is the length of the string. The For..Next loop at the bottom assigns the contents of the string to an array holding characters '0' through '9', the idea being that since each character will be stored as such in the string X, nothing outside that range will ever need to be represented.
A conditional would catch when the sum was over 9 and would carry the one, but I never got far enough to be concerned with that.
That first block works fine, but an identical block below it to correspond to Y variables (all declared as used obviously, the compiler would never let me get away with something stupid like that). It raises a data error when it goes to get string Y, which means that somewhere the data types are being misrepresented or mismatched through some bizarre and presently incomprehensible means.
That's all OK though, I don't know how to do this without casting the characters to integers and back.
Saturday, October 6, 2007
More Ada and Nerdery
So I had my first lab on Friday, and it turns out I'm the biggest nerd in my computer science class.
I don't have acne, I don't watch Battlestar Galactica, I don't play Halo, and I didn't know the name of the creepy laughing monster in Jabba's palace in Return of the Jedi (Salacious Crumb) until my sister told me.
But somehow it's true. I actually stayed in the lab after everyone had left, just so I could do my homework. I even came back after my next class to finish up. The TA had to remind me several times that I had finished the classwork and could leave whenever I wanted.
It was kind of an embarrassing revelation, but I had a problem I just had to figure out. And I still couldn't. Not to brag, but if I couldn't figure out how to screw around with the enumerated values and the TA didn't know how to help me, I think the rest of that class is fucked.
Right now I am working on two problems, one of which takes the colors of resistor bands (which, sadly, I have almost committed to memory) and converts them into ohms. The problem is taking three separate variables and concatenating them to become one number (e.g. 4,3, and 6 needs to become 436). This may not sound very hard, but it's kind of a daunting task*. The second needs to take a date and calculate what day of the week it will fall on, which is really just a formatting problem since we were given the linear algorithm (no loops, conditions, or arrays) to solve the problem.
God damned Ada, so picky and typesafe.
*As I typed this, I realized that if I could cast (convert) a string type to type integer/natural, I might have more luck. It won't work, but it's reassuring to know that I can come up with creative solutions that had not occurred to me.
I don't have acne, I don't watch Battlestar Galactica, I don't play Halo, and I didn't know the name of the creepy laughing monster in Jabba's palace in Return of the Jedi (Salacious Crumb) until my sister told me.
But somehow it's true. I actually stayed in the lab after everyone had left, just so I could do my homework. I even came back after my next class to finish up. The TA had to remind me several times that I had finished the classwork and could leave whenever I wanted.
It was kind of an embarrassing revelation, but I had a problem I just had to figure out. And I still couldn't. Not to brag, but if I couldn't figure out how to screw around with the enumerated values and the TA didn't know how to help me, I think the rest of that class is fucked.
Right now I am working on two problems, one of which takes the colors of resistor bands (which, sadly, I have almost committed to memory) and converts them into ohms. The problem is taking three separate variables and concatenating them to become one number (e.g. 4,3, and 6 needs to become 436). This may not sound very hard, but it's kind of a daunting task*. The second needs to take a date and calculate what day of the week it will fall on, which is really just a formatting problem since we were given the linear algorithm (no loops, conditions, or arrays) to solve the problem.
God damned Ada, so picky and typesafe.
*As I typed this, I realized that if I could cast (convert) a string type to type integer/natural, I might have more luck. It won't work, but it's reassuring to know that I can come up with creative solutions that had not occurred to me.
Friday, September 28, 2007
Ada
All right, while I was sitting in class today I wrote my first Ada program on paper and compiled it when I got back to my dorm. Pretty simple (and obnoxious), but I think I've got the formatting/syntax down, at least for text I/O.
WITH Ada.Text_IO;
PROCEDURE Hello IS
Name : String(1..4);
BEGIN --Hello
Ada.Text_IO.Put(Item => "Enter your name:");
Ada.Text_IO.Get(Item => Name);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item => "Hello, ");
Ada.Text_IO.Put(Item => Name);
Ada.Text_IO.Put(Item => "!");
END Hello;
This program, of course, takes a name and greets them. At least, only if the user has a four-letter name. This of course means that I'll need to dynamically allocate the contents of the array in memory.
Edit: I like how that last sentence really makes it obvious that English is not my first language. Which it is.
WITH Ada.Text_IO;
PROCEDURE Hello IS
Name : String(1..4);
BEGIN --Hello
Ada.Text_IO.Put(Item => "Enter your name:");
Ada.Text_IO.Get(Item => Name);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item => "Hello, ");
Ada.Text_IO.Put(Item => Name);
Ada.Text_IO.Put(Item => "!");
END Hello;
This program, of course, takes a name and greets them. At least, only if the user has a four-letter name. This of course means that I'll need to dynamically allocate the contents of the array in memory.
Edit: I like how that last sentence really makes it obvious that English is not my first language. Which it is.
Wednesday, September 19, 2007
CSCI 141
I really thought I'd update this more often, but I really haven't done anything lately.
At all.
Anyway, I'm finally on my way to becoming a CSCI major since I emailed the professor and pleaded with him to drop the math prereq for the class I wanted (which is bullshit anyway, I've taken enough math to get in a calc class). The condition is that I have to go to every lecture and lab, but I kinda had my heart set on that anyway.
The class uses Ada95 to teach the basic concepts of OOP programming. I'm not too thrilled about having a new language crammed down my throat in a ten-week course, but I do feel ready for it. Apparently they used to use C++ for the class, but I think it was probably too sink or swim for the majority of students.
I'm just hoping I don't get a bunch of people in my class who think CSCI is for them because they're good at the Internet. I hear stories about people failing CSCI classes all the time, and I'm hoping that's the reason why.
I don't really know what I would do if I couldn't make it through, so let's hope this works out.
At all.
Anyway, I'm finally on my way to becoming a CSCI major since I emailed the professor and pleaded with him to drop the math prereq for the class I wanted (which is bullshit anyway, I've taken enough math to get in a calc class). The condition is that I have to go to every lecture and lab, but I kinda had my heart set on that anyway.
The class uses Ada95 to teach the basic concepts of OOP programming. I'm not too thrilled about having a new language crammed down my throat in a ten-week course, but I do feel ready for it. Apparently they used to use C++ for the class, but I think it was probably too sink or swim for the majority of students.
I'm just hoping I don't get a bunch of people in my class who think CSCI is for them because they're good at the Internet. I hear stories about people failing CSCI classes all the time, and I'm hoping that's the reason why.
I don't really know what I would do if I couldn't make it through, so let's hope this works out.
Subscribe to:
Posts (Atom)