User Tools

Site Tools


Sidebar

projects

wcp1 (due 20240828)
btt0 (due 20240904)
wcp2 (due 20240904)
pct0 (bonus; due 20240905)
pct1 (bonus; due 20240905)
pct2 (due 20240905)
abc0 (due 20240906)
msi0 (due 20240911)
pct3 (bonus; due 20240911)
wcp3 (due 20240911)
msi1 (due 20240918)
pct4 (due 20240918)
wcp4 (due 20240918)
dsr0 (due 20240926)
pct5 (bonus; due 20240926)
wcp5 (due 20240926)
gfo0 (due 20241002)
pct6 (due 20241002)
pnc0 (due 20241002)
wcp6 (due 20241002)
dsr1 (due 20241009)
pct7 (bonus; due 20241009)
wcp7 (due 20241009)
bwp1 (bonus; due 20241016)
pct8 (due 20241016)
pnc1 (due 20241016)
wcp8 (due 20241016)
pct9 (bonus; due 20241023)
pnc2 (due 20241023)
wcp9 (due 20241023)
gfo1 (due 20241030)
mag0 (due 20241030)
pctA (due 20241030)
wcpA (due 20241030)
mag1 (due 20241106)
pctB (bonus; due 20241106)
wcpB (due 20241106)
mag2 (due 20241113)
pctC (due 20241113)
wcpC (due 20241113)
pctD (bonus; due 20241120)
wcpD (bonus; due 20241120)
bwp2 (bonus; due 20241204)
gfo2 (due 20241204)
pctE (bonus; due 20241204)
wcpE (bonus; due 20241204)
EoCE (due 20241216)
haas:fall2024:discrete:projects:dsr1

Corning Community College

CSCS2330 Discrete Structures

PROJECT: Discrete Skills Review (dsr1)

OBJECTIVE

Influenced by the unix/usr0 'urev' skills review activity, and discrete/dsr0, create a program that does the same but for bitwise logic on nibble-sized groups of binary values ranging from 4 to 16 bits.

This does not have to be written for Vircon32, nor does it specifically have to be in C.

EDIT

You will want to go here to edit and fill in the various sections of the document:

dsr1

Table

A B AND OR XOR NAND NOR XNOR
0 0 0 0 0 1 1 1
0 1 0 1 1 1 0 0
1 0 0 1 1 1 0 0
1 1 1 1 0 0 0 1
A NOT
0 1
1 0

bitwise AND

One way to do AND two values is manually.

One thing to keep in mind when doing it manually is that your numbers have to be the same length. One way to do that is to set a max length and then print it while padding it with spaces or zeros and capturing that output into a variable. Do this with both randomly generated numbers.

Then you can read each variable character by character against the other and do you operation on them.

For example (in bash):

for(( jndex=0; jndex<16; jndex++ ))
do
    if [[ "${array1[$jndex]}" == 1 ]] && [[ "${array2[$jndex]}" == 1 ]] ; then
        VarArray+=1
    else
        VarArray+=0
    fi
done

This is done for the programs answers to then check your user provided answer against later in the code.

You can also use bash pockets of arithmetic to do any of the bitwise operations, although they are very picky with number bases, so you will have to convert your numbers being compared into decimal to convert, then back into their base after doing logic. One way you can go about this is like this:

echo "obase=${ORIGINBASE}; $(( $(echo "obase=10; ibase=${ORIGINBASE}; ${FIRSTNUMBER}" | bc) & $(echo "obase=10; ibase=${ORIGINBASE}; ${SECONDNUMBER}" | bc) ))" | bc

bitwise iOR

You can use the same method(s) for iOR as you did with and, as the manual method works by giving it the cases for the operation, similarly to a truth table, and the pocket of arithmetic has a built in iOR operation “|”

bitwise XOR

You can use the same method(s) for iOR as you did with and, as the manual method works by giving it the cases for the operation, similarly to a truth table, and the pocket of arithmetic has a built in iOR operation “^”

bitwise NOT

echo 01010101 | tr '10' '01' or you can do tr '01' '10' both just flips it

If you use the bitwise NOT operation ~ (such as ~number1) and you do not want to use tr to flip the result, you can also use ‘and’ masking. (1«bit_length) - 1 where bit_length is a random number of bits (4, 8, 12, 16). This shifts the value 1 to the left by bit_length positions. With this mask, only the least significant bits are set to 1. For example, if bit_length (or whatever variable you use) is 8, mask will be 11111111 (255 in binary). What this may look like: (~number) & mask. You can also use this same ‘and’ masking for any other operations using bitwise NOT ~ (such as NAND, NOR, and XNOR).

bitwise NAND

Sort of like what you could do with the NOT operation you can do similar to the NAND operation. So, you could perform your AND operation first and then get the result from that and flip the bits to get your NAND result.

bitwise NOR

bitwise XNOR

Super Awesome Notes

Part 1:

-Generate random number of nibbles 1-4

-Generate random number for each generated nibble

-Convert numbers to a base (2,4,8,16)

-Convert those BACK to binary

-Select a NEW base (not the previous one)

-The player needs to convert the binary to the NEW base's value

Example:

Let there be 2 nibbles.

Let nibble1 = 10 (decimal)

Let nibble2 = 5 (decimal)

First base is 16

10 → A / 5 → 5

In binary: 1010 / 0101

NEW base = 8

Together: 010100101 (ADD A ZERO TO THE FRONT TO MAKE 9 DIGITS, bc 2^3 = 8 ← NEED SETS OF 3)

The player needs to break this down mentally into 010 100 010 → 2 4 5

The answer: 245

What the player will see:

2 nibbles in base16: A and 5

ANSWER: 245

Part 2:

-Generate random binary number (ideally 4,8,12,16) digits in length

-Generate second binary number in same length

-Do bitwise logic on it

What the player will see:

   1010
&& 0110
   ====
   0010
 

Let part 1 be something of a warmup. After X rounds, part 2 should kick in

 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

  • Project must be submit on time, by the deadline.
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output, if applicable, must be correct based on values input
  • Code must be nicely and consistently indented
  • Code must be consistently written, to strive for readability from having a consistent style throughout
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
      • Sufficient comments explaining the point of provided logic MUST be present
  • No global variables (without instructor approval), no goto statements, no calling of main()!
  • Track/version the source code in your lab46 semester repository
  • Submit a copy of your source code to me using the submit tool by the deadline.

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

RUBRIC

I'll be evaluating the project based on the following criteria:

182:dsr1:final tally of results (182/182)
*:dsr1:displays table on early problems [26/26]
*:dsr1:supports generation of similar size terms [26/26]
*:dsr1:generates problems in groups of nibbles, from 4 to 16 bits [26/26]
*:dsr1:supports bitwise AND, OR, NOT, XOR, XNOR, NAND, and NOR [26/26]
*:dsr1:keeps score and track of correct and incorrect responses [26/26]
*:dsr1:serves 12 problems every 4 hours and 20 minutes [26/26]
*:dsr1:allow for erasing of mistakes by getting a run correct [26/26]

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 1024 bytes (absolute value of data content change))
      • no zero-sum commits (adding in one commit then later removing in its entirety for the sake of satisfying edit requirements)
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2024/discrete/projects/dsr1.txt · Last modified: 2024/09/22 15:16 by 127.0.0.1