CS 1160 C/C++ Programming 12 MWF - Spring 2016

April 11th thru April 15th - Week #13 Square root day thru Power day


Monday 04/11/2016


  1. Program wordPerLine.cpp that outputs the first line of the file with the snowball sentence. Prints one word per line.
    The output is:
    jacobson[weblab]:~/web/cpp$ cat snowOutput.txt 
    jacobson[weblab]:~$ ./a.out
    
    I                      1
    do                     4
    not                    8
    know                  13
    where                 19
    family                26
    doctors               34
    acquired              43
    illegibly             53
    perplexing            64
    handwriting;          77
                          -1
    
    I do not know where family doctors acquired illegibly perplexing handwriting; 
    
    I do not know where family doctors acquired illegibly perplexing handwriting; 
    012345678901234567890123456789012345678901234567890123456789012345678901234567          
    1         2         3         4         5         6         7
    
    snowOutput.txt
  2. ... Did you get the two handouts? Study them! They are used for Wednesday's group exercise too. How to read an entire file into one string variable and get the words, one by one is illustrated.


Wednesday 4/13/2016


  1. ASSIGNMENT - GROUP EXERCISE: cppExercise4132016.pdf is the handout from todya's class, with an additional page added to it.
    ASSIGNMENT - paper/pen/pencil - one page required at START of FRIDAY class.
    Bring your work on this problem to class on Friday 
               and we will continue the group exercise
               in the same groups:  
    
    We had 4 groups of 4 students in each group with 16 students in class today.
    
    One side of one sheet of paper is the minimum.
    
    Develop your understanding of hte problem.  
    
        You can write C++ code attempts, 
    
        you can write and discuss example code that might be applicable,
    
        you can draw pictures of the input and output, 
    
        you can express confusion, ask questions,
    
        show your understand the problem work,
    
        show your develop a PLAN in pseudocode work,
    
        show your try to trace and understand a code segment work to verify
             that it works or why it runs into problems, or to develop the code,
             or debug it, etc.
    
        Just do at least one page to turn in or show the instructor at the beginning of class,
    so you have something to help the group or get help from the group with.
    
        If this problem is a cinch for you, then carefully work out how to explain it to someone
    with much less experience than you have.  There are NO PREREQUISITES for this class.
    
        You want everyone on your team to understand this as deeply as possible and grow from it.
    
        You are preparing as a team of four for a competition where the game show host randomly
    picks anyone from your group to ask a question or develop a similar tiny code segment
    to what this problem involves.   So the team needs to have every member with as strong
    a possible understanding.
    
        If you got something about the code then it is your responsibility to make sure
    everyone else understands that something at a higher level.  Ironically, in helping them
    do that, you develop more skill, understanding and speed with the same thing.
    
        If you don't understand something or could be clearer or are unceretain, it is your
    responsibility and to your teams advantage for you to communicate that.
    
        Teamwork is vip.  The team requires every member be able to carry out any task and
    answer any question.
    
    
  2. Do some VET and use the 3 step problem solving process and RESIST THE URGE TO CODE!
    The VET who SAT down to watch AUC (All U Children) on TVV, 
      SO what if this was at the YMDC (i.e., the YMCA in Washington, DC) 
      where the Gulf War or Vietnam Vet was staying.  
    
      VET-SAT-AUC, TVV-SO-YMDC is the string of the first letters 
      from a quote by Dijkstra.
      
    Programming, when stripped of all the circumstantial irrelevancies 
      is nothing more and nothing less than "very effective thinking 
      so as to avoid unmastered complexity, to very vigorous 
      separation of your many different concerns".
    
    very effective thinking so as to avoid unmastered complexity,
    v    e         t        s  a  t  a     u          c          = vet sat auc
    vet                     sat      auc
    VET                     SAT      AUC
    
    to very vigorous separation of your many different concerns.
    t  v    v        s          o  y    m    d         c         = tvv so ymdc
    tvv              so            ymdc
    TVV              SO            YMDC
    
  3. The two main concerns of programming are WHAT you wanna do and HOW you are going to do it.

    YMDC becomes YTDC, i.e. Your Two Different Concerns... or perhaps
    YTMC, i.e. Your Two Main Concerns. Very Vigorously Separate YTMC!

    YTCC has a nice poetic sound Y T C C - Your Two Chief Concerns...


Friday 4/15/2016

  1. SASP = Solve A Simpler Problem
    jacobson[weblab]:~/web/cpp$ g++ wordsSASP1.cpp 
    jacobson[weblab]:~/web/cpp$ ./a.out
                   1             3             5             7             9
                  0             2             4             6             8
                  11            13            15            17            19
                 10            12            14            16            18
                  21            23            25            27            29
                 20            22            24            26            28
                  31            33            35            37            39
                 30            32            34            36            38
                  41            43            45            47            49
                 40            42            44            46            48
    
  2. The SIMPLER PROBLEM for SASP was just to see if I could write the C++ code after developing the algorithm for printing out what would be the index values for the array of strings, the array of the words read in from the file. SASP.
    jacobson[weblab]:~/web/cpp$ ./a.out
    How much offset difference is desired: 0
    
                  1             3             5             7             9
                  0             2             4             6             8
                 11            13            15            17            19
                 10            12            14            16            18
                 21            23            25            27            29
                 20            22            24            26            28
                 31            33            35            37            39
                 30            32            34            36            38
                 41            43            45            47            49
                 40            42            44            46            48
    jacobson[weblab]:~/web/cpp$ ./a.out
    How much offset difference is desired: 4
    
                      1             3             5             7             9
                  0             2             4             6             8
                     11            13            15            17            19
                 10            12            14            16            18
                     21            23            25            27            29
                 20            22            24            26            28
                     31            33            35            37            39
                 30            32            34            36            38
                     41            43            45            47            49
                 40            42            44            46            48
    
  3. Here is the solved problem that outputs the words read in from the input file. I created a file with 50 different words. Some of the snowball sentence words are too long, so they had to stop at the 13th word!

    415wordsOut.txt...

    How many spaces do you want? 1
    
                    do            know          family        acquired      perplexing
                    I             not           where         doctors       illegibly
    
          nevertheless        pharmacy      University        Northern             UNI
          handwriting   extraordinary    intellectual              of            Iowa
    
             balancing      philosophy         science         Whitman         Hendrix
              counter    decipherable        computer            Walt            Jimi
    
                 Keith           piano       transcend        Humility           green
            community         Jarrett          guitar         BICTION          tennis
    
                   TWO            FOUR             SIX           EIGHT             TEN
                  ONE           THREE            FIVE           SEVEN            NINE