User Tools

Site Tools


haas:fall2019:discrete:projects:eoce

This is an old revision of the document!


Corning Community College

CSCS2330 Discrete Structures

End of Course Experience

EoCE

Rules

Presented within will be various questions evaluating your knowledge and experience gained this semester. In places where you are able, the more you write and explain topics the better the chance you will have of receiving full credit (and alternatively, the more credit you will receive should something defer correctness).

Unless otherwise specified, the questions on this experience are open resource with the exception of other individuals. In that respect, it is CLOSED PERSON. This means you are not to communicate with other people (either in the class or otherwise), in real life or electronically. Use your own knowledge, use your own skills, and use your own ability to access the allowed resources to aid you in coming up with your well thought out responses to each question.

You are allowed, and expected, to seek clarification on any question by asking any of the tutors or me. But the aim here is to evaluate what you have learned, so do not expect tutoring. Any help should be prompted by a well-asked question. Any reply (if possible) from a tutor, should also be in the form of a question.

You are to do all items. Submission is to be as follows:

  • an organized and easy to read presentation of information on your EoCE wiki page.
  • if applicable, a supplemental archive submitted using the submit tool (likely via Makefile)

The EoCE is worth 26 points of your overall grade (projects + participation + journal + eoce = 104), representing a distinct fourth category within the grading policy of the course (Projects, Journal, Participation, and EoCE).

Finals Week Availability

While some classes are allocated a specific meeting time during finals week, I make all such times available should you be free and have questions. As such, finals week in CHM123 will look something like this:

  • Monday, December 9th, 2019: from 02:30pm - 05:30pm
  • Tuesday, December 10th, 2019: from 08:00am - 02:15pm
  • Wednesday, December 11th, 2019: from 02:30pm - 05:30pm

DEADLINE FOR SUBMISSION: You have until 05:29:59pm (that's 17:29:59 in 24-hour time) Wednesday, December 11th, 2019 to complete your EoCE(s). This is the ultimate deadline for any and all coursework. There is no “late”, only “too late”. Don't be that person, not with this.

Good luck!

DISCRETE EoCE

Coding Restrictions

Since a lot of our explorations this semester were algorithmic in nature, we made a lot of use of restricting various approaches we could take in the implementation of our solutions.

As such, the following restrictions are in place for your implementations:

  • no global variables
  • no infinite loops
  • no if() shunts (have good conditions!)
    • what is the difference between an if() shunt and a valid conditional statement? if() shunts are a messy way of avoiding iterations; valid if() statements denote conditionally optional processing that occurs every iteration.
  • one return statement (max) per function
  • exit() calls are limited to command-line or resource allocation error processing
  • avoid redundant sections of code (merge logic, or break out functions)

Remember, the focus should be on writing elegant code, and NOT on brute forcing some solution. Show me that you've learned something this semester- write clean, well commented, consistently indented code.

0x0: Visualizing Long Division

Here we will pursue letter division, essentially a long division where the numbers had been swapped out for letters, and you had to ascertain the appropriate mapping of letter to number.

This problem explores the basis of that puzzle, where you will be writing a program that generates a numeric long division problem (step 1 in a process of writing our own letter division puzzle generator).

Specification

Your program is as much about the values generated as it is the output formatted.

  • Everything goes to STDOUT
  • subtraction signs justified to the left-most digit of the longer value being subtracted (see examples)
  • quotient should not be less than 3 digits
  • divisor should be 3-5 digits long
  • dividend should be 7-9 digits long
  • program runs through to final remainder
  • note the alignment
  • values should be randomly generated
    • seed your random number generator with: srand(time(NULL));
      • you'll want to include time.h to use the time() function

Execution

Your program does not need to accept any arguments, but when run, will produce a numeric visualization of a long division problem (spacing and formatting so everything lines up). A few examples follow:

lab46:~/src/discrete/eoce/0x0$ ./0x0
            3320
      +---------
17382 | 57716687 
       -52146
        =====
         55706
        -52146
         =====
          35608
         -34764
          =====
            8447

Another example:

lab46:~/src/discrete/eoce/0x0$ ./0x0
           11403
      +---------
 6270 | 71498775 
       -6270
        ====
         8798
        -6270
         ====
         25287
        -25080
         =====
           20775
          -18810
           =====
            1965

0x1: Letter-ifying your Long Division

In the previous problem, we were tasked with writing the logic that generates the long division problem, as a first step in our “letter division puzzle” generation.

Here, we perform the next step, and swap out the numbers with randomly chosen letters. You'll also want te display an answer “key” as part of your output.

Ideally, this program can be used to generate new letter division puzzles that you can then enjoy, to your heart's content!

Specifications

Specifications are the same as with 0x0, plus:

  • letters should all be capital
  • no duplication (obviously), one letter maps to exactly one number
  • key should be listed at the very end, following a “LETTERDIVISION:” label. The letters should correspond with the values 0123456789 (in that order).

Execution

A couple examples of desired program output:

lab46:~/src/discrete/eoce/0x1$ ./0x1
           VPWAK
      +---------
  AAV | DZMLLZVK
       -DDKV
        ====
         KLKL
        -KZVV
         ====
           LKZV
          -LWAW
           ====
            IAVK
           -ILLW
            ====
              AK

LETTERDIVISION: WIKPDVZLAM

Another example:

lab46:~/src/discrete/eoce/0x1$ ./0x1
           IIHBB
      +---------
 KIII | KRARAQGM
       -KIII
        ====
         BTBA
        -KIII
         ====
         QHGTQ
        -IBHHH
         =====
          ATMRG
         -TBBBB
          =====
           AQMRM
          -TBBBB
           =====
            HQMQ

LETTERDIVISION: MIQHTAKGBR

0x2: Choose your poison

Pick one from the following list to perform:

  • letter division generator where the divisor, dividend, and puzzle key are all english-readable words (perhaps from reading from a dictionary file, or provided via input from the user/command-line arguments)
  • dcf3: autodetect optimal stride and control byte (based on input file data)
  • sort buffet: implement bubble/selection/insert, merge, quick, and another sort of your choosing

Note that I'm not looking for name drops or other surface level attempts to gain credit. I want to see well thought out, and central utilizations of discrete structures-related concepts and practices in the solutions to your choices.

0x3: Variable Factor Pair Processing

In a previous cnvX project, you wrote a program that simply (brute forcedly, naively) generated a listing of appropriate nary values in space-separated fashion, executed as follows:

./program nary lower upper

We will be adding an additional (fourth) optional argument (argv[4]), which if present (as a 1), will display in set notation form, the factors of the identified N-ary value, in a list form). Omitted or specifying a 0 will format in a familiar space-separated output format.

N-ary values

What we know of as prime numbers are those numbers with just 1 factor pair (1 and the number itself).

Secondary numbers are those with 2 factor pairs (1 and itself, plus another 2 values). 6 is a secondary number, as its factors are: 1, 2, 3, 6.

There are some “hidden” values as well at times… for example, the number 4 is also to be considered a secondary number, as its factors are: 1, 2, 2, 4. Because it is a square value, its second factor pair is a set of 2's. You'll need to keep this detail in mind with respect to your processing.

Tertiary and beyond merely continue the scaling of this specification- tertiary numbers have 3 factor pairs (for example, the number 12- 1, 2, 3, 4, 6, 12).

Specification

You are to write a program that:

  • accepts the following values as command-line arguments:
    • argv[1]: the N-ary value to check for (1 or more)
    • argv[2]: the lower bound
    • argv[3]: the upper bound
    • argv[4]: optional; nothing or 0, default to pnc-style output; if 1, horizontally list factors, while vertically listing individual entries.
    • proper error checking should be performed so that the program cannot proceed (and should display an appropriate error) if violations occur.
    • perform the necessary calculations to determine the factors, according to command-line arguments given.
      • you may want to STORE the factors
    • display the results for that number, according to format (see execution section below)
      • factor output should be padded for the largest values being displayed

Execution

Your program output should be as follows (given the specific inputs via the command-line):

All secondary numbers between 2 and 40
lab46:~/src/discrete/eoce/0x3$ ./0x3 2 2 40
4 6 8 9 10 14 15 21 22 25 26 27 33 34 35 38 39
lab46:~/src/discrete/eoce/0x3$ 
Tertiary numbers between 2 and 40
lab46:~/src/discrete/eoce/0x3$ ./0x3 3 2 40 0
12 16 18 20 32 
lab46:~/src/discrete/eoce/0x3$ 
Quadrary numbers between 2 and 66, with factor list
lab46:~/src/discrete/eoce/0x3$ ./0x3 4 2 66 1
 24 = { 1,  2,  3,  4,  6,  8, 12, 24 }
 30 = { 1,  2,  3,  5,  6, 10, 15, 30 }
 40 = { 1,  2,  4,  5,  8, 10, 20, 40 }
 42 = { 1,  2,  3,  6,  7, 14, 21, 42 }
 54 = { 1,  2,  3,  6,  9, 18, 27, 54 }
 56 = { 1,  2,  4,  7,  8, 14, 28, 56 }
 64 = { 1,  2,  4,  8,  8, 16, 32, 64 }
 66 = { 1,  2,  3,  6, 11, 22, 33, 66 }
lab46:~/src/discrete/eoce/0x3$ 

0x4: Weird Numbers

We continue to apply our skills in implementing an algorithm that determines certain attributes of a number based on its factor composition.

Weird and Semi-perfect numbers

In the ewn0 project, we explored the computation of abundant, perfect, and deficient numbers. There is one more in that “genre”, and that is the classification of weird numbers, with a related semi-perfect classification.

A semi-perfect number is a natural number that is equal to the sum of all or some of its factors. A semi-perfect number that is equal to the sum of all its proper divisors is a perfect number. So by this definition, semi-perfect numbers can be abundant or perfect numbers, but that is limited by the constraining requirement of some combination of sums equalling the number we are evaluating.

Some examples of semi-perfect numbers include:

  • 6: with factors of 1, 2, 3, we see that 1+2+3 = 6. As this is also ALL the factors, this was identified as a perfect number in the previous project (and from the definition above, all perfect numbers are semi-perfect, but NOT all semi-perfect numbers are perfect).
  • 12: with factors of 1, 2, 3, 4, 6, we see that 1+2+3+6 = 12. Adding up ALL the factors gives us a value greater than 12 (and in the previous project, it would have been classified as an abundant number).
  • 18: with factors of 1, 2, 3, 6, 9, we see that 3+6+9 = 18. Adding up ALL the factors gives us a value greater than 18 (and in the previous project, it would have been classified as an abundant number).

A weird number is defined as a natural number that is abundant but not semi-perfect. In other words, the sum of the factors (divisors including 1 but not itself) of the number is greater than the number, but no subset of those divisors sums to the number itself.

Some examples of weird numbers include:

  • 70: with factors 1, 2, 5, 7, 10, 14, 35, is an abundant number where the factors sum to 74. Yet there is no subset of factors that can be summed that give us a value of 70. Therefore, 70 is classified as a weird number.

Subset of sums

Calculating semi-perfect and weird numbers requires us to analyze the various combinations of factor sums. This requires some additional consideration in our implementation, as we need to try every possible combination to see if there is a match.

Specification

You are to write a program that:

  • accepts two values via command-line arguments
    • argv[1]: the starting value
    • argv[2]: the ending value
    • proper error checking should be performed so that the program cannot proceed (and should display an appropriate error) if the following conditions are encountered:
      • values less than 2 are provided, with an error “invalid range specification”
      • missing argv[2], with the error “missing upper bound”
      • missing both argv[1] and argv[2]: “insufficient data provided”
    • assumptions: as inferred in the error checking above, processing can start at 2, and proceed up to the maximum value of the data type.
      • while we are including 1 as a factor, we are not including the number itself in the list of factors.
    • perform the necessary calculations to determine the factors, from (and including) argv[1] through (and including) argv[2]
      • be sure to STORE the factors
      • sum the factors, and determine its abundant/perfect/deficient quality
      • NOTE: the starting value does NOT have to be less than the ending value. We are merely connecting the two.
    • display the results for that number:
      • if it is NOT a semi-perfect nor a weird number, we keep the format from the previous project:
        • [NUMBER] quality: F1+F2+...+FN = SUM
        • for example: [8] deficient: 1+2+4 = 7
      • if it IS a semi-perfect or a weird number, we specifically display that information:
        • [NUMBER] quality: F1+F2+...+FN = SUM (CLASSIFICATION: factor summation or "none")
        • for example: [12] abundant: 1+2+3+4+6 = 16 (semi-perfect: 1+2+3+6).
        • or: [70] abundant: 1+2+5+7+10+14+35 = 74 (weird: none).

Basically, requirements are the SAME as for 0x4, only we are adding in the check, processing, and output identification of semi-perfect and weird numbers.

There exists the possibility that there may be multiple combinations of factor subset sums that will prove semi-perfection. For the purposes of this project, display the FIRST match you find (as such, you do not need to find EVERY possible combination, merely the first and then bail out of your attempt).

Execution

Your program output should be as follows (given the specific inputs via the command-line):

lab46:~/src/discrete/eoce/0x4$ ./0x4 66 70
[66] abundant:  1+2+3+6+11+22+33 = 78 (semi-perfect: 11+22+33)
[67] deficient: 1 = 1
[68] deficient: 1+2+4+17+34 = 58
[69] deficient: 1+3+23 = 27
[70] abundant:  1+2+5+7+10+14+35 = 74 (weird: none)
lab46:~/src/discrete/eoce/0x5$ 

As with ewn0, starting and ending at any acceptable value is possible, as well as the starting value being higher than the ending value.

0x5: Anagrams

An anagram is process of rearranging all the letters in a word to spell out different combinations.

For example, tar can have anagrams of:

  • tra
  • atr
  • art
  • rat
  • rta

Your task is to write a program that accepts a word or phrase as input (spaces ALLOWED), and will display all the possible UNIQUE anagrams (NO DUPLICATES!) possible from the source input.

You need to also display the total number of variations possible, along with the anagrammed words.

Input can be via command-line, menu, etc.

Please place your code in the 0x5/ directory of the eoce/ project directory.

0x6: Personal Assessment

After an exciting and intellectually challenging run, we're arriving at the end of this semester's journey. Some will be moving on, others sticking around for more. I make it a practice to listen to your thoughts and suggestions. The course, as we all experienced it, unfolds in a manner pertaining, in part, to how you respond to concepts and topics (do we need more time, can I crank it up a couple notches, etc.) so each semester and each class is entirely different from any other- because of each of you, and all of us, working together and learning together.

So, searching deep down within your soul- balancing reason with emotion, and considering attendance and timeliness; what grade do you feel you deserve for this course, and why? Justify your answer based on your own perceived performance to course ideals and content, not on need or desire.

Also, answer me the following:

  • Of all the work you've done this semester in this course, identify something that was meaningful to you. What is it? Why does it stick out in your mind? Explain.
  • How did you feel about the course?
  • Was it useful/interesting to you?
  • What was your least favorite aspect, and why?
  • Any comments, suggestions?

Please reflect your response based on your insights and understanding of computing. Don't just say “that one thing” was your least favorite aspect. Say why that was- How did your least favorite aspect play to your limitations of your knowledge and experiences? THAT is what I'm after.

0x7: In-person Knowledge Assessment

During some standard time between now and 05:29:59pm (that's 17:29:59 in 24-hour time) Wednesday, December 11th, 2019, you are to approach me to perform an in-person knowledge assessment. This is to help ensure consistency and validity of the other work you are performing on the EoCE (which of course you are following the rules and doing it all yourself with no outside help).

Valid times include any remaining class or office/lab hours with no structured/scheduled activities, or any of the finals week availabilities.

Note that you only have a single opportunity to take this (no make sure you allocate yourself an adequate amount of time).

Pro tip: Don't wander in 30 minutes (or similarly time deficient) before a deadline and expect an extension/more time to work on it.

When ready, please proceed: DISCRETE IPKA

Submission

EoCE document

All responses to questions, unless specifically indicated otherwise, should be addressed on this document (or the intended wiki document).

Please edit the appropriate section and provide the necessary information.

File Submission

For any other specific deliverables, if using a project directory tree you can obtain a copy of, when ready, submit it using the Makefile, as follows:

lab46:~/src/DESIG/eoce$ make submit
...

If no formal project, you can submit requested files (preferably in an archive of their own), using the submit tool. A project called eoce has been likely set up for this purpose.

haas/fall2019/discrete/projects/eoce.1572361329.txt.gz · Last modified: 2019/10/29 11:02 by 127.0.0.1