Tuesday, February 28, 2012

Lab Assignment Feb 28

Assignment:

Using the code we started in lab, alter the method we used to resize the canvas so that a canvas inherits its size from its parent (i.e. the dimensions are not hardcoded and the canvas can easily fill its container (div) )

Test this by creating two canvas elements with different widths.

Tuesday, February 21, 2012

Challenge 2/21/2012

Part 1

- 10 equations that do not pass but should for your calculator
- why does each test case fail? What should be considered?

Interpretation of first question: Submit equations that don't work on my calculator but should.

My calculator has issues with ',' and unary operators at present, but assuming that those were working correctly, equations with the following characteristics would not correctly evaluate:

+equations that use numbers with floating point precision (1.2 + 3.4)
           ex. it would split 1.2 into 1, . , and 2
+equations with multiple unary operators (---)
           --9+ ---3
+equations with operations that are more than one character
           ++. --. etc
+equations lacking correctly paired ()s
           maybe "shouldn't" work anyway, but it would be nice to deal with that somehow... perhaps infer where one should go?
+ not sure if functions within functions would work on mine
  sin(cos(sin(...cos(3.14+.... etc.))))
+ operators that take more than 2 inputs don't work yet
  old version (not rewrite) had only left and right nodes. Would require 3 prong node, but maybe a vector of pointers could be used to later add number of children with ease

Part II is inaccessible to me at this time...

Other equations that won't work on MyCalc -
(simply because I'm still not there yet)
use of user-added functions

I expect issues with the following:
user functions that contain the names of actual functions within them (ex: sinuserdef() )



Assignment for Thursday:


//Equations to use for testing : 
//GRACEFUL FAIL?
10 (+) 8 (*) 2 (+) 8
10 ()+ 8 * 2 + 8
(10 + 8 * 2 + 8
10) + 8 * 2 + 8

//FAILING FUNCTIONS
sin(45,8) 
sin(45,,)
sin45
(sin)45 

//PARENS ANYWHERE?
(10 + 8) * 2 + 8
(10) + (8) * (2) + (8)
(((10 + 8) * 2) + 8)

//UNARY OPERATORS
-(10) + 8 * 2 + 8
--10 +  8 * 2 + 8
---10 + 8*2+8
-(-(-(10))) + 8*2+8

Lab ScratchNotes- Feb 21 2012

Fermat
Polytope
Dirichlet's_theorem

Java's Big Decimal... c++ equiv?
      http://gmplib.org/ Perhaps?

Sacrificing time for precision
    Really a sacrifice? quick (matter of clk cycles), so 300x slower not bad

Composite Design Pattern brought up - NOT good for this assignment.

Lexicon and Parser Setup

Thursday, February 16, 2012

Lecture 2/16/2012 and Pre-Challenge 4.2.2

Current functionality of the current re-write ( ...3? ...4? treeAlg_v7) allows for tokenizing the equations.


Infinity and Div by 0

    C++ gives inf :

#include<iostream>
int main (int argc, char** argv)
{
  float answer = 1/0.f;
  std::cout << "1/0f gives " << answer << std::endl;
}

 
OUTPUT : 
1/0f gives inf

Regular Expressions
    \d+ <--find one or more digit 0-9 and any following digits
   \d* <-- permits 0 or more
   ( ) <-- catch, save for later not just match

....useful for tokenizing the string.... hrrrmmmm I've been doing this manually -_-

Thursday, February 9, 2012

Rounds of Focus

Here is my version of the TODO lists requested on svn. I found it easier (perhaps less embarrassing?) to keep track of these on my own google site, but I will migrate to svn. For the sake of having accessible documentation, here are the relevant "Rounds" (24 minute minimum sessions of focused work). 

Most have explanations/self-evaluations at the end. 

Testing Calculator

(1-2) * 13/16
(1-2) * (13/16
(pow(1,2))*(13/16)

I expect all errors, because my calculator does not presently handle parenthesis. (First iteration did, but I scrapped that because I thought it was necessary to get operation based tree-construction working first...)

Also, I just realized that I am only handling ints (not floats...)

To get any output, I would have to delete the ()s. For this iteration's sake, here are the results:

Please enter an equation:
1-2*13/16
You entered:
1-2*13/16
NOT base case 1-2*13/16
 Reached base case: 1
NOT base case 2*13/16
 Reached base case: 2
NOT base case 13/16
 Reached base case: 13
 Reached base case: 16
0

Another item I failed to include was "pow." (I understood in lab that the equation would be 'flat,' or linear. Misinterp of requirements, apparently.)

It is painstakingly obvious what is not happening....but ...

Examining what IS "happening" 
AKA what I (erroneously?) THINK is happening:


1-2*13/16

     -  
   /   \
1      *
       /   \
     2     "/"
           /    \
         13    16

1-2*13/16 = 1-1.something --> 0 (because ints truncate)

Traversing the tree (printing out each node as I travel left to right):



LEAF:
1
LEAF:
2
LEAF:
13
LEAF:
16
/
*
-


The fact that LEAF appears before each number is comforting, though I would expect the following:
1
2
13
16
/
*
-

...But that's what I'm getting.... OK- logic error traversing the tree. AArgh.

Wednesday, February 8, 2012

a + ( (b-c) / d ) * e
 
           +
          /     \
      a             * 
                 /         \
              " / "          e
           /       \    
        -          d
    b    c
 

Tuesday, February 7, 2012

Compiled Jibberish

Only one error! ....or so it says...


w00-129-24-253-3:FileIO_Redux smg$ g++ myCode.cpp
myCodePrev.cpp:1: error: expected `}' at end of input
myCodePrev.cpp:1: error: expected unqualified-id at end of input

Technically, it's all one line. Technically, that line is commented out... See?

Extra Credit: 
Adding the notion of start... WIP.

Thursday, February 2, 2012

Feb 2, 2012

TOPICS :
 
   Code Challenge

   Spikes & Tacks
       Where do you start?
              Text file describing process in English :


       PSEUDO CODE EXAMPLE

              {input_words} <- CSV_Read(  text  )
              text <- Jibbers(  {input_words}  )


       Spikes 1 & 2 ---> Hack it (early spikes )
       Spikes 3 & 4 = Rewrites
       
       Tacks - demo ONE "little" feature

   SVN
       Aim for 4 checkouts / hour
       Yes, even broken code (only increment spike number for working code)

//   Coding Standards
//   Nomenclature
//        Eclipse

Wednesday, February 1, 2012

Jibberish....

...should describe the output, not the code. --smg

I have documented my progress in svn text documents, but here's an overview of my versions, decisions, and conclusions thusfar:

history (Assignment 1)...
(will add this later....)
  • Attempt 1 : FileName :         Identifiers : Universe of too many ambiguous classes
  • Attempt 2 :
  • Attempt 3 : 
  • Attempt 4 : FileName :


print (Learned_Lessons ) -extra extra extra verbose
  • Step 1 = Make it work. Iteration 1 - I overthought. I was trying to include elements I did not need. Rather than asking how I could split the actual task into managable pieces, I obsessed over extra features and reusability and efficiency and irrelevant frosting - creature feap. Creature feap before I had even begun. Needless to say, iteration 1 did not work. Did not compile. Did not make sense. Too many ideas. Entangled and messy and before long, I could not even remember the requirements of the original assignment.
  • Step 0 = Plan it out. After strangling myself with iteration 2, I was sick of the 'wait,what-am-I-doing?' confusion that plagued me time and again about 50 lines of code into it. I decided that iteration 3 should be easy. Easy to read, easy to follow, easy to code. There should be no question as to whether I had already coded certain functionality or not. I should know. I needed a guiding map, so I created just that. A text file containing the specs, the intended versions/descriptions, and a section to log current progress.
  • Step 0.0 = Plan it out again. Write pseudo-code. Just do it. Inevitably you will discover faults in your original logic. Change now or forever hold your frustration (at least until the next iteration.) 
  •  Embrace Your One Track Mind. Between compiles, write with ONE goal in mind. I found myself changing the structure of my code while simultaneously trying to add functionality. (Changing from maps to vectors, for instance, while adding the Pick_Next_Word function. No way to tell where you're breaking.)
  • Keep it Simple, Keep it NOW. Go in knowing you are going to iterate. You don't know what Future You will want in the code, so don't out-think yourself. Add functions as they become useful... In fact, ask yourself if they are useful, and specifically if they are useful in the current situation. Example - I went overboard with the idea of printing with functors in Iteration 1 (or 2?). Sure they would be useful... if I were coding a spike or writing a header/library/toolbox. Afterall, did I really need 6 different ways to print a set of words ("just in case")? I don't think so.
  • Be Verbose, Descriptive, and Leave Comments. This is the easiest thing to do and the hardest thing to make yourself do. It's cake if you write pseudo-code beforehand. Comments? Check. Be verbose with variable names and take the time to describe the intended role of each new type as you create it.... or risk finding yourself in a world of god-Awful metaphors ("Okay, so each word has two neighbors, and they live in a list neighborhood, which is inside of a map City, which is part of a giant State object that has a population count and ..." --Right, got the picture? I'll spare you the details... -_-' )