├── .gitignore ├── codepost ├── c_templates │ ├── build_test.sh │ ├── build_warnings_test.sh │ ├── template_test_001.sh │ └── template_test_suite.sh ├── generic_rubric.json ├── java_templates │ ├── build_test.sh │ ├── build_warnings_test.sh │ ├── junit_test_suite.sh │ └── template_test_001.sh └── readme.md ├── documents ├── TheTaoOfTALC.pdf ├── byod.pdf ├── byod.tex ├── codeUsageGuidelines.pdf ├── codeUsageGuidelines.tex ├── faq.md ├── instructor.md ├── iticse-7steps.pdf ├── laGuidelines.md ├── misc │ ├── Activating-Huskers-Email.pdf │ └── CanvasForUNO.pdf ├── mrc.jpg ├── rubric.md ├── rubric.pdf ├── rubric.tex ├── syllabus-194.md ├── syllabus.md ├── teOfCSE.pdf ├── teOfCSE.tex ├── tipsForOnline.pdf ├── tipsForOnline.tex ├── troubleShooting.pdf └── troubleShooting.tex ├── hacks ├── hack-debugging │ ├── primesProgram-buggy.c │ ├── primesProgram-fixed.c │ └── readme.md ├── hack-strings │ └── readme.md ├── hack1.0 │ ├── images │ │ ├── change.png │ │ ├── cl-gitcommit.png │ │ ├── cl-gitdiff.png │ │ ├── cl-githubNewRepo.png │ │ ├── cl-githubNewRepoName.png │ │ ├── cl-gitignore.png │ │ ├── cl-gitinit.png │ │ ├── cl-gitpush2.png │ │ ├── cl-gitstatus.png │ │ ├── cl-pwd.png │ │ ├── commit.png │ │ ├── completedRepo01.png │ │ ├── completedRepo02.png │ │ ├── completedRepo03.png │ │ ├── drag.png │ │ ├── postCreation.png │ │ ├── publish.png │ │ ├── pushChange.png │ │ ├── repositorydiagram.png │ │ └── setup.png │ └── readme.md ├── hack10.0 │ ├── examples │ │ ├── dnaSample001.txt │ │ ├── dnaSample002.txt │ │ ├── proteinResult001.txt │ │ └── proteinResult002.txt │ ├── proteinUtilDemo.c │ ├── protein_utils.c │ ├── protein_utils.h │ └── readme.md ├── hack11.0 │ ├── airport.h │ └── readme.md ├── hack12.0 │ └── readme.md ├── hack13.0 │ ├── airport.c │ ├── airport.h │ ├── files │ │ ├── airport_output_001.txt │ │ ├── airport_output_002.txt │ │ ├── airport_output_003.txt │ │ ├── airport_test_001.c │ │ ├── airport_test_001.csv │ │ ├── airport_test_002.c │ │ ├── airport_test_002.csv │ │ ├── airport_test_003.c │ │ └── airport_test_003.csv │ └── readme.md ├── hack14.0 │ └── readme.md ├── hack2.0 │ └── readme.md ├── hack3.0 │ └── readme.md ├── hack4.0 │ └── readme.md ├── hack5.0 │ └── readme.md ├── hack6.0 │ ├── makefile │ ├── readme.md │ └── utilsTester.c ├── hack7.0 │ ├── images │ │ ├── pointers.png │ │ ├── pointersHFlip.jpg │ │ ├── pointersRotated.jpg │ │ └── pointersVFlip.png │ └── readme.md └── readme.md ├── honors ├── documents │ └── syllabus.md ├── hacks │ ├── hack-strings │ │ └── readme.md │ ├── hack1.0 │ │ ├── images │ │ │ ├── cl-githubNewRepo.png │ │ │ ├── cl-githubNewRepoName.png │ │ │ ├── eclipse-githubNewRepo.png │ │ │ ├── eclipse-githubNewRepoName.png │ │ │ ├── eclipseCloneDialogAMarkUp.png │ │ │ ├── eclipseCloneDialogBMarkUp.png │ │ │ ├── eclipseCloneDialogCMarkUp.png │ │ │ ├── eclipseCommitDialogAMarkUp.png │ │ │ ├── eclipseCreateRepoDialogAMarkUp.png │ │ │ ├── eclipseGitPull.png │ │ │ ├── eclipseGitPullResult.png │ │ │ ├── eclipseGitPushDialogBMarkUp.png │ │ │ ├── eclipseGitPushMarkup.png │ │ │ ├── eclipseGitRepoCreateNewMarkUp.png │ │ │ ├── eclipseGitRepoMarkUp.png │ │ │ ├── eclipseGitStagingMarkUp.png │ │ │ ├── eclipseOpenPerspectiveMarkUp.png │ │ │ ├── eclipsePerspectiveDialog.png │ │ │ ├── eclipsePreCommit.png │ │ │ ├── eclipsePush.png │ │ │ ├── eclipsePushDialog.png │ │ │ ├── eclipseRemotePushMarkUp.png │ │ │ ├── eclipseRepoCommitMarkUp.png │ │ │ └── repositorydiagram.png │ │ └── readme.md │ ├── hack10.0 │ │ ├── ProteinTranslator.java │ │ ├── examples │ │ │ ├── dnaSample001.txt │ │ │ ├── dnaSample002.txt │ │ │ ├── proteinResult001.txt │ │ │ └── proteinResult002.txt │ │ └── readme.md │ ├── hack11.0 │ │ ├── Airport.java │ │ └── readme.md │ ├── hack12.0 │ │ ├── Pair.java │ │ └── readme.md │ ├── hack13.0 │ │ ├── AirportUtils.java │ │ └── readme.md │ ├── hack14.0 │ │ └── readme.md │ ├── hack2.0 │ │ └── readme.md │ ├── hack3.0 │ │ └── readme.md │ ├── hack4.0 │ │ └── readme.md │ ├── hack5.0 │ │ └── readme.md │ ├── hack6.0 │ │ ├── CMYK.java │ │ ├── ColorUtilsTests.java │ │ ├── RGB.java │ │ └── readme.md │ ├── hack7.0 │ │ ├── ImageDriver.java │ │ ├── ImageUtils.java │ │ ├── RGB.java │ │ ├── images │ │ │ ├── pointers.png │ │ │ ├── pointersHFlip.jpg │ │ │ ├── pointersRotated.jpg │ │ │ └── pointersVFlip.png │ │ └── readme.md │ └── readme.md └── readme.md ├── license.md ├── notes ├── 1198-Fall2019 │ ├── 01-introduction.pdf │ ├── 02-basics.md │ ├── 03-conditionals.md │ ├── 04-loops.md │ ├── 05-functions.md │ ├── 06-errorHandling.md │ ├── 07-arrays.md │ ├── 08-strings.md │ ├── 09-fileIO.md │ ├── 10-encapsulation.md │ ├── 11-recursion.md │ ├── 14-gui.md │ ├── 15-databases-H.md │ ├── 15-databases.md │ ├── databases │ │ ├── books.csv │ │ ├── books.json │ │ └── books.xml │ ├── debugging.md │ ├── recursionDemo.c │ ├── rootDemo.c │ ├── roots.c │ ├── roots.h │ ├── roundDemo.c │ ├── roundUtils.c │ ├── roundUtils.h │ └── searchingSorting │ │ ├── 12-searchingSorting.md │ │ ├── binarySearchIdea.png │ │ ├── comparator.png │ │ ├── linearSearchPseudocode.png │ │ └── wrapup.md ├── 1208-Fall2020 │ ├── 10-fileIO.md │ ├── 11-encapsulation.md │ ├── 12-recursion.md │ ├── 13-searchingSorting.md │ ├── 2-basics.md │ ├── 3-conditionals.md │ ├── 4-loops.md │ ├── 5-functions.md │ ├── 6-errorHandling.md │ ├── 7-arrays.md │ ├── 8-debugging.md │ ├── 9-strings.md │ ├── bugsus.jpg │ └── honors │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ ├── 13-searchingSorting.md │ │ ├── 2-basics.md │ │ ├── 3-conditionals.md │ │ ├── 4-loops.md │ │ ├── 5-functions.md │ │ ├── 6-errorHandling.md │ │ ├── 7-arrays.md │ │ ├── 8-debugging.md │ │ └── 9-strings.md ├── 1218-Fall2021 │ ├── 1-intro.md │ ├── 10-fileIO.md │ ├── 11-encapsulation.md │ ├── 12-recursion.md │ ├── 13-searchingSorting.md │ ├── 14-gui.md │ ├── 15-databases.md │ ├── 2-basics.md │ ├── 3-conditionals.md │ ├── 4-loops.md │ ├── 5-functions.md │ ├── 6-errorHandling.md │ ├── 7-arrays.md │ ├── 8-strings.md │ ├── 9-debugging.md │ ├── encapsulationDemo │ │ ├── demo.c │ │ ├── film.c │ │ └── film.h │ └── honors │ │ ├── 1-intro.md │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ ├── 13-searchingSorting.md │ │ ├── 2-basics.md │ │ ├── 3-conditionals.md │ │ ├── 4-loops.md │ │ ├── 5-functions.md │ │ ├── 6-errorHandling.md │ │ ├── 7-arrays.md │ │ ├── 8-strings.md │ │ ├── 9-tooling.md │ │ └── encapsulationDemo │ │ ├── demo.c │ │ ├── student.c │ │ └── student.h ├── 1221-Spring2022 │ ├── 01-intro.md │ ├── 02-basics.md │ ├── 03-conditionals.md │ ├── 04-loops.md │ ├── 05-functions.md │ ├── 06-errorHandling.md │ ├── 07-arrays.md │ ├── 08-Debugging.md │ ├── 09-strings.md │ ├── 10-fileIO.md │ ├── 11-structures.md │ ├── 12-recursion.md │ ├── 13-searchingSorting.md │ └── demoCode │ │ ├── agm.c │ │ ├── fizzbuzz.c │ │ ├── harmonic.c │ │ └── loan.c ├── 1228-Fall2022 │ ├── 194 │ │ ├── 01-intro.md │ │ ├── 02-basics.md │ │ ├── 03-conditionals.md │ │ ├── 04-loops.md │ │ ├── 05-functions.md │ │ ├── 06-errorHandling.md │ │ ├── 07-arrays.md │ │ ├── 08-debugging.md │ │ ├── 09-strings.md │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ ├── 13-searchingSorting.md │ │ ├── code │ │ │ ├── book.c │ │ │ ├── book.h │ │ │ ├── bookDemo.c │ │ │ ├── books.csv │ │ │ ├── demo.c │ │ │ ├── weight.c │ │ │ ├── weight.h │ │ │ └── weightTester.c │ │ └── review.md │ ├── 155E │ │ ├── 01-intro.md │ │ ├── 02-basics.md │ │ ├── 03-conditionals.md │ │ ├── 04-loops.md │ │ ├── 05-functions.md │ │ ├── 06-errorHandling.md │ │ ├── 07-arrays.md │ │ ├── 08-debugging.md │ │ ├── 09-strings.md │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ ├── 13-searchingSorting.md │ │ ├── code │ │ │ ├── book.c │ │ │ ├── book.h │ │ │ ├── books.csv │ │ │ ├── demo.c │ │ │ ├── main.c │ │ │ ├── massUtils.c │ │ │ └── massUtils.h │ │ └── review.md │ ├── 155H │ │ ├── 01-intro.md │ │ ├── 02-basics.md │ │ ├── 03-conditionals.md │ │ ├── 04-loops.md │ │ ├── 05-functions.md │ │ ├── 06-errorHandling.md │ │ ├── 07-arrays.md │ │ ├── 08-debugging.md │ │ ├── 09-strings.md │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ ├── 13-searchingSorting.md │ │ └── code │ │ │ ├── Author.java │ │ │ ├── Book.java │ │ │ ├── Demo.java │ │ │ ├── book.c │ │ │ ├── book.h │ │ │ ├── bookDemo.c │ │ │ ├── books.csv │ │ │ └── sorting │ │ │ ├── Author.java │ │ │ ├── Book.java │ │ │ ├── BookDemo.java │ │ │ ├── book.c │ │ │ ├── book.h │ │ │ └── bookDemo.c │ └── books.csv ├── 1238-Fall2023 │ ├── 155E │ │ ├── 01-intro.md │ │ ├── 02-basics.md │ │ ├── 03-conditionals.md │ │ ├── 04-loops.md │ │ ├── 05-functions.md │ │ ├── 06-errorHandling.md │ │ ├── 07-arrays.md │ │ ├── 08-debugging.md │ │ ├── 09-strings.md │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ └── 13-searchingSorting.md │ └── 155H │ │ ├── 01-intro.md │ │ ├── 02-basics.md │ │ ├── 03-conditionals.md │ │ ├── 04-loops.md │ │ ├── 05-functions.md │ │ ├── 06-errorHandling.md │ │ ├── 07-arrays.md │ │ ├── 08-toolingDebugging.md │ │ ├── 09-strings.md │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ └── 13-searchingSorting.md ├── 1248-Fall2024 │ ├── 155E │ │ ├── 01-intro.md │ │ ├── 02-basics.md │ │ ├── 03-conditionals.md │ │ ├── 04-loops.md │ │ ├── 05-functions.md │ │ ├── 06-errorHandling.md │ │ ├── 07-arrays.md │ │ ├── 08-debuggingTooling.md │ │ ├── 09-strings.md │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ ├── 13-searchingSorting.md │ │ └── code │ │ │ ├── book.c │ │ │ ├── book.h │ │ │ ├── bookDemo.c │ │ │ ├── cheer.c │ │ │ ├── compute_roots_clas.c │ │ │ ├── compute_roots_interactive.c │ │ │ ├── corn.c │ │ │ ├── fizzbuzz.c │ │ │ ├── game.c │ │ │ ├── goodreads-abridged.csv │ │ │ ├── loan.c │ │ │ └── wins.c │ └── 155H │ │ ├── 01-intro.md │ │ ├── 02-basics.md │ │ ├── 03-conditionals.md │ │ ├── 04-loops.md │ │ ├── 05-functions.md │ │ ├── 06-errorHandling.md │ │ ├── 07-arrays.md │ │ ├── 08-toolingDebugging.md │ │ ├── 09-strings.md │ │ ├── 10-fileIO.md │ │ ├── 11-encapsulation.md │ │ ├── 12-recursion.md │ │ ├── 13-searchingSorting.md │ │ └── code │ │ ├── Agm.java │ │ ├── Book.java │ │ ├── BookDemo.java │ │ ├── Cheer.java │ │ ├── ComputeRoots.java │ │ ├── Loan.java │ │ ├── MilesToKms.java │ │ ├── Wins.java │ │ ├── agm.c │ │ ├── book.c │ │ ├── book.h │ │ ├── bookDemo.c │ │ ├── goodreads-abridged.csv │ │ ├── my_math.c │ │ ├── my_math.h │ │ ├── my_math_tests.c │ │ └── num_primes.c └── dev │ └── scratch.md ├── readme.md ├── scripts ├── codepost │ ├── assignment.py │ ├── canvas.py │ ├── canvasUtils.py │ ├── codepostGetSubmissions.py │ ├── codepostInitRoster.py │ ├── codepostToCanvas.py │ ├── codepostUtils.py │ ├── codepostValidateCourse.py │ ├── codepost_assign_graders.py │ ├── config.py │ ├── course.py │ ├── group.py │ ├── person.py │ ├── readme.md │ └── update_attendance.py └── php │ ├── assignGraders.php │ ├── mail.list │ └── makeTeams.php └── slides ├── figures ├── figureArrayOfStructurePointers.tex ├── figureArrayOfStructures.tex └── figureArrayOfStructuresHybrid.tex ├── images ├── ascii.png ├── triangleEquilateral.png ├── triangleIsosceles.png └── triangleScalene.png ├── lecture-arrays-HandoutNoNotes.pdf ├── lecture-arrays.pdf ├── lecture-arrays.tex ├── lecture-basics-HandoutNoNotes.pdf ├── lecture-basics.pdf ├── lecture-basics.tex ├── lecture-conditionals-HandoutNoNotes.pdf ├── lecture-conditionals.pdf ├── lecture-conditionals.tex ├── lecture-debugging-HandoutNoNotes.pdf ├── lecture-debugging.pdf ├── lecture-debugging.tex ├── lecture-errorHandling-HandoutNoNotes.pdf ├── lecture-errorHandling.pdf ├── lecture-errorHandling.tex ├── lecture-fileIO-HandoutNoNotes.pdf ├── lecture-fileIO.pdf ├── lecture-fileIO.tex ├── lecture-functions-HandoutNoNotes.pdf ├── lecture-functions.pdf ├── lecture-functions.tex ├── lecture-loops-HandoutNoNotes.pdf ├── lecture-loops.pdf ├── lecture-loops.tex ├── lecture-recursion-HandoutNoNotes.pdf ├── lecture-recursion.pdf ├── lecture-recursion.tex ├── lecture-searchingSorting-HandoutNoNotes.pdf ├── lecture-searchingSorting.pdf ├── lecture-searchingSorting.tex ├── lecture-strings-HandoutNoNotes.pdf ├── lecture-strings.pdf ├── lecture-strings.tex ├── lecture-structures-HandoutNoNotes.pdf ├── lecture-structures.pdf └── lecture-structures.tex /.gitignore: -------------------------------------------------------------------------------- 1 | # C files 2 | *.o 3 | *.so 4 | a.out 5 | 6 | # python files 7 | # Byte-compiled / optimized / DLL files 8 | __pycache__/ 9 | *.py[cod] 10 | *$py.class 11 | #pickle 12 | *.pkl 13 | # local dev files 14 | scripts/codepost/dev/** 15 | scripts/codepost/dev.py 16 | scripts/handin/ 17 | 18 | # latex temporary files 19 | *.acn 20 | *.acr 21 | *.alg 22 | *.aux 23 | *.bbl 24 | *.blg 25 | *.glg 26 | *.glo 27 | *.gls 28 | *.idx 29 | *.ilg 30 | *.ind 31 | *.ist 32 | *.loa 33 | *.lof 34 | *.log 35 | *.lol 36 | *.nav 37 | *.out 38 | *.snm 39 | *.synctex.gz 40 | *.vrb 41 | *.toc 42 | *.xwm 43 | # 44 | *~ 45 | 46 | # minted subdirectory 47 | _minted-* 48 | figures/_minted* 49 | 50 | # 51 | .DS_Store 52 | 53 | # 54 | .vscode/ 55 | notes/dev/ 56 | development 57 | codepost/dev 58 | -------------------------------------------------------------------------------- /codepost/c_templates/build_test.sh: -------------------------------------------------------------------------------- 1 | ####################################################################################### 2 | # This file will be run from main.sh. Create test results by calling the following function: 3 | # TestOutput 4 | ###################################################################################### 5 | 6 | # this could be done in a loop if multiple source files are present 7 | # however, a single test should be created for each part to communicate 8 | # which source files have warnings or issues 9 | source="FILE.c" 10 | #compile redirecting stderr to stdout 11 | result=$(gcc -w $source 2>&1) 12 | 13 | #if result is not empty 14 | if ! [[ -z "$result" ]]; then 15 | message="Your code does not appear to compile: 16 | $result" 17 | #echo "$message" 18 | TestOutput "Build Tests" "Compiler Output" false "$message" 19 | else 20 | message="Your code compiles with no errors." 21 | #echo "$message" 22 | TestOutput "Build Tests" "Compiler Output" true "$message" 23 | fi 24 | -------------------------------------------------------------------------------- /codepost/c_templates/build_warnings_test.sh: -------------------------------------------------------------------------------- 1 | ####################################################################################### 2 | # This file will be run from main.sh. Create test results by calling the following function: 3 | # TestOutput 4 | ###################################################################################### 5 | 6 | # this could be done in a loop if multiple source files are present 7 | # however, a single test should be created for each part to communicate 8 | # which source files have warnings or issues 9 | source="FILE.c" 10 | #compile redirecting stderr to stdout 11 | result=$(gcc -Wall -Wextra $source 2>&1) 12 | 13 | #if result is not empty 14 | if ! [[ -z "$result" ]]; then 15 | message="Your code does not appear to compile or compiles with warnings: 16 | $result" 17 | #echo "$message" 18 | TestOutput "Build Tests" "Compiler Warnings" false "$message" 19 | else 20 | message="Your code compiles with no errors or warnings." 21 | #echo "$message" 22 | TestOutput "Build Tests" "Compiler Warnings" true "$message" 23 | fi 24 | -------------------------------------------------------------------------------- /codepost/c_templates/template_test_suite.sh: -------------------------------------------------------------------------------- 1 | ####################################################################################### 2 | # This file will be run from main.sh. Create test results by calling the following function: 3 | # TestOutput 4 | ###################################################################################### 5 | 6 | # Convention: exit code 7 | # This script is intended to run self-contained test suites, either 8 | # ad-hoc or cmocka suites. 9 | # 10 | # The exit code is used to determine pass/failure of the codepost.io 11 | # test. 12 | # - cmocka outputs the number of tests failed (0 for all pass) 13 | # - our convention: 14 | # - by default it will report number of failed tests (0 all pass) 15 | # - via CLA "-reportPass" it will report the total passed 16 | # Thus we run it twice and capture both values 17 | 18 | numExpected=18 19 | executeCmd='./colorUtilsTester' 20 | input='' 21 | ## Alternative: CLAs 22 | output=$($executeCmd $input 2>&1) 23 | numFail=$(($?)) 24 | input='-reportPass' 25 | output=$($executeCmd $input 2>&1) 26 | numPass=$(($?)) 27 | 28 | if [ $numFail -gt 0 ]; then 29 | message="$output 30 | Result: FAIL, $numFail tests failed" 31 | TestOutput "Correctness" "Student Test Suite" false "$message" 32 | elif [ $numPass -lt $numExpected ]; then 33 | message="$output 34 | Result: FAIL, $numPass tests passsed, but expected at least $numExpected" 35 | TestOutput "Correctness" "Student Test Suite" false "$message" 36 | else 37 | message="Result: PASS, $numPass tests passsed" 38 | TestOutput "Correctness" "Student Test Suite" true "$message" 39 | fi 40 | -------------------------------------------------------------------------------- /codepost/java_templates/build_test.sh: -------------------------------------------------------------------------------- 1 | ####################################################################################### 2 | # This file will be run from main.sh. Create test results by calling the following function: 3 | # TestOutput 4 | ###################################################################################### 5 | 6 | # this could be done in a loop if multiple source files are present 7 | # however, a single test should be created for each part to communicate 8 | # which source files have warnings or issues 9 | baseClass="CLASS" 10 | package="unl.soc" 11 | classPath="./unl/soc/CLASS.class" 12 | #compile redirecting stderr to stdout 13 | result=$(javac -nowarn -cp . -d . $baseClass.java 2>&1) 14 | 15 | #if result is not empty 16 | if [[ ! -z "$result" ]]; then 17 | message="Your code does not appear to compile: 18 | $result" 19 | #echo "$message" 20 | TestOutput "Build Tests" "Compiler Output" false "$message" 21 | elif [[ ! -f "$classPath" ]]; then 22 | message="Your code appears to have compiled but the class file cannot be found; be sure you are using the expected package: $package" 23 | #echo "$message" 24 | TestOutput "Build Tests" "Compiler Output" false "$message" 25 | else 26 | message="Your code compiles with no errors." 27 | #echo "$message" 28 | TestOutput "Build Tests" "Compiler Output" true "$message" 29 | fi 30 | -------------------------------------------------------------------------------- /codepost/java_templates/build_warnings_test.sh: -------------------------------------------------------------------------------- 1 | ####################################################################################### 2 | # This file will be run from main.sh. Create test results by calling the following function: 3 | # TestOutput 4 | ###################################################################################### 5 | 6 | # this could be done in a loop if multiple source files are present 7 | # however, a single test should be created for each part to communicate 8 | # which source files have warnings or issues 9 | baseClass="CLASS" 10 | package="unl.soc" 11 | classPath="./unl/soc/CLASS.class" 12 | #compile redirecting stderr to stdout 13 | result=$(javac -Xlint:all -cp . -d . $baseClass.java 2>&1) 14 | 15 | #if result is not empty 16 | if [[ ! -z "$result" ]]; then 17 | message="Your code does not appear to compile or compiles with warnings: 18 | $result" 19 | #echo "$message" 20 | TestOutput "Build Tests" "Compiler Warnings" false "$message" 21 | elif [[ ! -f "$classPath" ]]; then 22 | message="Your code appears to have compiled but the class file cannot be found; be sure you are using the expected package: $package" 23 | #echo "$message" 24 | TestOutput "Build Tests" "Compiler Warnings" false "$message" 25 | else 26 | message="Your code compiles with no errors or warnings." 27 | #echo "$message" 28 | TestOutput "Build Tests" "Compiler Warnings" true "$message" 29 | fi 30 | -------------------------------------------------------------------------------- /codepost/java_templates/junit_test_suite.sh: -------------------------------------------------------------------------------- 1 | ####################################################################################### 2 | # This file will be run from main.sh. Create test results by calling the following function: 3 | # TestOutput 4 | ###################################################################################### 5 | 6 | # Convention: exit code 7 | # This script is intended to run self-contained test suites, either 8 | # ad-hoc or cmocka suites. 9 | # 10 | # The exit code is used to determine pass/failure of the codepost.io 11 | # test. 12 | # - our convention: 13 | # - by default it will report number of failed tests (0 all pass) 14 | # - via CLA "-reportPass" it will report the total passed 15 | # Thus we run it twice and capture both values 16 | 17 | numExpected=100 18 | #we don't run the standalone, we just use it; we want the 19 | # ability to report number of passed/failed tests as exit codes... 20 | executeCmd='java -cp .:./junit-platform-console-standalone-1.9.2.jar unl.soc.TestWrapper unl.soc.ColorUtilsTests' 21 | input='' 22 | ## Alternative: CLAs 23 | output=$($executeCmd $input 2>&1) 24 | numFail=$(($?)) 25 | input='-reportPass' 26 | output=$($executeCmd $input 2>&1) 27 | numPass=$(($?)) 28 | 29 | if [ $numFail -gt 0 ]; then 30 | message="$output 31 | Result: FAIL, $numFail tests failed" 32 | TestOutput "Correctness" "JUnit Test Suite" false "$message" 33 | elif [ $numPass -lt $numExpected ]; then 34 | message="$output 35 | Result: FAIL, $numPass tests passsed, but expected at least $numExpected" 36 | TestOutput "Correctness" "JUnit Test Suite" false "$message" 37 | else 38 | message="Result: PASS, $numPass tests passsed" 39 | TestOutput "Correctness" "JUnit Test Suite" true "$message" 40 | fi 41 | -------------------------------------------------------------------------------- /codepost/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Notes 4 | -------------------------------------------------------------------------------- /documents/TheTaoOfTALC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/TheTaoOfTALC.pdf -------------------------------------------------------------------------------- /documents/byod.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/byod.pdf -------------------------------------------------------------------------------- /documents/codeUsageGuidelines.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/codeUsageGuidelines.pdf -------------------------------------------------------------------------------- /documents/instructor.md: -------------------------------------------------------------------------------- 1 | 2 | # Instructor Notes & Resources 3 | 4 | ## Course Setup Checklist 5 | 6 | * Admin 7 | * Finalize syllabus 8 | * finalize Help Hours 9 | * Setup recurring reminders 10 | 11 | * LAP/Logistics 12 | * Retrieve roster data (name, NUID, unl email, photo, bio, lab availability, office hours) 13 | * Assign Labs 14 | * Office Hour grid 15 | * Update instructor page in canvas 16 | 17 | * Github/YouTube 18 | * Create new playlists 19 | * Update readme (YouTube playlist, canvas link) 20 | * Update syllabus 21 | 22 | * Canvas 23 | * Course Copy 24 | * Update front page (schedule) 25 | * Update assignments (due dates) 26 | * Add TAs 27 | * Hook in zybook readings 28 | * Publish 29 | 30 | * Codepost Setup 31 | * Copy, update course, set time zone 32 | * Copy Assignments 33 | * Clone 34 | * Update due date/time 35 | * Update/fix file name requirements 36 | * Initialize container/tests 37 | * Setup scripts (keys, NUIDs) 38 | * Import roster 39 | * Send notification 40 | 41 | * Forum Setup (campuswire) 42 | * Create course 43 | * Setup categories 44 | * Import LAs 45 | * TA welcome message 46 | * Import students 47 | * Student welcome message 48 | 49 | * Logistics 50 | * Unify rosters: MyRed, Canvas 51 | * Create new Microsoft group 52 | * Update QC sheet 53 | * Update Attendance sheet 54 | 55 | ## Resources 56 | 57 | * zyBooks linking instructions: https://zybooks.zendesk.com/hc/en-us/articles/4402955317531-How-to-link-a-zyBook-assignment-section-TOC-to-an-LMS-#h_01F9ERPSS67RTTNJ7CZWHK34QW 58 | 59 | ### UNO Resources 60 | 61 | * Course Portal 62 | * MavLink: https://www.unomaha.edu/my/mavlink.php 63 | 64 | * Bookstore 65 | * URL: https://textreq.prismservices.net/v3.0/Login.aspx?bookstore_id=5080 66 | * Contact: 402.554.2336 67 | -------------------------------------------------------------------------------- /documents/iticse-7steps.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/iticse-7steps.pdf -------------------------------------------------------------------------------- /documents/misc/Activating-Huskers-Email.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/misc/Activating-Huskers-Email.pdf -------------------------------------------------------------------------------- /documents/misc/CanvasForUNO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/misc/CanvasForUNO.pdf -------------------------------------------------------------------------------- /documents/mrc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/mrc.jpg -------------------------------------------------------------------------------- /documents/rubric.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/rubric.pdf -------------------------------------------------------------------------------- /documents/teOfCSE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/teOfCSE.pdf -------------------------------------------------------------------------------- /documents/tipsForOnline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/tipsForOnline.pdf -------------------------------------------------------------------------------- /documents/troubleShooting.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/documents/troubleShooting.pdf -------------------------------------------------------------------------------- /hacks/hack-debugging/primesProgram-buggy.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This program computes the sum of the first n 3 | * prime numbers. Optionally, it allows the user 4 | * to provide n as a command line argument, but 5 | * defaults to the first n = 10 primes 6 | */ 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * This function takes an integer array (of size n) and 13 | * returns the sum of its elements. It returns 0 if the 14 | * array is NULL or if its size is <= 0 15 | */ 16 | int sum(int *arr, int n); 17 | 18 | /** 19 | * This function returns an array containing the first 20 | * n prime numbers 21 | */ 22 | int* getPrimes(int n); 23 | 24 | /** 25 | * This function determines returns true if the give 26 | * integer is prime and false otherwise. 27 | */ 28 | int isPrime(int x); 29 | 30 | int main(int argc, char **argv) { 31 | 32 | int n = 10; //default to the first 10 primes 33 | if(argc = 2) { 34 | atoi(argv[2]); 35 | } 36 | int *primes = getPrimes(n); 37 | 38 | int s = sum(primes, n); 39 | printf("The sum of the first %d primes is %d\n", n, s); 40 | 41 | return 0; 42 | } 43 | 44 | int sum(int *arr, int n) { 45 | int i; 46 | int total; 47 | for(i=0; i 8 | #include 9 | #include 10 | 11 | /** 12 | * This function takes an integer array (of size n) and 13 | * returns the sum of its elements. It returns 0 if the 14 | * array is NULL or if its size is <= 0 15 | */ 16 | int sum(int *arr, int n); 17 | 18 | /** 19 | * This function returns an array containing the first 20 | * n prime numbers 21 | */ 22 | int* getPrimes(int n); 23 | 24 | /** 25 | * This function determines returns true if the give 26 | * integer is prime and false otherwise. 27 | */ 28 | int isPrime(int x); 29 | 30 | int main(int argc, char **argv) { 31 | 32 | int n = 10; //default to the first 10 primes 33 | if(argc == 2) { 34 | n = atoi(argv[1]); 35 | } 36 | int *primes = getPrimes(n); 37 | 38 | int s = sum(primes, n); 39 | printf("The sum of the first %d primes is %d\n", n, s); 40 | 41 | return 0; 42 | } 43 | 44 | int sum(int *arr, int n) { 45 | int i; 46 | int total = 0; 47 | for(i=0; i 8 | #include 9 | 10 | #include "protein_utils.h" 11 | 12 | int main(int argc, char **argv) { 13 | 14 | if(argc != 2) { 15 | fprintf(stderr, "Usage: %s RNATrigram\n", argv[0]); 16 | exit(1); 17 | } 18 | 19 | char prot = rnaToProtein(argv[1]); 20 | 21 | if(prot == '\0') { 22 | printf(" \"%s\" is an invalid RNA trigram\n", argv[1]); 23 | } else { 24 | printf("%s -> %c\n", argv[1], prot); 25 | } 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /hacks/hack10.0/protein_utils.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "protein_utils.h" 6 | 7 | char rnaToProtein(const char *rna) { 8 | if(rna == NULL || strlen(rna) != 3) { 9 | return 0; 10 | } 11 | ProteinMap key = { "", '\0' }; 12 | strcpy(key.trigram, rna); 13 | ProteinMap *match = bsearch(&key, pMap, NUM_TRIGRAMS, sizeof(ProteinMap), proteinMapComp); 14 | return (match == NULL) ? 0 : match->protein; 15 | 16 | } 17 | 18 | int proteinMapComp(const void *a, const void *b) { 19 | const ProteinMap *x = (const ProteinMap *) a; 20 | const ProteinMap *y = (const ProteinMap *) b; 21 | return strcmp(x->trigram, y->trigram); 22 | } 23 | -------------------------------------------------------------------------------- /hacks/hack10.0/protein_utils.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * A structure to model an RNA-to-Protein translation 4 | * Each RNA trigram is translated into a single character 5 | * protein 6 | */ 7 | typedef struct { 8 | char trigram[4]; 9 | char protein; 10 | } ProteinMap; 11 | 12 | #define NUM_TRIGRAMS 64 13 | 14 | /** 15 | * This is an array of ProteinMap elements which 16 | * map a trigram to a protein. The array is presorted 17 | * to allow an efficient binary search. 18 | */ 19 | static const ProteinMap pMap[] = { 20 | { "AAA", 'K' }, 21 | { "AAC", 'N' }, 22 | { "AAG", 'K' }, 23 | { "AAU", 'N' }, 24 | { "ACA", 'T' }, 25 | { "ACC", 'T' }, 26 | { "ACG", 'T' }, 27 | { "ACU", 'T' }, 28 | { "AGA", 'R' }, 29 | { "AGC", 'S' }, 30 | { "AGG", 'R' }, 31 | { "AGU", 'S' }, 32 | { "AUA", 'I' }, 33 | { "AUC", 'I' }, 34 | { "AUG", 'M' }, 35 | { "AUU", 'I' }, 36 | { "CAA", 'Q' }, 37 | { "CAC", 'H' }, 38 | { "CAG", 'Q' }, 39 | { "CAU", 'H' }, 40 | { "CCA", 'P' }, 41 | { "CCC", 'P' }, 42 | { "CCG", 'P' }, 43 | { "CCU", 'P' }, 44 | { "CGA", 'R' }, 45 | { "CGC", 'R' }, 46 | { "CGG", 'R' }, 47 | { "CGU", 'R' }, 48 | { "CUA", 'L' }, 49 | { "CUC", 'L' }, 50 | { "CUG", 'L' }, 51 | { "CUU", 'L' }, 52 | { "GAA", 'E' }, 53 | { "GAC", 'D' }, 54 | { "GAG", 'E' }, 55 | { "GAU", 'D' }, 56 | { "GCA", 'A' }, 57 | { "GCC", 'A' }, 58 | { "GCG", 'A' }, 59 | { "GCU", 'A' }, 60 | { "GGA", 'G' }, 61 | { "GGC", 'G' }, 62 | { "GGG", 'G' }, 63 | { "GGU", 'G' }, 64 | { "GUA", 'V' }, 65 | { "GUC", 'V' }, 66 | { "GUG", 'V' }, 67 | { "GUU", 'V' }, 68 | { "UAA", 'x' }, 69 | { "UAC", 'Y' }, 70 | { "UAG", 'x' }, 71 | { "UAU", 'Y' }, 72 | { "UCA", 'S' }, 73 | { "UCC", 'S' }, 74 | { "UCG", 'S' }, 75 | { "UCU", 'S' }, 76 | { "UGA", 'x' }, 77 | { "UGC", 'C' }, 78 | { "UGG", 'W' }, 79 | { "UGU", 'C' }, 80 | { "UUA", 'L' }, 81 | { "UUC", 'F' }, 82 | { "UUG", 'L' }, 83 | { "UUU", 'F' }, 84 | }; 85 | 86 | /** 87 | * An RNA-to-protein translator function. 88 | * The input is a string containing a valid RNA trigram 89 | * (a 3 character sequence consisting of A, G, C, or U) 90 | * The function returns a single character corresponding 91 | * to the translated protein. 92 | * 93 | * This function returns the null byte character, '\0' if 94 | * the given RNA string is invalid. 95 | */ 96 | char rnaToProtein(const char *rna); 97 | 98 | /** 99 | * A comparator used by getProtein to perform a 100 | * binary search of predefined ProteinMap structures 101 | */ 102 | int proteinMapComp(const void *a, const void *b); 103 | -------------------------------------------------------------------------------- /hacks/hack11.0/airport.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a collection of utility functions involving 3 | * and airport structure. 4 | */ 5 | 6 | typedef struct { 7 | // TODO: design your structure 8 | } Airport; 9 | 10 | /** 11 | * A factory function to create a new Airport with the given 12 | * attributes. This function should make *deep* copies of each 13 | * of the relevant fields and return a pointer to the newly 14 | * created Airport structure. 15 | */ 16 | Airport* createAirport(const char* gpsId, 17 | const char* type, 18 | const char* name, 19 | double latitude, 20 | double longitude, 21 | int elevationFeet, 22 | const char* city, 23 | const char* countryAbbrv); 24 | 25 | /** 26 | * This function initializes an existing allocated 27 | * Airport structure with the given attributes. This 28 | * function should make *deep* copies of each of the 29 | * relevant fields. 30 | */ 31 | void initAirport(Airport* airport, 32 | const char* gpsId, 33 | const char* type, 34 | const char* name, 35 | double latitude, 36 | double longitude, 37 | int elevationFeet, 38 | const char* city, 39 | const char* countryAbbrv); 40 | 41 | /** 42 | * Constructs a new string representation of the given 43 | * Airport structure. 44 | */ 45 | char* airportToString(const Airport* a); 46 | 47 | /** 48 | * Computes the air distance, in kilometers, between 49 | * the two Airports using their latitude/longitude 50 | */ 51 | double getAirDistance(const Airport* origin, const Airport* destination); 52 | 53 | /** 54 | * Computes the estimated travel time (in hours) for a flight 55 | * that involves the given stops (an array of Airport structures 56 | * of the given size) using the average flight speed 57 | * (kilometers per hour). Thus there are size - 1 "legs" of the 58 | * trip. 59 | * 60 | * The first stop is the origin and the last stop is the destination. 61 | * Each stop in between is a layover each incurring a wait time 62 | * of aveLayoverTimeHrs 63 | */ 64 | double getEstimatedTravelTime(const Airport* stops, 65 | int size, 66 | double aveKmsPerHour, 67 | double aveLayoverTimeHrs); 68 | -------------------------------------------------------------------------------- /hacks/hack13.0/airport.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "airport.h" 5 | 6 | void generateReports(Airport *airports, int n) { 7 | 8 | printf("Airports (original): \n"); 9 | printf("==============================\n"); 10 | printAirports(airports, n); 11 | 12 | printf("\nAirports By GPS ID: \n"); 13 | printf("==============================\n"); 14 | 15 | printf("\nAirports By Type: \n"); 16 | printf("==============================\n"); 17 | 18 | printf("\nAirports By Name: \n"); 19 | printf("==============================\n"); 20 | 21 | printf("\nAirports By Name - Reversed: \n"); 22 | printf("==============================\n"); 23 | 24 | printf("\nAirports By Country/City: \n"); 25 | printf("==============================\n"); 26 | 27 | printf("\nAirports By Latitude: \n"); 28 | printf("==============================\n"); 29 | 30 | printf("\nAirports By Longitude: \n"); 31 | printf("==============================\n"); 32 | 33 | printf("\nAirports By Distance from Lincoln: \n"); 34 | printf("==============================\n"); 35 | 36 | printf("\nClosest Airport to Lincoln: \n"); 37 | printf("==============================\n"); 38 | 39 | printf("\nFurthest Airport from Lincoln: \n"); 40 | printf("==============================\n"); 41 | 42 | printf("\nEast-West Geographic Center: \n"); 43 | printf("==============================\n"); 44 | 45 | printf("\nNew York, NY airport: \n"); 46 | printf("==============================\n"); 47 | //if none found, print: "No New York airport found!\n" 48 | 49 | printf("\nLarge airport: \n"); 50 | printf("==============================\n"); 51 | //if none found, print: "No large airport found!\n" 52 | 53 | 54 | return; 55 | } 56 | 57 | char* airportToString(const Airport* a) { 58 | char temp[1000]; 59 | //this formatting is required but the code may need to be adapted 60 | // to your definiion of your Airport structure. 61 | sprintf(temp, "%-8s %-15s %-20s %.2f %.2f %d %-10s %-2s", a->gpsId, a->type, a->name, 62 | a->latitude, a->longitude, a->elevationFeet, a->city, 63 | a->countryAbbrv); 64 | char* result = (char*)malloc(sizeof(char) * (strlen(temp) + 1)); 65 | strcpy(result, temp); 66 | return result; 67 | } 68 | 69 | void printAirports(Airport *airports, int n) { 70 | 71 | for(int i=0; i proteinMap = new HashMap<>(); 15 | 16 | static { 17 | 18 | proteinMap.put("AAA", 'K'); 19 | proteinMap.put("AAC", 'N'); 20 | proteinMap.put("AAG", 'K'); 21 | proteinMap.put("AAU", 'N'); 22 | proteinMap.put("ACA", 'T'); 23 | proteinMap.put("ACC", 'T'); 24 | proteinMap.put("ACG", 'T'); 25 | proteinMap.put("ACU", 'T'); 26 | proteinMap.put("AGA", 'R'); 27 | proteinMap.put("AGC", 'S'); 28 | proteinMap.put("AGG", 'R'); 29 | proteinMap.put("AGU", 'S'); 30 | proteinMap.put("AUA", 'I'); 31 | proteinMap.put("AUC", 'I'); 32 | proteinMap.put("AUG", 'M'); 33 | proteinMap.put("AUU", 'I'); 34 | proteinMap.put("CAA", 'Q'); 35 | proteinMap.put("CAC", 'H'); 36 | proteinMap.put("CAG", 'Q'); 37 | proteinMap.put("CAU", 'H'); 38 | proteinMap.put("CCA", 'P'); 39 | proteinMap.put("CCC", 'P'); 40 | proteinMap.put("CCG", 'P'); 41 | proteinMap.put("CCU", 'P'); 42 | proteinMap.put("CGA", 'R'); 43 | proteinMap.put("CGC", 'R'); 44 | proteinMap.put("CGG", 'R'); 45 | proteinMap.put("CGU", 'R'); 46 | proteinMap.put("CUA", 'L'); 47 | proteinMap.put("CUC", 'L'); 48 | proteinMap.put("CUG", 'L'); 49 | proteinMap.put("CUU", 'L'); 50 | proteinMap.put("GAA", 'E'); 51 | proteinMap.put("GAC", 'D'); 52 | proteinMap.put("GAG", 'E'); 53 | proteinMap.put("GAU", 'D'); 54 | proteinMap.put("GCA", 'A'); 55 | proteinMap.put("GCC", 'A'); 56 | proteinMap.put("GCG", 'A'); 57 | proteinMap.put("GCU", 'A'); 58 | proteinMap.put("GGA", 'G'); 59 | proteinMap.put("GGC", 'G'); 60 | proteinMap.put("GGG", 'G'); 61 | proteinMap.put("GGU", 'G'); 62 | proteinMap.put("GUA", 'V'); 63 | proteinMap.put("GUC", 'V'); 64 | proteinMap.put("GUG", 'V'); 65 | proteinMap.put("GUU", 'V'); 66 | proteinMap.put("UAA", 'x'); 67 | proteinMap.put("UAC", 'Y'); 68 | proteinMap.put("UAG", 'x'); 69 | proteinMap.put("UAU", 'Y'); 70 | proteinMap.put("UCA", 'S'); 71 | proteinMap.put("UCC", 'S'); 72 | proteinMap.put("UCG", 'S'); 73 | proteinMap.put("UCU", 'S'); 74 | proteinMap.put("UGA", 'x'); 75 | proteinMap.put("UGC", 'C'); 76 | proteinMap.put("UGG", 'W'); 77 | proteinMap.put("UGU", 'C'); 78 | proteinMap.put("UUA", 'L'); 79 | proteinMap.put("UUC", 'F'); 80 | proteinMap.put("UUG", 'L'); 81 | proteinMap.put("UUU", 'F'); 82 | } 83 | 84 | public static void main(String args[]) { 85 | //an example of how to use the map: 86 | String codon = "GGU"; 87 | char protein = proteinMap.get(codon); 88 | System.out.println(codon + " translates to " + protein); 89 | 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /honors/hacks/hack10.0/examples/dnaSample001.txt: -------------------------------------------------------------------------------- 1 | AAATTCCGCGTACCCTAG 2 | -------------------------------------------------------------------------------- /honors/hacks/hack10.0/examples/dnaSample002.txt: -------------------------------------------------------------------------------- 1 | TTCCTCTTTCTCGACTCCATCTTCGCGGTAGCTGGGACCGCCGTTCAGTCGCCAATATGCAGCTCTTTGTCCGCGCCCA 2 | GGAGCTACACACCTTCGAGGTGACCGGCCAGGAAACGGTCGCCCAGATCAAGGCTCATGTAGCCTCACTGGAGGGCATT 3 | GCCCCGGAAGATCAAGTCGTGCTCCTGGCAGGCGCGCCCCTGGAGGATGAGGCCACTCTGGGCCAGTGCGGGGTGGAGG 4 | CCCTGACTACCCTGGAAGTAGCAGGCCGCATGCTTGGAGGTAAAGTTCATGGTTCCCTGGCCCGTGCTGGAAAAGTGAG 5 | AGGTCAGACTCCTAAGGTGGCCAAACAGGAGAAGAAGAAGAAGAAGACAGGTCGGGCTAAGCGGCGGATGCAGTACAAC 6 | CGGCGCTTTGTCAACGTTGTGCCCACCTTTGGCAAGAAGAAGGGCCCCAATGCCAACTCTTAAGTCTTTTGTAATTCTG 7 | GCTTTCTCTAATAAAAAAGCCACTTAGTTCAGTCAAAAAAAAAA 8 | -------------------------------------------------------------------------------- /honors/hacks/hack10.0/examples/proteinResult001.txt: -------------------------------------------------------------------------------- 1 | KFRVP 2 | -------------------------------------------------------------------------------- /honors/hacks/hack10.0/examples/proteinResult002.txt: -------------------------------------------------------------------------------- 1 | FLFLDSIFAVAGTAVQSPICSSLSAPRSYTPSR 2 | -------------------------------------------------------------------------------- /honors/hacks/hack11.0/Airport.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * TODO: documentation 7 | * 8 | */ 9 | public class Airport { 10 | 11 | //TODO: define your member variables and methods 12 | 13 | /** 14 | * Required constructor 15 | * TODO: add documentation, implement 16 | */ 17 | public Airport(String gpsId, String name, double latitude, double longitude, String type, int elevationFeet, 18 | String city, String country) { 19 | } 20 | 21 | /** 22 | * Computes the air distance, in kilometers, from this 23 | * airport to the given destination using their latitude/longitude 24 | * and the 25 | * Spherical 26 | * Law of Cosines. 27 | */ 28 | public double getAirDistance(Airport destination) { 29 | //TODO: implement 30 | return -1.0; 31 | } 32 | 33 | /** 34 | * Computes the estimated travel time (in hours) for a flight that involves the 35 | * given stops using the average flight speed (kilometers per hour) and average 36 | * layover time (in hours) 37 | */ 38 | public static double getEstimatedTravelTime(List stops, double aveKmsPerHour, double aveLayoverTimeHrs) { 39 | //TODO: implement 40 | return -1.0; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /honors/hacks/hack6.0/CMYK.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | /** 4 | * A CMYK (Cyan-Magenta-Yellow-Black) color object. 5 | * 6 | */ 7 | public class CMYK { 8 | 9 | private double cyan; 10 | private double magenta; 11 | private double yellow; 12 | private double k; 13 | 14 | public CMYK(double cyan, double magenta, double yellow, double k) { 15 | this.cyan = cyan; 16 | this.magenta = magenta; 17 | this.yellow = yellow; 18 | this.k = k; 19 | } 20 | 21 | public double getCyan() { 22 | return cyan; 23 | } 24 | 25 | public double getMagenta() { 26 | return magenta; 27 | } 28 | 29 | public double getYellow() { 30 | return yellow; 31 | } 32 | 33 | public double getK() { 34 | return k; 35 | } 36 | 37 | public String toString() { 38 | return "(" + this.cyan + ", " + this.magenta + ", " + this.yellow + ", " + k + ")"; 39 | } 40 | 41 | @Override 42 | public int hashCode() { 43 | final int prime = 31; 44 | int result = 1; 45 | long temp; 46 | temp = Double.doubleToLongBits(cyan); 47 | result = prime * result + (int) (temp ^ (temp >>> 32)); 48 | temp = Double.doubleToLongBits(k); 49 | result = prime * result + (int) (temp ^ (temp >>> 32)); 50 | temp = Double.doubleToLongBits(magenta); 51 | result = prime * result + (int) (temp ^ (temp >>> 32)); 52 | temp = Double.doubleToLongBits(yellow); 53 | result = prime * result + (int) (temp ^ (temp >>> 32)); 54 | return result; 55 | } 56 | 57 | @Override 58 | public boolean equals(Object obj) { 59 | if (this == obj) 60 | return true; 61 | if (obj == null) 62 | return false; 63 | if (getClass() != obj.getClass()) 64 | return false; 65 | CMYK other = (CMYK) obj; 66 | if (Double.doubleToLongBits(cyan) != Double 67 | .doubleToLongBits(other.cyan)) 68 | return false; 69 | if (Double.doubleToLongBits(k) != Double.doubleToLongBits(other.k)) 70 | return false; 71 | if (Double.doubleToLongBits(magenta) != Double 72 | .doubleToLongBits(other.magenta)) 73 | return false; 74 | if (Double.doubleToLongBits(yellow) != Double 75 | .doubleToLongBits(other.yellow)) 76 | return false; 77 | return true; 78 | } 79 | 80 | public static void main(String args[]) { 81 | //create a new color object: 82 | CMYK myColor = new CMYK(.25, .75, .50, 0.0); 83 | CMYK red = new CMYK(0.0, .99, 1.0, 0.0); 84 | 85 | // you can get the red, green and blue values: 86 | System.out.println("cyan = " + myColor.getCyan()); 87 | System.out.println("magenta = " + myColor.getMagenta()); 88 | System.out.println("yellow = " + myColor.getYellow()); 89 | System.out.println("k = " + myColor.getK()); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /honors/hacks/hack6.0/RGB.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | /** 4 | * An RGB (Red-Green-Blue) color object. 5 | * 6 | */ 7 | public class RGB { 8 | 9 | private int red; 10 | private int green; 11 | private int blue; 12 | 13 | public RGB(int red, int green, int blue) { 14 | this.red = red; 15 | this.green = green; 16 | this.blue = blue; 17 | } 18 | 19 | public int getRed() { 20 | return red; 21 | } 22 | 23 | public int getGreen() { 24 | return green; 25 | } 26 | 27 | public int getBlue() { 28 | return blue; 29 | } 30 | 31 | public String toString() { 32 | return "(" + this.red + ", " + this.green + ", " + this.blue + ")"; 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | final int prime = 31; 38 | int result = 1; 39 | result = prime * result + blue; 40 | result = prime * result + green; 41 | result = prime * result + red; 42 | return result; 43 | } 44 | 45 | @Override 46 | public boolean equals(Object obj) { 47 | if (this == obj) 48 | return true; 49 | if (obj == null) 50 | return false; 51 | if (getClass() != obj.getClass()) 52 | return false; 53 | RGB other = (RGB) obj; 54 | if (blue != other.blue) 55 | return false; 56 | if (green != other.green) 57 | return false; 58 | if (red != other.red) 59 | return false; 60 | return true; 61 | } 62 | 63 | public static void main(String args[]) { 64 | //create a new color object: 65 | RGB myColor = new RGB(100, 125, 25); 66 | RGB red = new RGB(255, 0, 0); 67 | 68 | // you can get the individual red, green and blue values 69 | // using the .get methods: 70 | System.out.println("red = " + myColor.getRed()); 71 | System.out.println("green = " + myColor.getGreen()); 72 | System.out.println("blue = " + myColor.getBlue()); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /honors/hacks/hack7.0/ImageDriver.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | public class ImageDriver { 4 | 5 | public static void main(String args[]) { 6 | 7 | RGB original[][] = ImageUtils.loadImage("images/pointers.png"); 8 | 9 | // TODO: perform any method calls here; example: 10 | RGB rotated[][] = ImageUtils.rotateClockwise(original); 11 | ImageUtils.saveImage("images/rotated.jpg", rotated); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /honors/hacks/hack7.0/RGB.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | /** 4 | * An RGB (Red-Green-Blue) color object. 5 | * 6 | */ 7 | public class RGB { 8 | 9 | private int red; 10 | private int green; 11 | private int blue; 12 | 13 | public RGB(int red, int green, int blue) { 14 | this.red = red; 15 | this.green = green; 16 | this.blue = blue; 17 | } 18 | 19 | public int getRed() { 20 | return red; 21 | } 22 | 23 | public int getGreen() { 24 | return green; 25 | } 26 | 27 | public int getBlue() { 28 | return blue; 29 | } 30 | 31 | public String toString() { 32 | return "(" + this.red + ", " + this.green + ", " + this.blue + ")"; 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | final int prime = 31; 38 | int result = 1; 39 | result = prime * result + blue; 40 | result = prime * result + green; 41 | result = prime * result + red; 42 | return result; 43 | } 44 | 45 | @Override 46 | public boolean equals(Object obj) { 47 | if (this == obj) 48 | return true; 49 | if (obj == null) 50 | return false; 51 | if (getClass() != obj.getClass()) 52 | return false; 53 | RGB other = (RGB) obj; 54 | if (blue != other.blue) 55 | return false; 56 | if (green != other.green) 57 | return false; 58 | if (red != other.red) 59 | return false; 60 | return true; 61 | } 62 | 63 | public static void main(String args[]) { 64 | //create a new color object: 65 | RGB myColor = new RGB(100, 125, 25); 66 | RGB red = new RGB(255, 0, 0); 67 | 68 | // you can get the individual red, green and blue values 69 | // using the .get methods: 70 | System.out.println("red = " + myColor.getRed()); 71 | System.out.println("green = " + myColor.getGreen()); 72 | System.out.println("blue = " + myColor.getBlue()); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /honors/hacks/hack7.0/images/pointers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/honors/hacks/hack7.0/images/pointers.png -------------------------------------------------------------------------------- /honors/hacks/hack7.0/images/pointersHFlip.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/honors/hacks/hack7.0/images/pointersHFlip.jpg -------------------------------------------------------------------------------- /honors/hacks/hack7.0/images/pointersRotated.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/honors/hacks/hack7.0/images/pointersRotated.jpg -------------------------------------------------------------------------------- /honors/hacks/hack7.0/images/pointersVFlip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/honors/hacks/hack7.0/images/pointersVFlip.png -------------------------------------------------------------------------------- /honors/hacks/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Hacks 3 | 4 | Hacks are weekly programming assignments used in CSCE 155E 5 | (C version) and CSCE 155H (Java version). 6 | 7 | * Hack 1.0 - Introduction to Git 8 | * Hack 2.0 - Basic I/O (air distance program) 9 | * Hack 3.0 - Conditionals (data plan usage) 10 | * Hack 4.0 - Loops (retirement savings) 11 | * Hack 5.0 - Methods, Testing 12 | * Hack 6.0 - Methods, Error Handling & Unit Testing 13 | * Hack 7.0 - Lists and Arrays 14 | * Hack - Strings 15 | * Hack 10.0 - File I/O 16 | * Hack 11.0 - Encapsulation (airport object design) 17 | * Hack 12.0 - Recursion 18 | * Hack 13.0 - Searching & Sorting (airport sorting) 19 | * Hack 14.0 - Final Project (design) 20 | -------------------------------------------------------------------------------- /notes/1198-Fall2019/01-introduction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/notes/1198-Fall2019/01-introduction.pdf -------------------------------------------------------------------------------- /notes/1198-Fall2019/11-recursion.md: -------------------------------------------------------------------------------- 1 | # CSCE 155E - Computer Science I 2 | #### Recursion 3 | 4 | * What is recursion? 5 | * In general, *recursion* is something that references itself 6 | * Example: fractals 7 | * Fibonacci sequence: 8 | 9 | $$\begin{equation*} 10 | f(n) = \begin{cases} 11 | 1 & n = 0\\ 12 | 1 & n = 1\\ 13 | f(n-1) + f(n-2) & \text{otherwise} 14 | \end{cases} 15 | \end{equation*}$$ 16 | 17 | $$1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, \ldots$$ 18 | 19 | 20 | ```c 21 | void countDown(int n) { 22 | 23 | if(n == 0) { 24 | printf("blastoff!\n"); 25 | return; 26 | } else if(n > 0) { 27 | printf("%d\n", n); 28 | countDown(n-1); 29 | } 30 | 31 | } 32 | 33 | countDown(10); 34 | ``` 35 | 36 | * IN the context of coding, recursion simply means when a function makes one or more calls to itself! 37 | 38 | ## Parts of Recursion 39 | 40 | * Every recursive function needs at least one *base case*: a case in which no recursive calls are made: infinite recursion 41 | * Each recursive function call should make progress towards the base case 42 | * Corner cases may need to be handled separately (error handling) 43 | 44 | ## Recursion: Good? 45 | 46 | * Recursion *can* be a "useful" and "good" tool: 47 | * Many divide and conquer algorithms are usually presented as recursive 48 | * Many functional programming languages require recursion or highly discourage the use of loops 49 | * Recursion can lead to "simple", "clean", "beautiful" code that is easily understood 50 | 51 | ## Recursion: Bad? 52 | 53 | * Recursive function essentially abuse the stack space 54 | * Risks stack overflow for "deep recursions" 55 | * In general recursion is not needed: any recursive function can be rewritten as a non-recursive function using a loop or a stack, etc. 56 | * Recursion can often be *simulated* using an in-memory stack 57 | * Some organizations even BAN recursion (NASA) 58 | * Recursion also risks needlessly recomputing values over and over and over 59 | 60 | ## Eliminating Recursion 61 | 62 | * In general, you can always rewrite a recursive function 63 | * You can also use *memoization*: 64 | * If you need to compute a value, you "pay" for the recursion 65 | * But, each value you compute: you save it (in table): ie you *cache* previously computed values 66 | * Demonstration: recompute the fibonacci sequence using memoization 67 | 68 | ## Hack 12 69 | 70 | * You'll compute how long it would take to compute binomial coefficients recursively 71 | * You'll replace recursive code with *memoization* code 72 | * Given n elements, {a, b, c, d, ...} how many ways are there of choosing k of them? (how many subsets of size k are there?) 73 | * 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /notes/1198-Fall2019/databases/books.csv: -------------------------------------------------------------------------------- 1 | Course,Title,Author(s),Topic(s),URL 2 | CSCE 155A,Thinking in Java,"Eckel, Bruce",Java,http://www.mindview.net/Books/TIJ/ 3 | CSCE 155A,Introduction to Programming Using Java,"Eck, David J.",Java,http://math.hws.edu/javanotes/ 4 | CSCE 155A,Java Programming,,Java,https://en.wikibooks.org/wiki/Java_Programming 5 | CSCE 155E,C Programming,,C,https://en.wikibooks.org/wiki/C_Programming 6 | CSCE 155T,Dive Into Python,Mark Pilgrim,Python,http://www.diveintopython.net/toc/index.html 7 | CSCE 155T,Learn Python The Hard Way,Zed A. Shaw,Python,http://learnpythonthehardway.org/book/ 8 | CSCE 155T,Python for Informatics: Exploring Information,Charles Severance,Python,http://www.pythonlearn.com/book.php 9 | CSCE 156,Hacking With PHP,"Hudson, Paul",PHP,http://www.hackingwithphp.com/ 10 | CSCE 156,PHP Programming,,PHP,http://en.wikibooks.org/wiki/PHP_Programming 11 | CSCE 156,Data Structures and Algorithms with Object-Oriented Design Patterns in Java,"Preiss, Bruno","Data Structures, Java",http://www.brpreiss.com/books/opus5/ 12 | CSCE 156,MySQL Essentials,,SQL,http://www.techotopia.com/index.php/MySQL_Essentials 13 | CSCE 235,Book of Proof,Richard Hammack,Discrete Mathematics,http://www.people.vcu.edu/~rhammack/BookOfProof/ 14 | CSCE 235,Mathematics for Computer Science,Albert R. Meyer,Discrete Mathematics,https://www.seas.harvard.edu/courses/cs20/MIT6_042Notes.pdf 15 | CSCE 235,Notes on Discrete Mathematics,James Aspnes,Discrete Mathematics,http://www.cs.yale.edu/homes/aspnes/classes/202/notes.pdf 16 | CSCE 235,Discrete Mathematics,,Discrete Mathematics,https://en.wikibooks.org/wiki/Discrete_Mathematics 17 | CSCE 310,C Plus Plus,,C++,http://www.cplusplus.com/ 18 | CSCE 322,Prolog and Natural-Language Analysis,Fernando C. N. Pereira and Stuart M. Shieber,Prolog,http://mtome.com/Publications/PNLA/pnla.html 19 | CSCE 322,Learn You a Haskell for Great Good!,Miran Lipovaca,Haskell,http://learnyouahaskell.com/ 20 | CSCE 322,Haskell,,Haskell,http://en.wikibooks.org/wiki/Haskell 21 | CSCE 322,Learn Haskell Fast and Hard,,Haskell,http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/ 22 | CSCE 322,Prolog,,Prolog,http://en.wikibooks.org/wiki/Prolog 23 | CSCE 322,Learn Prolog Now!,Patrick Blackburn and Johan Bos and Kristina Striegnitz,Prolog,http://www.learnprolognow.org/ 24 | CSCE 322,Prolog Tutorial,R. J. Fisher,Prolog,http://www.cpp.edu/~jrfisher/www/prolog_tutorial/contents.html 25 | CSCE 477,Handbook of Applied Cryptography,"Menezes, Alfred J. and Vanstone, Scott A. and Oorschot, Paul C. Van",Cryptography,http://cacr.uwaterloo.ca/hac/ 26 | -------------------------------------------------------------------------------- /notes/1198-Fall2019/debugging.md: -------------------------------------------------------------------------------- 1 | 2 | # Debugging 3 | 4 | * Using `printf` statements to view the value(s) of variables is referred to as "poor man's" debugging 5 | * Using a proper *debugger* is better 6 | * A debugger is a program that simulates/runs another program and allows you to: 7 | * pause the execution 8 | * View variable values 9 | * "step" through the program line by line 10 | * set break points in a program and continue execution up to that point 11 | * GDB (Gnu's Debugger) is a command line debugger 12 | * Usage: 13 | * Compile with `-g` flag to preserve variable and function names 14 | `gcc -g arrayProgram.c` 15 | * Start GDB with your program: 16 | `gdb a.out` 17 | * Run your program: 18 | `run` 19 | * Set a break point: 20 | `break main` 21 | * See your code: 22 | `layout next` 23 | * Step: 24 | `next` (shorthand: `n`) 25 | * print a variable: 26 | `print foo` 27 | * print an array: 28 | `print *arr@len` 29 | * Set anothe break point base on a line number: 30 | `break 25` 31 | * Continue: 32 | `continue` 33 | * Watch a variable: 34 | `watch total` 35 | 36 | 37 | 38 | 39 | ```text 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | ``` 60 | -------------------------------------------------------------------------------- /notes/1198-Fall2019/recursionDemo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | long numFuncCalls = 0; 5 | 6 | long recursiveFibMem(int n, long *values) { 7 | numFuncCalls++; 8 | 9 | //if the table already has the value for fib(n): use it 10 | if(values[n] > 0) { 11 | return values[n]; 12 | } else { 13 | long x = recursiveFibMem(n-1, values) + recursiveFibMem(n-2, values); 14 | values[n] = x; 15 | return x; 16 | } 17 | 18 | 19 | } 20 | 21 | long recursiveFib(int n) { 22 | numFuncCalls++; 23 | if(n == 0 || n == 1) { 24 | return 1; 25 | } else { 26 | return recursiveFib(n-1) + recursiveFib(n-2); 27 | } 28 | } 29 | 30 | int main(int argc, char **argv) { 31 | 32 | if(argc != 2) { 33 | fprintf(stderr, "Usage: %s n \n", argv[0]); 34 | exit(1); 35 | } 36 | int n = atoi(argv[1]); 37 | 38 | //set up the table of values: 39 | long *values = (long *) malloc(sizeof(long) * (n+1)); 40 | //set up your base cases and "flag" values: 41 | for(int i=0; i 2 | #include 3 | 4 | #include "roots.h" 5 | 6 | int main(int argc, char **argv) { 7 | 8 | int a = atoi(argv[1]); 9 | int b = atoi(argv[2]); 10 | int c = atoi(argv[3]); 11 | double r1, r2; 12 | 13 | int errorCode = computeRoots(a, b, c, &r1, &r2); 14 | 15 | if(errorCode == DIVISION_BY_ZERO_ERROR) { 16 | //we have a linear function, there is only one root 17 | //bx + c = 0, x = -c / b 18 | printf("You have a linear function with solution = %f\n", (-c / (double)b)); 19 | } else if(errorCode == COMPLEX_ROOT_ERROR) { 20 | printf("use a complex number library!\n"); 21 | } else if(errorCode == NULL_POINTER_ERROR) { 22 | printf("Bad pointers or something\n"); 23 | } else if(errorCode == NO_ERROR){ 24 | printf("Roots of %dx^2 + %dx + %d are %f and %f\n", a, b, c, r1, r2); 25 | } else { 26 | printf("something went really wrong: invalid error code\n"); 27 | } 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /notes/1198-Fall2019/roots.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "roots.h" 5 | 6 | double firstRoot(int a, int b, int c) { 7 | 8 | return (-b + sqrt(b*b - 4*a*c)) / (2*a); 9 | } 10 | 11 | double secondRoot(int a, int b, int c) { 12 | 13 | return (-b - sqrt(b*b - 4*a*c)) / (2*a); 14 | } 15 | 16 | RootError computeRoots(int a, int b, int c, double *root1, double *root2) { 17 | 18 | //potential errors? 19 | if(a == 0) { 20 | return DIVISION_BY_ZERO_ERROR; 21 | } else if(b*b - 4*a*c < 0) { 22 | return COMPLEX_ROOT_ERROR; 23 | } else if(root1 == NULL || root2 == NULL) { 24 | return NULL_POINTER_ERROR; 25 | } else { 26 | *root1 = (-b + sqrt(b*b - 4*a*c)) / (2*a); 27 | *root2 = (-b - sqrt(b*b - 4*a*c)) / (2*a); 28 | return NO_ERROR; 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /notes/1198-Fall2019/roots.h: -------------------------------------------------------------------------------- 1 | /** 2 | * TODO: do the documentation later 3 | */ 4 | typedef enum { 5 | NO_ERROR, 6 | DIVISION_BY_ZERO_ERROR, 7 | NULL_POINTER_ERROR, 8 | COMPLEX_ROOT_ERROR, 9 | } RootError; 10 | 11 | /** 12 | * Computes the first root of a quadratic 13 | * polynomial with the given coefficients. 14 | */ 15 | double firstRoot(int a, int b, int c); 16 | 17 | /** 18 | * Computes the second root of a quadratic 19 | * polynomial with the given coefficients. 20 | */ 21 | double secondRoot(int a, int b, int c); 22 | 23 | /** 24 | * Computes the roots of a quadratic 25 | * polynomial with the given coefficients, 26 | * placing the results in the two variables 27 | * pased by reference. 28 | * 29 | * Returns an error code (see RootError) in 30 | * the event of an error 31 | */ 32 | RootError computeRoots(int a, int b, int c, double *root1, double *root2); 33 | -------------------------------------------------------------------------------- /notes/1198-Fall2019/roundDemo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "roundUtils.h" 6 | 7 | int main(int argc, char **argv) { 8 | 9 | double x = 123.456; 10 | double y; 11 | int numPassed = 0; 12 | int numFailed = 0; 13 | 14 | y = roundToCents(x); 15 | if( fabs(y - 123.46) > 0.00001) { 16 | printf("FAILED: expected 123.46, but got %f\n", y); 17 | numFailed++; 18 | } else { 19 | printf("PASSED\n"); 20 | numPassed++; 21 | } 22 | 23 | y = roundToDigit(x, -2); 24 | printf("y = %f\n", y); 25 | 26 | y = roundToDigit(x, 0); 27 | printf("y = %f\n", y); 28 | 29 | y = roundToDigit(x, 2); 30 | printf("y = %f\n", y); 31 | 32 | printf("Number failed: %d\n", numFailed); 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /notes/1198-Fall2019/roundUtils.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "roundUtils.h" 4 | 5 | double roundToCents(double amount) { 6 | return roundToDigit(amount, -2); 7 | } 8 | 9 | double roundToDigit(double value, int digit) { 10 | double power = pow(10, digit); 11 | return round(value / power) * power; 12 | } 13 | -------------------------------------------------------------------------------- /notes/1198-Fall2019/roundUtils.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * This function rounds the given value to a decimal 4 | * places defined by the given digit. 5 | * For example for 6 | * value = 123.456 and digit = 2 it would round to 100 7 | * value = 123.456 and digit = 0 it would round to 123 8 | * value = 123.456 and digit = -2 it would round to 123.46 9 | */ 10 | double roundToDigit(double value, int digit); 11 | 12 | /** 13 | * This function rounds the given amount to the 14 | * nearest hundredth (ie the nearest cent) and 15 | * returns the value. 16 | * 17 | */ 18 | double roundToCents(double amount); -------------------------------------------------------------------------------- /notes/1198-Fall2019/searchingSorting/binarySearchIdea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/notes/1198-Fall2019/searchingSorting/binarySearchIdea.png -------------------------------------------------------------------------------- /notes/1198-Fall2019/searchingSorting/comparator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/notes/1198-Fall2019/searchingSorting/comparator.png -------------------------------------------------------------------------------- /notes/1198-Fall2019/searchingSorting/linearSearchPseudocode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/notes/1198-Fall2019/searchingSorting/linearSearchPseudocode.png -------------------------------------------------------------------------------- /notes/1208-Fall2020/8-debugging.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155E - Computer Science I 3 | ## Debugging & Tooling 4 | ### Fall 2020 5 | 6 | ## Tooling 7 | 8 | * Source Control & Software Versioning: 9 | * git: distributed VCS 10 | * Old and grimy: CVS, SVN 11 | * Build Systems 12 | * make, cmake 13 | * Dependency management of external libraries 14 | * Package management 15 | * Dev Ops = Development Operations 16 | * Unit Testing: ad-hoc, informal, formal framework: cmocka 17 | * Static Analysis Tools 18 | * Static analysis is an analysis of your code *before* it compiles 19 | * Example: `gcc` can be used as a linter: `-Wall` 20 | * Another flag: `gcc -Wextra` 21 | * Clang: `clang --analyze foo.c` 22 | * Facebook's Infer: 23 | `infer capture -- gcc foo.c` 24 | later: `infer analyze` 25 | * Dynamic Analysis Tools 26 | * Dynamic analysis occurs when you actually run the program 27 | `valgrind --leak-check=full --show-leak-kinds=all ./a.out` 28 | * memory leaks 29 | * bounds checks (compile with `-g`!) 30 | * Perf testing 31 | * Performance Testing 32 | * Profiler 33 | * `gprof` (later) 34 | 35 | # Debugging 36 | 37 | ![Bug Sus](bugsus.jpg) 38 | 39 | * "poor man's debugger": `printf` 40 | * You'll want to use a proper debugger: `gdb` 41 | * A debugger is a program that simulates/runs another program and allows you to: 42 | * pause the execution 43 | * view variable values 44 | * "step" through a program line by line 45 | * set break points to pause the execution at a particular function, line, or under some condition! 46 | * GDB is GNU's Debugger is a command line or "TUI" debugger 47 | * Usage: 48 | * always compile with the `-g` flag: it preserves variable and function names as well as line numbers 49 | * To run GDB use: `gdb a.out` 50 | * To run your program: `run` 51 | * To view your source code you can use `layout next` 52 | * Sometimes it screws up, just type: `refresh` 53 | * You can set a function breakpoint: `break main` 54 | * You can set a line breakpoint: `break 12` 55 | * You can set a line breakpoint in another file: `break file.c:26` 56 | * You can clear a breakpoint by using `clear main` or `clear 12` 57 | * You can resume the program with `continue` 58 | * You can view the value stored in a variable using `print variableName` 59 | * Halt: control-C 60 | * Continue: 61 | `continue` 62 | * Watch a variable: 63 | `watch total` 64 | * Redraw: 65 | `refresh` 66 | * set arguments: 67 | `set args a b c` 68 | * Conditional break: 69 | `break 10 if x == 21` 70 | 71 | ```text 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | ``` 87 | -------------------------------------------------------------------------------- /notes/1208-Fall2020/bugsus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/notes/1208-Fall2020/bugsus.jpg -------------------------------------------------------------------------------- /notes/1208-Fall2020/honors/12-recursion.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155H - Computer Science I Honors 3 | ## Recursion 4 | ### Fall 2020 5 | 6 | * Motivating Demonstration: sum the elements of an array without using a loop! 7 | * What is recursion? Anything that makes reference to itself! 8 | * In coding, a recursive function is a function that makes one or more calls to itself 9 | * Mathematics: fractals 10 | * The classic "bad" example: Fibonacci sequence 11 | 12 | 13 | $$\begin{equation*} 14 | f(n) = \begin{cases} 15 | 1 & n = 0\\ 16 | 1 & n = 1\\ 17 | f(n-1) + f(n-2) & \text{otherwise} 18 | \end{cases} 19 | \end{equation*}$$ 20 | 21 | $$1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...$$ 22 | 23 | ## Designing Recursive functions 24 | 25 | * Every recursive function needs at least one or more *base cases*: a condition in which no further recursion is performed 26 | * Some base cases may be for error handling 27 | * You make one or more recursive calls to the same function, BUT you need to make sure your recursive calls are *making progress* toward a base case! 28 | 29 | ## Recursion: Good? 30 | 31 | * Recursion *can* be a useful and "good" tool: 32 | * Many divide and conquer style algorithms initially use recursion to solve a problem 33 | * Many functional programming languages (Haskell) use recursion as the "default" way of computing things 34 | * Recursion can also lead to "clean" or "Beautiful" or "easily understood" code 35 | 36 | ## Recursion; Bad 37 | 38 | * Recursive function essentially abuse the stack: you're always risking a stack overflow 39 | * You risk recomputing values over and over 40 | * You risk naively doing an exponential amount of work 41 | 42 | ## eliminating recursion 43 | 44 | * In general recursion is not necessary 45 | * You can, in general, take any computable recursive function and create an equivalent non-recursive computation/algorithm 46 | * You can "simulate" recursion using an in-memory stack 47 | * you can use *memoization* 48 | * If you need to compute a value, go ahead and "pay" for the recursion 49 | * BUT, once computed, *store* the result into a table or *cache* 50 | * When you need to compute a value, look in the cache first: if it is already computed, use it! Otherwise again pay for the recursion 51 | 52 | ## java 53 | 54 | 55 | ```text 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | ``` 64 | -------------------------------------------------------------------------------- /notes/1208-Fall2020/honors/8-debugging.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155E - Computer Science I 3 | ## Debugging & Tooling 4 | ### Fall 2020 5 | 6 | ## Tooling 7 | 8 | * Source Control & Versioning: git 9 | * Build Systems: make, cmake, ant (java) 10 | * Deployment scripts 11 | * Dependancy management (java: maven) 12 | * DevOps 13 | * Unit Testing: ad-hoc, informal, formal testing: cmocka, Java: JUnit 14 | * Static analysis tools: 15 | * Linter: `gcc -Wall` 16 | * Another: `gcc -Wall -Wextra` 17 | * Clang: `gcc --analyze foo.c` 18 | * Facebook's Infer: 19 | `infer capture -- gcc foo.c` 20 | `infer analyze` 21 | * More: https://github.com/cbourke/ComputerScienceI/blob/master/documents/troubleShooting.pdf 22 | * Dynamic Analysis Tools 23 | * Valgrind: 24 | `valgrind --leak-check=full --show-leak-kinds=all ./a.out` 25 | * memory leaks 26 | * bounds checks (compile with `-g`!) 27 | * Perf Testing 28 | * Performance Testing 29 | * Profilers 30 | * `gprof` (later) 31 | * Debuggers 32 | 33 | # Debugging 34 | 35 | * Identify the bug 36 | * Identify input that causes the bug 37 | * You need to do this to make the bug *reproducible* 38 | * Using `printf` statements to view the value(s) of variables is referred to as "poor man's" debugging 39 | * Using a proper *debugger* is better 40 | * A debugger is a program that simulates/runs another program and allows you to: 41 | * pause the execution 42 | * View variable values 43 | * "step" through the program line by line 44 | * set break points in a program and continue execution up to that point 45 | * GDB (Gnu's Debugger) is a command line debugger 46 | * Compile with `-g` flag to preserve variable and function names 47 | `gcc -g arrayProgram.c` 48 | * Start GDB with your program: 49 | `gdb a.out` 50 | * Run your program: 51 | `run` 52 | * Set a break point: 53 | `break main` 54 | * See your code: 55 | `layout next` 56 | * Step: 57 | `next` (shorthand: `n`) 58 | * print a variable: 59 | `print foo` 60 | * print an array: 61 | `print *arr@len` 62 | * Set another break point base on a line number: 63 | `break 25` 64 | * Continue: 65 | `continue` 66 | * Watch a variable: 67 | `watch total` 68 | * Redraw: 69 | `refresh` 70 | * set arguments: 71 | `set args a b c` 72 | * Conditional break: 73 | `break 10 if x == 21` 74 | * Halt: control-C 75 | 76 | 77 | -------------------------------------------------------------------------------- /notes/1218-Fall2021/1-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I 2 | ## CSCE 155E - Fall 2021 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | -------------------------------------------------------------------------------- /notes/1218-Fall2021/12-recursion.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155E - Computer Science I 3 | ## Recursion 4 | ### Fall 2021 5 | 6 | * Motivating Demonstration: print a count down without a loop! 7 | * What is recursion? 8 | * In general, *recursion* is something that references itself 9 | * In coding, a function is recursive if it makes one or more calls to itself 10 | * Mathematics: fractals are self-similar objects 11 | * Fibonacci Sequence 12 | 13 | $$\begin{equation*} 14 | f(n) = \begin{cases} 15 | 1 & n = 1\\ 16 | 1 & n = 2\\ 17 | f(n-1) + f(n-2) & \text{otherwise} 18 | \end{cases} 19 | \end{equation*}$$ 20 | 21 | $$1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...$$ 22 | 23 | ## Designing Recursive functions 24 | 25 | * Every recursive function needs one or more *base cases* in which no further recursion is performed 26 | * Some base cases may be for error handling 27 | * You make one or more recursive calls that *must* make progress toward the base conditions 28 | 29 | ## Recursion: Good? 30 | 31 | * Recursion *can* be useful or "good" 32 | * Many divide and conquer style algorithms will be presented recursively 33 | * It is a good way to think "inductively" 34 | * Many functional programming lanaguages encourage or primarily use recursion (Haskell, Scheme, Lisp) 35 | * Recursion can also lead to "simple" or "clean" or "beautiful" code that is easily understood 36 | 37 | ## Recursion: Bad 38 | 39 | * Recursive function are essentially abusing the call stack and risking stack overflow 40 | * You risk recomputing values over and over 41 | * You risk a naive *exponential* approach to a problem 42 | 43 | ## Eliminating Recursion 44 | 45 | * In general any computable recursive function can be replaced with a iterative solution 46 | * You can use various tricks to eliminate the additional functions including: 47 | * Using a stack 48 | * Using "tail recursion" 49 | * You can use *memoization* 50 | * If you need to compute a value, go ahead and do so recursively, "paying" for the recursion 51 | * BUT: once you compute one value, STORE it (*cache* it) and save it for later 52 | * Before you do a subsequent recursive call, check your cache: if the value has already been computed and stored, use it, avoiding the recursive call! 53 | 54 | ## Hack 12 55 | 56 | * You'll compute how long it would take to compute binomial coefficients recursively 57 | $${n \choose k} = \frac{n!}{(n-k)!k!} = {n-1\choose k } + {n-1 \choose k-1}$$ 58 | * read: n choose k 59 | * it is the number of ways to choose k elements from a set of size n without consideration on the order 60 | ```text 61 | 62 | 63 | 64 | 65 | ``` 66 | -------------------------------------------------------------------------------- /notes/1218-Fall2021/9-debugging.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155E - Computer Science I 3 | ## Debugging & Tooling 4 | ### Fall 2021 5 | 6 | ## Tooling 7 | 8 | * Source Control & Software Versioning: 9 | * git: distributed VCS 10 | * Build Systems 11 | * make, cmake 12 | * Dependency management of external libraries 13 | * Package management 14 | * Dev Ops = Development Operations 15 | * Unit Testing 16 | * ad-hoc 17 | * informal 18 | * formal: cmocka 19 | * Static Analysis Tools 20 | * Static analysis is an analysis of your code *before* it compiles 21 | * Example: `gcc` can be used as a linter: `-Wall` 22 | * Another flag: `gcc -Wextra` 23 | * Clang: `clang --analyze foo.c` 24 | * Facebook's Infer: 25 | `infer capture -- gcc foo.c` 26 | later: `infer analyze` 27 | * Dynamic Analysis Tools 28 | * Dynamic analysis occurs when you actually run the program 29 | `valgrind --leak-check=full --show-leak-kinds=all ./a.out` 30 | * memory leaks 31 | * bounds checks (compile with `-g`!) 32 | * Perf testing 33 | * Performance Testing 34 | * Profiler 35 | * `gprof` (later) 36 | 37 | # Debugging 38 | 39 | * "poor man's debugger": `printf` 40 | * You'll want to use a proper debugger: `gdb` 41 | * https://ftp.gnu.org/old-gnu/Manuals/gdb/html_chapter/gdb_19.html 42 | * A debugger is a program that simulates/runs another program and allows you to: 43 | * pause the execution 44 | * view variable values 45 | * "step" through a program line by line 46 | * set break points to pause the execution at a particular function, line, or under some condition! 47 | * GDB is GNU's Debugger is a command line or "TUI" debugger 48 | * Usage: 49 | * always compile with the `-g` flag: it preserves variable and function names as well as line numbers 50 | * To run GDB use: `gdb a.out` 51 | * To run your program: `run` 52 | * To view your source code you can use `layout next` or `layout src` 53 | * Sometimes it screws up, just type: `refresh` 54 | * You can set a function breakpoint: `break main` 55 | * You can set a line breakpoint: `break 12` 56 | * You can set a line breakpoint in another file: `break file.c:26` 57 | * You can clear a breakpoint by using `clear main` or `clear 12` 58 | * You can resume the program with `continue` 59 | * You can view the value stored in a variable using `print variableName` 60 | * Halt: control-C 61 | * Continue: 62 | `continue` 63 | * Watch a variable: 64 | `watch total` 65 | * Redraw: 66 | `refresh` 67 | * set arguments: 68 | `set args a b c` 69 | * Conditional break: 70 | `break 10 if x == 21` 71 | 72 | ```text 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | ``` 88 | -------------------------------------------------------------------------------- /notes/1218-Fall2021/encapsulationDemo/demo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "film.h" 6 | 7 | int main(int argc, char **argv) { 8 | 9 | Date d = {1967, 10, 3 }; 10 | Person denis = { 11 | "Denis", 12 | "Villenueve", 13 | { 14 | 1967, 10, 3 15 | } 16 | }; 17 | 18 | Film *arr = (Film *) malloc(sizeof(Film) * 3); 19 | initFilm(&arr[0], "1234", "Arrival", denis, 8.5); 20 | initFilm(&arr[1], "10.5240/D15F-5FCE-B8D0-FA2B-EF6A-D", "Dune", denis, 9.0); 21 | initFilm(&arr[2], "5678", "Blade Runner 2049", denis, 9.9); 22 | 23 | printFilms(arr, 3); 24 | 25 | Film **films = (Film **) malloc(sizeof(Film *) * 3); 26 | 27 | Film *arrival = createFilm("1234", "Arrival", denis, 8.5); 28 | Film *dune = createFilm("10.5240/D15F-5FCE-B8D0-FA2B-EF6A-D", "Dune", denis, 9.0); 29 | Film *bladeRunner = createFilm("5678", "Blade Runner 2049", denis, 9.9); 30 | 31 | films[0] = arrival; 32 | films[1] = dune; 33 | films[2] = bladeRunner; 34 | 35 | printFilmsV2(films, 3); 36 | 37 | 38 | //TODO: free properly 39 | // free(dune); 40 | // free(bladeRunner); 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /notes/1218-Fall2021/encapsulationDemo/film.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "film.h" 6 | 7 | void initFilm(Film *f, const char *eidr, const char *title, Person director, double imdbRating) { 8 | f->eidr = strdup(eidr); 9 | f->title = strdup(title); 10 | f->imdbRating = imdbRating; 11 | f->director = director; 12 | } 13 | 14 | Film *createFilm(const char *eidr, const char *title, Person director, double imdbRating) { 15 | 16 | Film *f = (Film *) malloc(1 * sizeof(Film)); 17 | initFilm(f, eidr, title, director, imdbRating); 18 | return f; 19 | } 20 | 21 | char *filmToString(const Film *f) { 22 | char s[1000]; 23 | sprintf(s, "%s directed by %s, %s (%.2f)\n", 24 | f->title, 25 | f->director.lastName, 26 | f->director.firstName, 27 | f->imdbRating); 28 | char *result = strdup(s); 29 | return result; 30 | } 31 | 32 | void printFilm(const Film *f) { 33 | char *s = filmToString(f); 34 | printf("%s", s); 35 | free(s); 36 | return; 37 | } 38 | 39 | void printFilms(const Film *films, int n) { 40 | 41 | for(int i=0; i 2 | #include 3 | #include 4 | 5 | #include "student.h" 6 | 7 | 8 | int main(int argc, char **argv) { 9 | 10 | Date d = { 2000, 10, 28 }; 11 | 12 | Student *jane = constructStudent(1234, "Jane", "Doe", FRESHMAN, 4.0, d); 13 | Student *john = constructStudent(4321, "John", "Doe", FRESHMAN, 4.0, d); 14 | Student *jahm = constructStudent(9876, "Jahm", "Smith", FRESHMAN, 4.0, d); 15 | 16 | // Student *r = (Student *) malloc(sizeof(Student) * 3); 17 | // r[0] = *jane; 18 | // r[1] = *john; 19 | // r[2] = *jahm; 20 | 21 | int n = 3; 22 | 23 | Student **roster = (Student **) malloc( sizeof(Student*) * n ); 24 | roster[0] = jane; 25 | roster[1] = john; 26 | roster[2] = jahm; 27 | 28 | printRoster(roster, n); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /notes/1218-Fall2021/honors/encapsulationDemo/student.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "student.h" 6 | 7 | Student *constructStudent(int nuid, 8 | const char *firstName, 9 | const char *lastName, 10 | Year year, 11 | double gpa, 12 | Date dateOfBirth) { 13 | 14 | Student *s; 15 | 16 | s = (Student *) malloc(1 * sizeof(Student)); 17 | 18 | initStudent(s, nuid, firstName, lastName, year, gpa, dateOfBirth); 19 | 20 | return s; 21 | } 22 | 23 | void initStudent(Student *s, int nuid, 24 | const char *firstName, 25 | const char *lastName, 26 | Year year, 27 | double gpa, 28 | Date dateOfBirth) { 29 | s->nuid = nuid; 30 | 31 | s->firstName = strdup(firstName); 32 | s->lastName = strdup(lastName); 33 | 34 | s->year = year; 35 | s->gpa = gpa; 36 | s->dateOfBirth = dateOfBirth; 37 | 38 | return; 39 | } 40 | 41 | void printRoster(Student **r, int n) { 42 | 43 | for(int i=0; ilastName, s->firstName, s->nuid); 61 | return strdup(str); 62 | } 63 | -------------------------------------------------------------------------------- /notes/1218-Fall2021/honors/encapsulationDemo/student.h: -------------------------------------------------------------------------------- 1 | 2 | typedef enum { 3 | FRESHMAN, 4 | SOPHOMORE, 5 | JUNIOR, 6 | SENIOR 7 | } Year; 8 | 9 | typedef struct { 10 | int year; 11 | int month; 12 | int day; 13 | } Date; 14 | 15 | typedef struct { 16 | int nuid; 17 | char *firstName; 18 | char *lastName; 19 | Year year; 20 | double gpa; 21 | Date dateOfBirth; 22 | } Student; 23 | 24 | Student *constructStudent(int nuid, 25 | const char *firstName, 26 | const char *lastName, 27 | Year year, 28 | double gpa, 29 | Date dateOfBirth); 30 | 31 | void initStudent(Student *s, int nuid, 32 | const char *firstName, 33 | const char *lastName, 34 | Year year, 35 | double gpa, 36 | Date dateOfBirth); 37 | 38 | void printStudent(const Student *s); 39 | void printRoster(Student **s, int n); 40 | 41 | char *studentToString(const Student *s); -------------------------------------------------------------------------------- /notes/1221-Spring2022/01-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I 2 | ## ECEN 1940 - Spring 2022 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | 9 | ## Programming, Compiling, Running 10 | 11 | * Source files are *plain text* files containing computer code in a highlevel programming language 12 | * Source files have to be compiled into an *executable program* (binary code) 13 | * *source → assembly → machine code* 14 | 15 | ### Demonstration 16 | 17 | 1. Edit a source file `hello.c` 18 | 2. Assemble: `gcc -S hello.c` 19 | 3. Compile: `gcc -c hello.c` 20 | * Produces an object file, `hello.o` 21 | * View: `hexdump -C hello.o` 22 | 4. You need to also *link* in any external libraries 23 | 24 | * All at once: `gcc hello.c` 25 | -------------------------------------------------------------------------------- /notes/1221-Spring2022/demoCode/agm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char **argv) { 7 | 8 | double tolerance = 0.000001; 9 | 10 | double x = 42; 11 | double y = 103; 12 | 13 | double amPrev, gmPrev; 14 | double amCurr = (x + y) / 2; 15 | double gmCurr = sqrt(x * y); 16 | 17 | while( fabs(amCurr - gmCurr) > tolerance ) { 18 | amPrev = amCurr; 19 | gmPrev = gmCurr; 20 | 21 | amCurr = (amPrev + gmPrev) / 2; 22 | gmCurr = sqrt(amPrev * gmPrev); 23 | 24 | } 25 | printf("agm(%f, %f) = %f\n", x, y, amCurr); 26 | 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /notes/1221-Spring2022/demoCode/fizzbuzz.c: -------------------------------------------------------------------------------- 1 | /** TODO: DOcument 2 | */ 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char **argv) { 9 | 10 | for(int i=1; i<=100; i++) { 11 | 12 | if(i % 3 == 0 && i % 5 == 0) { 13 | printf("FizzBuzz\n"); 14 | } else if(i % 3 == 0) { 15 | printf("Fizz\n"); 16 | } else if(i % 5 == 0) { 17 | printf("Buzz\n"); 18 | } else { 19 | printf("%d\n", i); 20 | } 21 | 22 | } 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /notes/1221-Spring2022/demoCode/harmonic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char **argv) { 7 | 8 | if(argc != 2) { 9 | printf("Usage: give me a positive integer\n"); 10 | exit(1); 11 | } 12 | 13 | int n = atoi(argv[1]); 14 | if(n <= 0) { 15 | printf("Error: integer must be positive\n"); 16 | exit(2); 17 | } 18 | 19 | double sum = 0.0; 20 | for(int i=1; i<=n; i++) { 21 | sum += (1.0 / i); 22 | } 23 | 24 | printf("sum 1/i, i = 1..%d = %f\n", n, sum); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /notes/1221-Spring2022/demoCode/loan.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char **argv) { 7 | 8 | if(argc != 4) { 9 | printf("Usage: principle years interestRate\n"); 10 | exit(1); 11 | } 12 | 13 | double principle = atof(argv[1]); 14 | int years = atoi(argv[2]); 15 | double interestRate = atof(argv[3]); 16 | 17 | double monthlyInterestRate = (interestRate / 12); 18 | 19 | //TODO: validate the input 20 | 21 | double monthlyPayment = (monthlyInterestRate * principle) / ( 1 - pow(1 + monthlyInterestRate, -years*12) ); 22 | monthlyPayment = round(monthlyPayment * 100.0) / 100.0; 23 | printf("Monthly payment = $%.2f\n", monthlyPayment); 24 | 25 | double balance = principle; 26 | 27 | printf("Month Balance Interest New Balance\n"); 28 | for(int i=1; i<=years * 12; i++) { 29 | double monthlyInterest = round(monthlyInterestRate * balance * 100.0) / 100.0; 30 | double monthlyPrinciple = monthlyPayment - monthlyInterest; 31 | double newBalance = balance - monthlyPrinciple; 32 | printf("%d $%10.2f | $%10.2f | $%10.2f | $%10.2f \n", i, balance, monthlyInterest, monthlyPrinciple, newBalance); 33 | balance = newBalance; 34 | } 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/01-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I 2 | ## CSCE 155E - Fall 2022 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/11-encapsulation.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155E - Computer Science I 3 | ## Encapsulation - Structures 4 | ### Fall 2022 5 | 6 | ## Motivating Exercise 7 | 8 | * Given (CSV) data on books, compute various statistics/reports: 9 | * What is the best book? 10 | * What is the worst book? 11 | * What are all books written by Frank Herbert? 12 | 13 | ## Introduction 14 | 15 | * Built-in primitive types `int, double, char` are very limiting: not everything is a number or character 16 | * Real world entities are *composed* of multiple pieces of data 17 | * Encapsulating multiple pieces of data into one "object" or "thing" allows you to deal with that one "thing" 18 | * Solution: encapsulation 19 | * C: structures 20 | * YOu can define a user-defined type called a `struct` that allows you to collect multiple pieces of data into one logical unit 21 | * Encapsulation is a mechanism that allows you to: 22 | 1. Group pieces of data together into one logical "unit" 23 | 2. Protect that data from the outside world 24 | 3. Group functionality that acts on that data with the data 25 | 26 | ## Demo 27 | 28 | * Observations: 29 | * A structure is *composed* of multiple pieces of data or even *other structures* this is called "composition" 30 | * Order of declaration matters: if one structure uses another, it must be declared first 31 | * The variables inside of a structure are called *member variables* 32 | * WHen you create an actual variable of that type, it is known as an "instance" 33 | * `Book b; //b is an "instance" of the Book structure` 34 | * To access member variables of a regular old structure you use the dot operator: `.`; example: `b.title = ...` 35 | * Style notes: 36 | * Names of structures should be `UpperCamelCased` 37 | * Member variables should be `lowerCamelCased` 38 | * You end the definition with a semicolon 39 | * Member variables are ended with a semicolon 40 | 41 | ## Using Structures 42 | 43 | * Once defined, you can create instances of a structure or pointer to instances of structures: `Book b`, `Book *b` 44 | * To access member variables of a pointer to a structure, use the arrow operator: `b->rating` 45 | * You can/should define utility functions: 46 | * You can define a factory function to create new instances 47 | * You can define "to string" functions to print or convert data to a human-readable format 48 | * You can define "destructor" functions to free up memory properly 49 | * You can also define "initialization" versions of a function: suppose that an instance already exists, you simply need to assign/allocate its values 50 | 51 | 52 | ```text 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | ``` 63 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/12-recursion.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155E - Computer Science I 3 | ## Recursion 4 | ### Fall 2022 5 | 6 | * Motivating Demonstration: print a count down without a loop! 7 | * What is recursion? 8 | * In general, *recursion* is something that references itself 9 | * In math: fractals and fractal art 10 | * Code: a function is recursive if it makes one or more calls to itself 11 | * Fibonacci Sequence 12 | 13 | $$\begin{equation*} 14 | f(n) = \begin{cases} 15 | 1 & n = 1\\ 16 | 1 & n = 2\\ 17 | f(n-1) + f(n-2) & \text{otherwise} 18 | \end{cases} 19 | \end{equation*}$$ 20 | 21 | $$1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...$$ 22 | 23 | ## Designing Recursive functions 24 | 25 | * Every recursive function needs at least one or more *base cases* 26 | * A base case is a single return statement such that no additional recursive calls are made 27 | * Otherwise, you make one or more recursive calls to the same function 28 | * However, each recursive call *must* make some *progress* toward the base case 29 | * The initial call to your recursive function is your initialization statement 30 | 31 | ## Recursion: Good? Bad? Ugly? 32 | 33 | * Recursion *can* be a good or useful thing 34 | * Often many divide and conquer style algorithms/problem solving approaches can be recursive 35 | * It is a good way to think "inductively" 36 | * Many functional programming languages discourage or don't even have loop control structures! 37 | * Recursion can be "simple" or "clean" or "mathematical" or "beautiful" that is easily understood 38 | 39 | * Recursion can be bad (or very bad): 40 | * Deep recursion risks stack overflow 41 | * You risk recomputing the same values over and over 42 | * Ultimately, you are abusing the stack space: there is a non-trivial overhead in recursion that is not present with regular loops 43 | * You risk an *exponential* amount of work which may not be feasible 44 | * These are all *objective* measures 45 | 46 | ## Eliminate Recursion 47 | 48 | * In general, any computable recursive function can be rewritten as an iterative algorithm 49 | * You don't really *need* recursion in order to compute anything 50 | * You can always *simulate* recursion using an in-memory stack 51 | * Tail recursion can eliminate the inefficient stack frame usage 52 | * You can use *memoization* to reduce the amount of recomputation 53 | * If you need to compute a value, go ahead and "pay" for the recursion 54 | * BUT: you store the result into a table or "cache" 55 | * If you ever need to recompute the result: you first check the cache; if it has already been computed, reuse it! 56 | * After you have computed it, be sure to store it in the cache! 57 | 58 | ```text 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | ``` 70 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/code/book.h: -------------------------------------------------------------------------------- 1 | 2 | typedef struct { 3 | int year; 4 | int month; 5 | int day; 6 | } Date; 7 | 8 | typedef struct { 9 | char *firstName; 10 | char *lastName; 11 | Date dateOfBirth; 12 | } Author; 13 | 14 | typedef struct { 15 | char *title; 16 | Author author; 17 | Date releaseDate; 18 | double rating; 19 | } Book; 20 | 21 | /** 22 | * This is a factory function that creates a new instance of a Book 23 | * structure. 24 | */ 25 | Book *createBook(const char *title, 26 | const char *authorFirstName, 27 | const char *authorLastName, 28 | int releaseYear, 29 | double rating); 30 | 31 | /** 32 | * Initializes an existing Book structure's variables 33 | */ 34 | void initBook(Book *b, 35 | const char *title, 36 | const char *authorFirstName, 37 | const char *authorLastName, 38 | int releaseYear, 39 | double rating); 40 | 41 | 42 | /** 43 | * Creates a deep copy of the given string and returns a pointer 44 | * to it. 45 | */ 46 | char *deepStringCopy(const char *s); 47 | 48 | /** 49 | * Prints the given instance of a Book to the standard output 50 | */ 51 | void printBook(const Book *b); 52 | 53 | /** 54 | * Returns a tabular/human readable format of the given book as 55 | * a string 56 | */ 57 | char *bookToString(const Book *b); 58 | 59 | /** 60 | * Frees all memory associated with the given Book and then 61 | * frees the Book structure itself 62 | */ 63 | void freeBook(Book *b); 64 | 65 | /** 66 | * Loads Book records/data from the given file... 67 | */ 68 | Book *loadBooks(const char *fileName, int *numBooks); 69 | 70 | /** 71 | * This function finds the best book (with respect to the 72 | * highest rating) and returns it 73 | */ 74 | Book *getBestBook(const Book *library, int numBooks); 75 | 76 | /** 77 | * This function finds the words book (with respect to the 78 | * lowest rating) and returns it 79 | */ 80 | Book *getWorstBook(const Book *library, int numBooks); 81 | 82 | /** 83 | * Returns a new array containing all the books by the given 84 | * author (passed by reference) in the array of Books (library) 85 | * which is of size numBooks. 86 | * 87 | * The size of the resulting array is communicated in the numResultingBooks 88 | * variable 89 | */ 90 | Book *getBooksByAuthor(const Book *library, int numBooks, const Author *author, int *numResultingBooks); 91 | 92 | 93 | int authorIsEqual(const Author *a, const Author *b); -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/code/books.csv: -------------------------------------------------------------------------------- 1 | 20 2 | Harry Potter and the Deathly Hallows,J.K.,Rowling,2007,4.62 3 | The Name of the Wind,Patrick,Rothfuss,2007,4.55 4 | The Wise Man's Fear,Patrick,Rothfuss,2011,4.58 5 | Colour of Magic,Terry,Pratchett,1983,3.98 6 | Wyrd Sisters,Terry,Pratchett,1988,4.12 7 | Moby Dick,Herman,Melville,1851,3.48 8 | Neuromancer,William,Gibson,1984,3.88 9 | Stranger in a Strange Land,Robert,Heinlein,1961,3.91 10 | Have Space Suit-Will Travel,Robert,Heinlein,1958,3.89 11 | The Clan of the Cave Bear,Jean,Auel,1980,4.02 12 | Dianetics,L. Ron,Hubbard,1950,2.33 13 | Dune,Frank,Herbert,1965,4.20 14 | Dune Messiah,Frank,Herbert,1969,3.86 15 | Children of Dune,Frank,Herbert,1976,3.91 16 | God Emperor of Dune,Frank,Herbert,1981,3.82 17 | Heretics of Dune,Frank,Herbert,1984,3.84 18 | Chapterhouse: Dune,Frank,Herbert,1985,3.89 19 | Mort,Terry,Pratchett,1987,4.22 20 | Raising Steam,Terry,Pratchett,2013,3.94 21 | A Game of Thrones,George,Martin,1996,4.45 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/code/demo.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "book.h" 10 | 11 | int main(int argc, char **argv) { 12 | 13 | 14 | int numBooks; 15 | Book *library = loadBooks("books.csv", &numBooks); 16 | 17 | //print them out as an ad-hoc test... 18 | for(int i=0; i 2 | #include 3 | #include 4 | 5 | #include "massUtils.h" 6 | 7 | int main(int argc, char **argv) { 8 | 9 | 10 | double kgf = 78.2; 11 | double expectedLbs = 172.4015; 12 | double expectedOz = 2758.424; 13 | double expectedNewtons = 766.88003; 14 | double actualLbs, actualOz, actualNewtons; 15 | int expectedError = 0, actualError; 16 | actualError = convertWeight(kgf, &actualLbs, &actualOz, &actualNewtons); 17 | if(expectedError != actualError) { 18 | printf("FAIL: expected %d, got %d\n", expectedError, actualError); 19 | } else if( fabs(expectedLbs - actualLbs) >= 0.001) { 20 | printf("FAIL: expected %f, got %f\n", expectedLbs, actualLbs); 21 | } else { 22 | printf("PASS, I guess\n"); 23 | } 24 | 25 | 26 | } -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/code/massUtils.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "massUtils.h" 4 | 5 | ErrorCode convertWeight(double kgf, double *lbs, double *oz, double *newtons) { 6 | 7 | if(lbs == NULL || oz == NULL || newtons == NULL) { 8 | return NULL_POINTER_ERROR; 9 | } else if(kgf < 0) { 10 | return NEGATIVE_VALUE_ERROR; 11 | } 12 | 13 | *lbs = 2.20462 * kgf; 14 | *oz = 2.20462 * 16 * kgf; 15 | *newtons = 9.80665 * kgf; 16 | 17 | return NO_ERROR; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/code/massUtils.h: -------------------------------------------------------------------------------- 1 | 2 | typedef enum { 3 | NO_ERROR, 4 | NULL_POINTER_ERROR, 5 | NEGATIVE_VALUE_ERROR, 6 | } ErrorCode; 7 | 8 | /** 9 | * This function converts the given kilogram force value to the other 10 | * three units (pounds, ounces, newtons) using the three pass-by-reference 11 | * variables. 12 | * 13 | * Returns a non-zero error code for any error conditions 14 | */ 15 | ErrorCode convertWeight(double kgf, double *lbs, double *oz, double *newtons); -------------------------------------------------------------------------------- /notes/1228-Fall2022/155E/review.md: -------------------------------------------------------------------------------- 1 | 2 | # Computer Science I 3 | ## CSCE 155E - Fall 2022 4 | ### Review: functions, pointers, pass-by-reference 5 | 6 | 7 | * Pointers 8 | * `int x;` a regular old variable 9 | * `int *a` a pointer variable 10 | * If you have a regular variable and you want to transform it into a pointer: referencing operator `&x` 11 | * If you have a pointer variable and you want to transform it into a regular old variable: *de*reference: `*a` 12 | * Pass-by-value 13 | * *copies* of the variables' values are passed to the function 14 | * Any changes to those parameter variables *do not affect* the original variables 15 | * Pass-by-reference 16 | * *pointers* to the variables are passed to the function 17 | * Changes via the pointers *do affect* the original variables 18 | * You can use pass-by-reference variables to "return" multiple values 19 | * It frees up the return value to communicate error codes 20 | * Error Handling 21 | * LOOK BEFORE YOU LEAP 22 | * Error handling is the ***FIRST*** thing you do 23 | * When error handling, `NULL` pointer checks are the first you do 24 | * Otherwise: Bret Hart will come and knock you upside the head 25 | * You do *not*: 26 | * Print anything 27 | * Exit the program 28 | * Tip: 29 | * Only set pointer values once at the end of the function; use temporarily variables 30 | * This reduces the number of potential failure points 31 | * YOU NEVER NEVER NEVER include source files: THIS IS BAD: `#include "foo.c"` 32 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/01-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I - Honors 2 | ## CSCE 155H - Fall 2022 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/11-encapsulation.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155H - Computer Science I 3 | ## Encapsulation - Structures & Classes 4 | ### Fall 2022 5 | 6 | ## Motivating Exercise 7 | 8 | * Given (CSV) data on books, compute various statistics/reports: 9 | * What is the best book? 10 | * What is the worst book? 11 | * What are all books written by Frank Herbert? 12 | 13 | ## Introduction 14 | 15 | * Built-in primitive types `int, double, char` are very limiting: not everything is a number or character 16 | * Real world entities are *composed* of multiple pieces of data 17 | * Encapsulating multiple pieces of data into one "object" or "thing" allows you to deal with that one "thing" 18 | * Solution: encapsulation 19 | * C: structures 20 | * Java: Classes 21 | * Encapsulation is a mechanism that allows you to: 22 | 1. Group pieces of data together into one logical "unit" 23 | 2. Protect that data from the outside world 24 | 3. Group functionality that acts on that data with the data 25 | * C: structures support just #1 (weak encapsulation) 26 | * Java: all three, strong encapsulation 27 | 28 | ## C: Structures 29 | 30 | * A structure is a user-defined type that allows you to create a new type of variable that consists of a grouping of other variables 31 | * Demo 32 | 33 | ## Java: Classes 34 | 35 | * Demo: create `Book`, `Author`, (`Date`?) classes 36 | * Visibility: 37 | * making a member variable `private` means only the class can "see" it (no outside code can access or change it!) 38 | * making a member variable (or method) `public` means any piece of code can access or change it: this leads to a lot of chaos! 39 | * Design principle: 40 | * make all member variables `private` unless you have a Very Good Reason to do otherwise 41 | * Instead: control access through *getters* and *setters*: functions that allow the outside world to access or change the variable values 42 | * getters/setters allow you to control access and do *data validation* 43 | * Lack of any setters and all `private` variables make your class *immutable*: this is a Very Good Thing: it gives you thread safety for free! 44 | * Constructors 45 | * Constructors are special methods in a class that allow you to specify how an object gets built/constructed 46 | * You can define multiple constructors to allow a user to create an object in multiple different ways 47 | * Other observations 48 | * Class names should be `UpperCamelCased`, member variables should be `lowerCamelCased` 49 | 50 | ```text 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | ``` 61 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/code/Author.java: -------------------------------------------------------------------------------- 1 | package unl.cse; 2 | 3 | import java.time.LocalDate; 4 | 5 | public class Author { 6 | 7 | private String firstName; 8 | private String lastName; 9 | private LocalDate dateOfBirth; 10 | 11 | /** 12 | * @param firstName 13 | * @param lastName 14 | */ 15 | public Author(String firstName, String lastName) { 16 | super(); 17 | this.firstName = firstName; 18 | this.lastName = lastName; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return lastName +", " + firstName; 24 | } 25 | 26 | public String getFirstName() { 27 | return firstName; 28 | } 29 | 30 | public String getLastName() { 31 | return lastName; 32 | } 33 | 34 | public LocalDate getDateOfBirth() { 35 | return dateOfBirth; 36 | } 37 | 38 | @Override 39 | public int hashCode() { 40 | final int prime = 31; 41 | int result = 1; 42 | result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); 43 | result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); 44 | return result; 45 | } 46 | 47 | @Override 48 | public boolean equals(Object obj) { 49 | if (this == obj) 50 | return true; 51 | if (obj == null) 52 | return false; 53 | if (getClass() != obj.getClass()) 54 | return false; 55 | Author other = (Author) obj; 56 | if (firstName == null) { 57 | if (other.firstName != null) 58 | return false; 59 | } else if (!firstName.equals(other.firstName)) 60 | return false; 61 | if (lastName == null) { 62 | if (other.lastName != null) 63 | return false; 64 | } else if (!lastName.equals(other.lastName)) 65 | return false; 66 | return true; 67 | } 68 | 69 | 70 | 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/code/Book.java: -------------------------------------------------------------------------------- 1 | package unl.cse; 2 | 3 | import java.time.LocalDate; 4 | 5 | public class Book { 6 | 7 | private String title; 8 | private Author author; 9 | private LocalDate releaseDate; 10 | private double rating; 11 | 12 | /** 13 | * @param title 14 | * @param author 15 | * @param releaseDate 16 | * @param rating 17 | */ 18 | public Book(String title, Author author, LocalDate releaseDate, double rating) { 19 | this.title = title; 20 | this.author = author; 21 | this.releaseDate = releaseDate; 22 | this.rating = rating; 23 | } 24 | 25 | /** 26 | * This is a copy constructor: it allows you to create a new copy of a Book instance 27 | * possibly with different values; example: a different value for a rating 28 | */ 29 | public Book(Book that, double rating) { 30 | this.title = that.title; 31 | this.author = that.author; 32 | this.releaseDate = that.releaseDate; 33 | this.rating = rating; 34 | 35 | } 36 | 37 | 38 | @Override 39 | public String toString() { 40 | return String.format("%s by %s was released in %d with a rating of %f", title, author, releaseDate.getYear(), rating); 41 | } 42 | 43 | public double getRating() { 44 | return this.rating; 45 | } 46 | 47 | public String getTitle() { 48 | return title; 49 | } 50 | 51 | public Author getAuthor() { 52 | return author; 53 | } 54 | 55 | public LocalDate getReleaseDate() { 56 | return releaseDate; 57 | } 58 | 59 | // public void setRating(double rating) { 60 | // if(rating < 0 || rating > 5.0) { 61 | // throw new RuntimeException("Attempted to set an invalid rating: " + rating); 62 | // } 63 | // this.rating = rating; 64 | // } 65 | 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/code/book.h: -------------------------------------------------------------------------------- 1 | 2 | typedef struct { 3 | int year; 4 | int month; 5 | int day; 6 | } Date; 7 | 8 | typedef struct { 9 | char *firstName; 10 | char *lastName; 11 | Date dateOfBirth; 12 | } Author; 13 | 14 | typedef struct { 15 | char *title; 16 | Author author; 17 | Date releaseDate; 18 | double rating; 19 | } Book; 20 | 21 | 22 | /** 23 | * This is a "factory" function that creates a new instance of a Book 24 | */ 25 | Book *createBook(const char *title, 26 | const char *authorFirstName, 27 | const char *authorLastName, 28 | int releaseYear, 29 | double rating); 30 | 31 | void initBook(Book *b, 32 | const char *title, 33 | const char *authorFirstName, 34 | const char *authorLastName, 35 | int releaseYear, 36 | double rating); 37 | 38 | /** 39 | * Prints the given book to the standard output 40 | */ 41 | void printBook(const Book *b); 42 | 43 | /** 44 | * Returns a human-readable representation of the given Book 45 | */ 46 | char *bookToString(const Book *b); 47 | 48 | Book *loadFromCsvFile(const char *fileName, int *numBooks); 49 | 50 | Book *getBestBook(const Book *library, int numBooks); 51 | 52 | Book *getWorstBook(const Book *library, int numBooks); 53 | 54 | Book *getBooksByAuthor(const Book *library, int numBooks, Author a, int *numAuthorBooks); 55 | 56 | /** 57 | * Returns an integer: 58 | * something negative if a comes before b with respect to last name/first name 59 | * zero if the authors have the same name 60 | * something positive if b comes before a 61 | * 62 | */ 63 | int compareAuthor(const Author *a, const Author *b); -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/code/bookDemo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "book.h" 8 | 9 | int main(int argc, char **argv) { 10 | 11 | int numBooks; 12 | Book *library = loadFromCsvFile("books.csv", &numBooks); 13 | 14 | //print each book 15 | for(int i=0; i { 6 | 7 | private String firstName; 8 | private String lastName; 9 | private LocalDate dateOfBirth; 10 | 11 | /** 12 | * @param firstName 13 | * @param lastName 14 | */ 15 | public Author(String firstName, String lastName) { 16 | super(); 17 | this.firstName = firstName; 18 | this.lastName = lastName; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return lastName +", " + firstName; 24 | } 25 | 26 | public String getFirstName() { 27 | return firstName; 28 | } 29 | 30 | public String getLastName() { 31 | return lastName; 32 | } 33 | 34 | public LocalDate getDateOfBirth() { 35 | return dateOfBirth; 36 | } 37 | 38 | @Override 39 | public int hashCode() { 40 | final int prime = 31; 41 | int result = 1; 42 | result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); 43 | result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); 44 | return result; 45 | } 46 | 47 | @Override 48 | public boolean equals(Object obj) { 49 | if (this == obj) 50 | return true; 51 | if (obj == null) 52 | return false; 53 | if (getClass() != obj.getClass()) 54 | return false; 55 | Author other = (Author) obj; 56 | if (firstName == null) { 57 | if (other.firstName != null) 58 | return false; 59 | } else if (!firstName.equals(other.firstName)) 60 | return false; 61 | if (lastName == null) { 62 | if (other.lastName != null) 63 | return false; 64 | } else if (!lastName.equals(other.lastName)) 65 | return false; 66 | return true; 67 | } 68 | 69 | @Override 70 | public int compareTo(Author that) { 71 | //compare this to that... 72 | int result = this.getLastName().compareTo(that.getLastName()); 73 | if(result == 0) { 74 | result = this.getFirstName().compareTo(that.getFirstName()); 75 | } 76 | return result; 77 | 78 | } 79 | 80 | 81 | 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/code/sorting/Book.java: -------------------------------------------------------------------------------- 1 | package unl.cse; 2 | 3 | import java.time.LocalDate; 4 | 5 | public class Book { 6 | 7 | private String title; 8 | private Author author; 9 | private LocalDate releaseDate; 10 | private double rating; 11 | public String getIsbn() { 12 | return isbn; 13 | } 14 | 15 | private String isbn; 16 | 17 | /** 18 | * @param title 19 | * @param author 20 | * @param releaseDate 21 | * @param rating 22 | */ 23 | public Book(String title, Author author, LocalDate releaseDate, double rating) { 24 | this.title = title; 25 | this.author = author; 26 | this.releaseDate = releaseDate; 27 | this.rating = rating; 28 | } 29 | 30 | /** 31 | * This is a copy constructor: it allows you to create a new copy of a Book instance 32 | * possibly with different values; example: a different value for a rating 33 | */ 34 | public Book(Book that, double rating) { 35 | this.title = that.title; 36 | this.author = that.author; 37 | this.releaseDate = that.releaseDate; 38 | this.rating = rating; 39 | 40 | } 41 | 42 | 43 | @Override 44 | public String toString() { 45 | return String.format("%s by %s was released in %d with a rating of %f", title, author, releaseDate.getYear(), rating); 46 | } 47 | 48 | public double getRating() { 49 | return this.rating; 50 | } 51 | 52 | public String getTitle() { 53 | return title; 54 | } 55 | 56 | public Author getAuthor() { 57 | return author; 58 | } 59 | 60 | public LocalDate getReleaseDate() { 61 | return releaseDate; 62 | } 63 | 64 | // public void setRating(double rating) { 65 | // if(rating < 0 || rating > 5.0) { 66 | // throw new RuntimeException("Attempted to set an invalid rating: " + rating); 67 | // } 68 | // this.rating = rating; 69 | // } 70 | 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/code/sorting/book.h: -------------------------------------------------------------------------------- 1 | 2 | typedef struct { 3 | int year; 4 | int month; 5 | int day; 6 | } Date; 7 | 8 | typedef struct { 9 | char *firstName; 10 | char *lastName; 11 | Date dateOfBirth; 12 | } Author; 13 | 14 | typedef struct { 15 | char *title; 16 | Author author; 17 | Date releaseDate; 18 | double rating; 19 | } Book; 20 | 21 | 22 | /** 23 | * This is a "factory" function that creates a new instance of a Book 24 | */ 25 | Book *createBook(const char *title, 26 | const char *authorFirstName, 27 | const char *authorLastName, 28 | int releaseYear, 29 | double rating); 30 | 31 | void initBook(Book *b, 32 | const char *title, 33 | const char *authorFirstName, 34 | const char *authorLastName, 35 | int releaseYear, 36 | double rating); 37 | 38 | /** 39 | * Prints the given book to the standard output 40 | */ 41 | void printBook(const Book *b); 42 | 43 | /** 44 | * Returns a human-readable representation of the given Book 45 | */ 46 | char *bookToString(const Book *b); 47 | 48 | Book *loadFromCsvFile(const char *fileName, int *numBooks); 49 | 50 | Book *getBestBook(const Book *library, int numBooks); 51 | 52 | Book *getWorstBook(const Book *library, int numBooks); 53 | 54 | Book *getBooksByAuthor(const Book *library, int numBooks, Author a, int *numAuthorBooks); 55 | 56 | /** 57 | * Returns an integer: 58 | * something negative if a comes before b with respect to last name/first name 59 | * zero if the authors have the same name 60 | * something positive if b comes before a 61 | * 62 | */ 63 | int compareAuthor(const Author *a, const Author *b); 64 | 65 | /** 66 | * Orders books in descreasing order with respect to their rating 67 | */ 68 | int cmpBookByRating(const void *a, const void *b); 69 | 70 | int cmpBookByAuthor(const void *a, const void *b); 71 | 72 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/155H/code/sorting/bookDemo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "book.h" 8 | 9 | int main(int argc, char **argv) { 10 | 11 | int numBooks; 12 | Book *library = loadFromCsvFile("books.csv", &numBooks); 13 | 14 | //print each book 15 | for(int i=0; ititle); 45 | } 46 | 47 | return 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/194/01-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I 2 | ## ECEN 194 - Fall 2022 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/194/11-encapsulation.md: -------------------------------------------------------------------------------- 1 | 2 | # ECEN 194 - Computer Science I 3 | ## Encapsulation - Structures 4 | ### Fall 2022 5 | 6 | ## Motivating Exercise 7 | 8 | * Given (CSV) data on books, compute various statistics/reports: 9 | * What is the best book? 10 | * What is the worst book? 11 | * What are all books written by Frank Herbert? 12 | 13 | ## Introduction 14 | 15 | * Built-in primitive types `int, double, char` are very limiting: not everything is a number or character 16 | * Real world entities are *composed* of multiple pieces of data 17 | * Encapsulation is when you group multiple pieces of data together into one "object" or "thing" 18 | * Solution in C: structures 19 | * You can define a structure using the `typedef struct` keyword 20 | * Encapsulation is a mechanism by which you can: 21 | 1. Group pieces of data together into one logical "unit" 22 | 2. Protect that data from the outside world 23 | 3. Group functionality that acts on that data with the data 24 | * C only supports #1: weak encapsulation 25 | 26 | ### Defining Structures 27 | 28 | ```c 29 | 30 | typedef struct { 31 | int year; 32 | int month; 33 | int day; 34 | } Date; 35 | 36 | typedef struct { 37 | char *firstName; 38 | char *lastName; 39 | Date dateOfBirth; 40 | } Author; 41 | 42 | typedef struct { 43 | char *title; 44 | Author author; 45 | double rating; 46 | Date releaseDate; 47 | } Book; 48 | 49 | 50 | ``` 51 | 52 | Observations: 53 | * You use the keywords `typedef struct` and within curly brackets provide a "list" of the structure's *member variables* 54 | * Each one is ended with a semicolon: `;` 55 | * The name of the structure is provided at the end with a semicolon 56 | * The name should follow an `UpperCamelCasing` convention 57 | * Member variables should use a `lowerCamelCasing` convention 58 | * When a structure contains another structure, it is known as *composition* 59 | * When you declare an "instance" of your structure, you can access its member variable variables using the "dot" operator: `.` 60 | * When you have a *pointer* to a structure, you can/should use the array operator: `->` 61 | 62 | ## Constructors or "Factory" functions 63 | 64 | * Creating instances of structures can be a lot of boilerplate code 65 | * Instead: create a function to do the grunt work for you! 66 | * OOP: this would be a "constructor" 67 | * C: factory functions 68 | 69 | 70 | ```text 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | ``` 81 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/194/code/bookDemo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "book.h" 9 | 10 | int main(int argc, char **argv) { 11 | 12 | int numBooks; 13 | Book *books = loadBooksFromCsvFile("books.csv", &numBooks); 14 | 15 | qsort(books, numBooks, sizeof(Book), cmpBooksByRatingDesc); 16 | 17 | printf("Books:\n"); 18 | for(int i=0; i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | 11 | int *randomArr(int n) { 12 | int *a = (int *)malloc(sizeof(int)*n); 13 | for(int i=0; i *y) { 44 | return 1; 45 | } else { 46 | return 0; 47 | } 48 | 49 | } 50 | 51 | /** 52 | * This is a comparator for integers that orders them in descending 53 | */ 54 | int cmpIntDescending(const void *a, const void *b) { 55 | 56 | return cmpIntAscending(b, a); 57 | 58 | } 59 | 60 | 61 | int main(int argc, char **argv) { 62 | 63 | srand(time(NULL)); 64 | 65 | //selection sort: 1,000,000: 20 minutes 66 | //selection sort: 10,000,000: 2000 minutes = 33 hours 67 | //selection sort: 100,000,000: 2000 minutes = 3300 hours = 4.5 months 68 | 69 | int n = 10; 70 | int *arr = randomArr(n); 71 | 72 | qsort(arr, n, sizeof(int), cmpIntAscending); 73 | 74 | 75 | return 0; 76 | } -------------------------------------------------------------------------------- /notes/1228-Fall2022/194/code/weight.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | 5 | #include "weight.h" 6 | 7 | ErrorCode convertWeight(double kilogramForce, double *pounds, double *ounces, double *newtons) { 8 | 9 | if(pounds == NULL || ounces == NULL || newtons == NULL) { 10 | return NULL_POINTER_ERROR; 11 | } else if (kilogramForce < 0) { 12 | return NEGATIVE_VALUE_ERROR; 13 | } 14 | 15 | *pounds = kilogramForce * 2.20462; 16 | *ounces = kilogramForce * 2.20462 * 16; 17 | *newtons = kilogramForce * 9.80665; 18 | 19 | return NO_ERROR; 20 | 21 | } 22 | 23 | double getSum(const double *arr, int n) { 24 | double total = 0.0; 25 | for(int i=0; i 2 | #include 3 | #include 4 | 5 | #include "weight.h" 6 | 7 | int main(int argc, char **argv) { 8 | 9 | //test the weight conversion: 10 | double kgf = 100.0; 11 | double expectedPounds = 220.462; 12 | double expectedOunces = 3527.392; 13 | double expectedNewtons = 9.80665; 14 | double actualPounds, actualOunces, actualNewtons; 15 | int errorCode = convertWeight(kgf, &actualPounds, &actualOunces, &actualNewtons); 16 | if(errorCode != 0) { 17 | printf("FAIL\n"); 18 | } else if( fabs(actualPounds - expectedPounds) ) { 19 | printf("FAIL\n"); 20 | } 21 | 22 | //using arrays and functions: 23 | // often you need to pass an array to a function 24 | // Ex: pass an array of weights to a function to sum them up! 25 | int n = 5; 26 | double weights[] = {42.5, 98.1, 4324.23, 123.45}; 27 | double total = getSum(weights, n); 28 | printf("total = %f\n", total); 29 | 30 | total = getSum(weights, n); 31 | printf("total = %f\n", total); 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /notes/1228-Fall2022/194/review.md: -------------------------------------------------------------------------------- 1 | 2 | # Computer Science I 3 | ## ECEN 194 - Fall 2022 4 | ### Review: functions, pointers, pass-by-reference, error handling 5 | 6 | * Pointers: 7 | * `int x;` a regular old variable 8 | * `int *a;` is a pointer variable 9 | * If you have a regular variable and you want to make it into a pointer: use the referencing operator: `&x` 10 | * If you have a pointer variable and you want to make it into a regular variable: *de*referencing operator: `*a` 11 | * Passing-by-value: 12 | * *COPIES* of the variable's values are passed to the function 13 | * Any changes to those parameters *do not affect* the original variables 14 | * Pass-by-reference: 15 | * *pointers* or memory locations are passed to the function 16 | * Any changes via the pointers *do affect* the original variables 17 | * Use cases: 18 | * You can "return" multiple values 19 | * It frees up the return value for error handling 20 | * Error Handling: 21 | * Look before you leap 22 | * Error handling in a function is the ***absolute first thing you*** 23 | * Null pointer checks come first: they are the first of the first 24 | * You do NOT: 25 | * print anything 26 | * Exit the program 27 | * YOu return an error code: 28 | * an integer 29 | * zero for no error 30 | * non-zero for some type of error 31 | * You can use an enumerated type to use human-readable words for error codes 32 | * Tips: 33 | * You NEVER EVER include source files! 34 | * Generally you should avoid dereferencing too much: if you want to set a value, dereference it ONCE at the end of the function; use temporary variables instead! 35 | -------------------------------------------------------------------------------- /notes/1228-Fall2022/books.csv: -------------------------------------------------------------------------------- 1 | 20 2 | Harry Potter and the Deathly Hallows,J.K.,Rowling,2007,4.62 3 | The Name of the Wind,Patrick,Rothfuss,2007,4.55 4 | The Wise Man's Fear,Patrick,Rothfuss,2011,4.58 5 | Colour of Magic,Terry,Pratchett,1983,3.98 6 | Wyrd Sisters,Terry,Pratchett,1988,4.12 7 | Moby Dick,Herman,Melville,1851,3.48 8 | Neuromancer,William,Gibson,1984,3.88 9 | Stranger in a Strange Land,Robert,Heinlein,1961,3.91 10 | Have Space Suit-Will Travel,Robert,Heinlein,1958,3.89 11 | The Clan of the Cave Bear,Jean,Auel,1980,4.02 12 | Dianetics,L. Ron,Hubbard,1950,2.33 13 | Dune,Frank,Herbert,1965,4.20 14 | Dune Messiah,Frank,Herbert,1969,3.86 15 | Children of Dune,Frank,Herbert,1976,3.91 16 | God Emperor of Dune,Frank,Herbert,1981,3.82 17 | Heretics of Dune,Frank,Herbert,1984,3.84 18 | Chapterhouse: Dune,Frank,Herbert,1985,3.89 19 | Mort,Terry,Pratchett,1987,4.22 20 | Raising Steam,Terry,Pratchett,2013,3.94 21 | A Game of Thrones,George,Martin,1996,4.45 22 | -------------------------------------------------------------------------------- /notes/1238-Fall2023/155E/01-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I 2 | ## CSCE 155E - Fall 2023 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | 9 | ## Hello World 10 | 11 | ```c 12 | 13 | int i = 10; 14 | printf("Hello WOrld"); 15 | 16 | ``` 17 | -------------------------------------------------------------------------------- /notes/1238-Fall2023/155E/12-recursion.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155E - Computer Science I 3 | ## Recursion 4 | ### Fall 2023 5 | 6 | * Challenge: print a count down without a loop! 7 | * What is recursion? 8 | * In general, *recursion* is something that references itself 9 | * In coding, a function is recursive if it makes one or more calls to itself 10 | * Mathematics: fractals are self-similar objects 11 | * Fibonacci Sequence 12 | 13 | $$\begin{equation*} 14 | f(n) = \begin{cases} 15 | 1 & n = 1\\ 16 | 1 & n = 2\\ 17 | f(n-1) + f(n-2) & \text{otherwise} 18 | \end{cases} 19 | \end{equation*}$$ 20 | 21 | $$1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...$$ 22 | 23 | ## Designing Recursive functions 24 | 25 | * Every recursive function needs one or more *base cases* in which no further recursion is performed 26 | * Some base cases may be for error handling 27 | * You make one or more recursive calls that *must* make progress toward the base conditions 28 | 29 | ## Recursion: The Good 30 | 31 | * Recursion *can* be useful or "good" 32 | * many divide-and-conquer style algorithms are presented as recursive 33 | * It is a good way to think "inductively" 34 | * Many functional programming languages encourage or primarily use recursion (Haskell, Scheme, Lisp) 35 | * Recursion can also lead to "simple" or "clean" or "beautiful" code that is easily understood 36 | 37 | ## Recursion: The Bad 38 | 39 | * You risk overflowing your stack with runaway recursion 40 | * Even if it isn't runaway (infinite) then you are still abusing the call stack! Which is *limited* 41 | * You risk a naive *exponential* approach to a problem 42 | 43 | ## Eliminating Recursion 44 | 45 | * Any recursive (code-wise) function can be rewritten as a non-recursive function! 46 | * YOU can always use regular old loops and data structures to "simulate" recursion 47 | * Another technique: tail recursion 48 | * You can use *memoization* 49 | * You can use recursion, but... 50 | * You store (cache) results so that they are not *recomputed* 51 | * YOu store results into a table (cache) 52 | * When you need to compute a value: 53 | * Check the table/cache, if already computed, use it, no recursion 54 | * If not, then yeah, okay pay for the recursion 55 | * After computing it, *store* it in your table 56 | * Example: use memoization to compute the fibonaccci numbers 57 | 58 | ## More Exercises 59 | 60 | * Sum up numbers in an array using recursion 61 | * Strategy A: Decrease & Conquer 62 | * Strategy B: Divide & Conquer 63 | 64 | 65 | ```c 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | ``` 75 | -------------------------------------------------------------------------------- /notes/1238-Fall2023/155H/01-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I - Honors 2 | ## CSCE 155H - Fall 2023 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | 9 | ```c 10 | 11 | int main() { 12 | printf("Hello WOrld!"); 13 | } 14 | 15 | ``` 16 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/01-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I 2 | ## CSCE 155E - Fall 2024 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/11-encapsulation.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155E - Computer Science I 3 | ## Encapsulation - Structures 4 | ### Fall 2024 5 | 6 | * Built-in primitive types (`int, double, char`) are limiting: not everything is a simple number of character 7 | * Real world entities are made up of multiple pieces of data 8 | * In programming languages you can *collect* and **encapsulate** multiple pieces of data together into one logical unit 9 | * In C this is achieved using *structures* 10 | * Structures are "weak" encapsulation 11 | * Encapsulation in general: 12 | 1. The grouping of data 13 | 2. The protection of data 14 | 3. The grouping of functionality that acts on that data 15 | * C is NOT an OOP language and only supports #1 ("weak" encapsulation) 16 | 17 | ## Defining Structures 18 | 19 | * Create a structure that models a *book* 20 | * You use the syntax: `typedef struct` 21 | * You place a collection of variables inside `{}` (delimited by `;`) 22 | * You provide a name at the end + `;` 23 | * Generally: modern convention is to use `UpperCamelCasing` 24 | * Generally, structure declarations are placed into header files, often of similar name, `book.h` 25 | * Generally you should document them 26 | * Order matters: if you use *composition* (one structure is composed of other structures) then you need to declare the used structures first 27 | * Usage: 28 | * Once defined you can declare them: `Book b1;` or a pointer: `Book *b2;` 29 | * To access member variables of a regular-old-struture: dot operator: `b1.isbn` 30 | * to access member variables of a pointer-to-structure: arrow operator: `b2->isbn` 31 | * You can define factory functions to create new instances of your structure, returning a pointer to a *dynamically allocated* instance of the structure 32 | * remember: to use `sizeof(Book)` with `malloc()` 33 | * Other common functions: 34 | * a "to string" function that formats the structure as a string `char *` 35 | * A "destructor" function: `freeBook()` that frees *all* memory assoicated with the structure 36 | * An "initializer" function: if you already have an instance of a book, you can pass it as a pointer and *initialize* instead of create 37 | * Bulk functions: print all books, destroy all books, etc. that operate on *arrays* of structures 38 | 39 | ```text 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | ``` 50 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/code/book.h: -------------------------------------------------------------------------------- 1 | //TODO: documentation 2 | 3 | typedef struct { 4 | int year; 5 | int month; 6 | int day; 7 | } Date; 8 | 9 | typedef struct { 10 | char *firstName; 11 | char *lastName; 12 | Date birthDate; 13 | } Person; 14 | 15 | typedef struct { 16 | char *isbn; 17 | char *title; 18 | double rating; 19 | Person author; 20 | Date publishDate; 21 | } Book; 22 | 23 | /** 24 | * TODO: documentation 25 | */ 26 | char *deepStrCopy(const char *s); 27 | 28 | /** 29 | * Creates a new book instance (on the heap) and returns it with the given 30 | * data. 31 | */ 32 | Book *createBook(const char *isbn, 33 | const char *title, 34 | const char *authorFirstName, 35 | const char *authorLastName); 36 | 37 | /** 38 | * Initializes the given book with the given data. 39 | */ 40 | void initBook(Book *b, 41 | const char *isbn, 42 | const char *title, 43 | double rating, 44 | const char *authorFirstName, 45 | const char *authorLastName, 46 | int publishYear); 47 | 48 | /** 49 | * Prints the given Book instance to the standard output 50 | */ 51 | void printBook(const Book *b); 52 | 53 | /** 54 | * Returns a formatted string representation of the given Book instance 55 | */ 56 | char *bookToString(const Book *b); 57 | 58 | /** 59 | * Frees up the given book along with all of its data 60 | */ 61 | void freeBook(Book *b); 62 | 63 | /** 64 | * Loads book data from the given file and returns an array of 65 | * Book instances. Also sets n to the size of the resulting array. 66 | */ 67 | Book *loadBookData(const char *fileName, int *n); 68 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/code/bookDemo.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Demonstration code template. 3 | * 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "book.h" 11 | 12 | int main(int argc, char **argv) { 13 | 14 | // Book *scythe = createBook("2983479238", "Scythe", "Neal", "Shusterman"); 15 | // Book *dispossessed = createBook("23423532", "The Dispossessed", "Ursula", "le Guin"); 16 | 17 | // printBook(scythe); 18 | // printBook(dispossessed); 19 | 20 | // freeBook(scythe); 21 | // freeBook(dispossessed); 22 | 23 | // Book goodOmens; 24 | // initBook(&goodOmens, "987423987", "Good Omens", "Neil", "Gaiman"); 25 | // printBook(&goodOmens); 26 | 27 | int numBooks; 28 | Book *books = loadBookData("./goodreads-abridged.csv", &numBooks); 29 | for(int i=0; i bestBook.rating ) { 41 | bestBook = books[i]; 42 | } 43 | } 44 | printf("Best book is:\n"); 45 | printBook(&bestBook); 46 | 47 | 48 | //2. Goal B: find the "Worst" book (lowest year); 49 | //outline: 50 | //assume initially that its the first one: 51 | Book worstBook = books[0]; 52 | for(int i=0; i 6 | #include 7 | 8 | int main(int argc, char **argv) { 9 | 10 | if(argc != 4) { 11 | printf("ERROR: provide a b n\n"); 12 | exit(1); 13 | } 14 | 15 | int a = atoi(argv[1]); 16 | int b = atoi(argv[2]); 17 | int n = atoi(argv[3]); 18 | 19 | if(a < 2 || b < 2 || n < 1) { 20 | printf("ERROR; invalid input\n"); 21 | exit(2); 22 | } 23 | 24 | for(int i=1; i<=n; i++) { 25 | if(i % a == 0 && i % b == 0) { 26 | printf("Go Nebraska!\n"); 27 | } else if(i % a == 0) { 28 | printf("Go Huskers\n"); 29 | } else if(i % b == 0) { 30 | printf("Go Mavs\n"); 31 | } else { 32 | printf("%d\n", i); 33 | } 34 | } 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/code/compute_roots_clas.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Chris Bourke 3 | * 2024-09-04 4 | * 5 | * This program reads in 3 coefficients (from command line arguments) 6 | * and uses the quadratic formula to compute the roots of a quadratic polynomial: 7 | * 8 | * ax^2 + bx + c 9 | * 10 | * See more at here. 11 | */ 12 | #include 13 | #include 14 | #include 15 | 16 | int main(int argc, char **argv) { 17 | 18 | double a, b, c; 19 | 20 | //if argc is not 4, then we have error... 21 | if(argc != 4) { 22 | printf("ERROR: you need to provide a, b, c as command line arguments!\n"); 23 | exit(1); 24 | } 25 | 26 | a = atof(argv[1]); 27 | b = atof(argv[2]); 28 | c = atof(argv[3]); 29 | 30 | //if a is zero, this is not a quadratic equation 31 | if(a == 0) { 32 | printf("ERROR: a cannot be zero, that is a linear equation, you know how to solve that!\n"); 33 | exit(1); 34 | } 35 | 36 | double root1 = ( -b + sqrt( pow(b, 2) - 4*a*c ) ) / (2*a); 37 | double root2 = ( -b - sqrt( pow(b, 2) - 4*a*c ) ) / (2*a); 38 | 39 | printf("The roots of %fx^2 + %fx + %f are %f and %f\n", a, b, c, root1, root2); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/code/compute_roots_interactive.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Chris Bourke 3 | * 2024-09-04 4 | * 5 | * This program reads in 3 coefficients from the user and uses 6 | * the quadratic formula to compute the roots of a quadratic polynomial: 7 | * 8 | * ax^2 + bx + c 9 | * 10 | * See more at here. 11 | */ 12 | #include 13 | #include 14 | #include 15 | 16 | int main(int argc, char **argv) { 17 | 18 | double a, b, c; 19 | 20 | printf("Please enter a: "); 21 | scanf("%lf", &a); 22 | 23 | printf("Please enter b: "); 24 | scanf("%lf", &b); 25 | 26 | printf("Please enter c: "); 27 | scanf("%lf", &c); 28 | 29 | double root1 = ( -b + sqrt( pow(b, 2) - 4*a*c ) ) / (2*a); 30 | double root2 = ( -b - sqrt( pow(b, 2) - 4*a*c ) ) / (2*a); 31 | 32 | printf("The roots of %fx^2 + %fx + %f are %f and %f\n", a, b, c, root1, root2); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/code/corn.c: -------------------------------------------------------------------------------- 1 | /** 2 | * TODO: author header: name, date, purpose 3 | * 4 | */ 5 | #include 6 | #include 7 | #include 8 | 9 | //#define CORN_DENSITY 720.83; 10 | 11 | int main(int argc, char **argv) { 12 | 13 | const double CORN_DENSITY = 720.83; 14 | 15 | CORN_DENSITY = 2; 16 | if(argc != 4) { 17 | printf("ERROR: provide radius height percent\n"); 18 | exit(1); 19 | } 20 | 21 | double radius = atof(argv[1]); 22 | double height = atof(argv[2]); 23 | double percent = atof(argv[3]); 24 | 25 | if(radius < 0 || height < 0 || percent < 0 || percent > 1) { 26 | printf("ERROR: invalid input(s)\n"); 27 | exit(2); 28 | } 29 | 30 | double volume = height * M_PI * radius * radius; 31 | double weight = volume * CORN_DENSITY * percent; 32 | 33 | printf("Radius: %fm\n", radius); 34 | printf("Height: %fm\n", height); 35 | printf("Percentage: %f%%\n", percent * 100); 36 | printf("Total Volume: %f mˆ3\n", volume); 37 | printf("Total Weight: %f kg\n", weight); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/code/fizzbuzz.c: -------------------------------------------------------------------------------- 1 | /** 2 | * CSCE 155E - Fall 2024 3 | * 4 | * An implementation of the classic fizz buzz program. 5 | * 6 | */ 7 | #include 8 | #include 9 | 10 | int main(int argc, char **argv) { 11 | 12 | int i = 1; 13 | int n = 100; 14 | while(i <= n) { 15 | 16 | if( i % 15 == 0 ) { 17 | printf("FizzBuzz\n"); 18 | } else if(i % 3 == 0) { 19 | //divisible by three 20 | printf("Fizz\n"); 21 | } else if(i % 5 == 0) { 22 | //divisible by five 23 | printf("Buzz\n"); 24 | } else { 25 | printf("%d\n", i); 26 | } 27 | i++; 28 | } 29 | 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/code/game.c: -------------------------------------------------------------------------------- 1 | /** 2 | * TODO: full author header 3 | * 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int main(int argc, char **argv) { 11 | 12 | if(argc != 2) { 13 | printf("ERROR: provide two command line arguments (points for, against)\n"); 14 | exit(1); 15 | } 16 | 17 | int n = atoi(argv[1]); 18 | 19 | int round = 1; 20 | int aPoints = 0; 21 | int bPoints = 0; 22 | 23 | while(n != 1) { 24 | if(n % 2 == 0) { 25 | printf("Round %d: %d... even, player A scores!\n", round, n); 26 | n = n / 2; 27 | aPoints++; 28 | } else { 29 | //n is odd 30 | printf("Round %d: %d... odd, player B scores!\n", round, n); 31 | n = 3 * n + 1; 32 | bPoints++; 33 | } 34 | round++; 35 | } 36 | printf("Game Over\n"); 37 | 38 | int aFinalScore = (2*aPoints - 1) / 3; 39 | int bFinalScore = (3*bPoints + 1) / 2; 40 | 41 | printf("Results:\n"); 42 | printf("Player Points Total Score\n"); 43 | printf("A %d %d\n", aPoints, aFinalScore); 44 | printf("b %d %d\n", bPoints, bFinalScore); 45 | if(aFinalScore > bFinalScore) { 46 | printf("A wins!\n"); 47 | } else if(aFinalScore < bFinalScore) { 48 | printf("B wins!\n"); 49 | } else { 50 | printf("Tie!\n"); 51 | } 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155E/code/loan.c: -------------------------------------------------------------------------------- 1 | /** 2 | * CSCE 155E - Fall 2024 3 | * 4 | * Computes a loan amortization table 5 | * 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * Returns the given amount rounded to the nearest cent 14 | * (rounded to the nearest hundredth) 15 | */ 16 | double roundToCents(double amount); 17 | 18 | /** 19 | * Computes the monthly payment of a loan with the given 20 | * inputs. See here 21 | */ 22 | double getMonthlyPayment(double principle, double annualRate, int years); 23 | 24 | int main(int argc, char **argv) { 25 | 26 | double annualRate = 0.05; 27 | double monthlyRate = annualRate / 12; 28 | double principle = 10000.0; 29 | double balance = principle; 30 | int years = 5; 31 | int months = years * 12; 32 | 33 | double monthlyPayment = getMonthlyPayment(principle, annualRate, years); 34 | //TODO: round to the nearest cent... 35 | monthlyPayment = roundToCents(monthlyPayment); 36 | 37 | printf("Monthly Payment: $%.2f\n", monthlyPayment); 38 | 39 | for(int i=1; i 6 | #include 7 | #include 8 | #include 9 | 10 | int main(int argc, char **argv) { 11 | 12 | if(argc != 3) { 13 | printf("ERROR: provide two command line arguments (points for, against)\n"); 14 | exit(1); 15 | } 16 | 17 | int pointsFor = atoi(argv[1]); 18 | int pointsAgainst = atoi(argv[2]); 19 | 20 | double winPercentage = pow(pointsFor, 2.37) / (pow(pointsFor, 2.37) + pow(pointsAgainst, 2.37)); 21 | 22 | int numWins = round(winPercentage * 12); 23 | int numLoss = 12 - numWins; 24 | 25 | printf("Win Percentage: %.2f%%\n", winPercentage * 100.0); 26 | printf("Win/Loss: %d/%d\n", numWins, numLoss); 27 | 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/01-intro.md: -------------------------------------------------------------------------------- 1 | # Computer Science I - Honors 2 | ## CSCE 155H - Fall 2024 3 | ### Introduction/Getting Started 4 | 5 | - Course Overview 6 | - Syllabus 7 | - Getting Started 8 | 9 | ```c 10 | 11 | int main(int argc, char **argv) { 12 | printf("Hello oOrld!"); 13 | printf("My name is Chris\n"); 14 | } 15 | 16 | ``` 17 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/11-encapsulation.md: -------------------------------------------------------------------------------- 1 | 2 | # CSCE 155H - Computer Science I 3 | ## Encapsulation - Structures/Classes 4 | ### Fall 2024 5 | 6 | * Built-in primitive types `int, double, char` are very limiting: not everything is a number or character 7 | * Real world entities are *composed* of multiple pieces of data 8 | * Encapsulating multiple pieces of data into one "object" or "thing" allows you to deal with that one "thing" 9 | * Solution: encapsulation 10 | * C: structures 11 | * Java: Classes 12 | * Encapsulation is a mechanism that allows you to: 13 | 1. Group pieces of data together to form one logical "unit" 14 | 2. Protect that data from the outside world/code 15 | 3. Group functionality that acts on that data with the data 16 | * C: weak encapsulation, it only supports #1 17 | * Java: supports all three, it has *strong* encapsulation (because it is an OOP = Object-Oriented Programming language) 18 | 19 | ## C 20 | 21 | * C only supports *weak* encapsulation: #1 the grouping of data through *structures* 22 | * Defining a structure: 23 | * Define using `typedef struct` 24 | * Generally: use `UpperCamelCasing` for structure name 25 | * Use `lowerCamelCasing` for structure variables 26 | * Declaration order matters 27 | * Other: 28 | * IF you have a regular structure, `Book b`, then use the dot operator: `b.title` 29 | * If you have a pointer: `Book *b` then use the arrow operator 30 | `b->title` 31 | 32 | ## Java 33 | 34 | * Java is an OOP language that uses classes for encapsulation 35 | * Class names are `UpperCamelCased` 36 | * *Member variables* are `lowerCamelCased` 37 | * Recall that Java offers **strong** encapsulation 38 | * Java supports "strong encapsulation": you can "protect" your variables from the outside world 39 | * `public` allows *any* piece of code to change or view your variables! Chaos! 40 | * `protected` (inheritance: next semester) 41 | * `private`: only the class and instances of the class can see the variable 42 | * Best practice: make everything `private` unless you have a Very Good Reason 43 | * YOu can control access through getters/setters (but generally you prefer *immutable objects*) 44 | * Java allows you to define *nontrivial* methods; ex: `getAge()` 45 | 46 | 47 | ```text 48 | 49 | 50 | 51 | 52 | ``` 53 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/Agm.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | /** 4 | * Chris Bourke 5 | * 2024-09-13 6 | * 7 | * This program reads command line arguments for two numbers 8 | * and computes and outputs their arithmetic–geometric. See 9 | * 10 | * here 11 | * 12 | */ 13 | public class Agm { 14 | 15 | public static void main(String args[]) { 16 | 17 | final double TOLERANCE = 0.0000001; 18 | 19 | if(args.length != 2) { 20 | System.err.printf("ERROR: expected 2 numbers\n"); 21 | System.exit(1); 22 | } 23 | double x = Double.parseDouble(args[0]); 24 | double y = Double.parseDouble(args[1]); 25 | 26 | if(x < 0 || y < 0) { 27 | System.err.printf("ERROR: both values should be non-negative\n"); 28 | System.exit(2); 29 | } else if( Math.abs(x - y) < TOLERANCE) { 30 | System.err.printf("agm(%f, %f) = %.20f\n", x, y, x); 31 | System.exit(0); 32 | } 33 | 34 | double a_mean_prev = x, a_mean_curr = 0; 35 | double g_mean_prev = y, g_mean_curr = 0; 36 | 37 | while( Math.abs(a_mean_prev - g_mean_prev) > TOLERANCE ) { 38 | a_mean_curr = (a_mean_prev + g_mean_prev) / 2; 39 | g_mean_curr = Math.sqrt(a_mean_prev * g_mean_prev); 40 | a_mean_prev = a_mean_curr; 41 | g_mean_prev = g_mean_curr; 42 | } 43 | System.out.printf("agm(%f, %f) = %.20f\n", x, y, a_mean_curr); 44 | 45 | 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/Book.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | import java.time.LocalDate; 4 | import java.time.Period; 5 | 6 | public class Book { 7 | 8 | private String isbn; 9 | private String title; 10 | private LocalDate publishDate; 11 | private Double rating; 12 | private Person author; 13 | 14 | public Book(String isbn, String title, LocalDate publishDate, Person author) { 15 | this(isbn, title, publishDate, author, null); 16 | } 17 | 18 | public Book(String isbn, String title, LocalDate publishDate, Person author, Double rating) { 19 | this.isbn = isbn; 20 | this.title = title; 21 | this.publishDate = publishDate; 22 | this.author = author; 23 | this.rating = rating; 24 | } 25 | 26 | public Book(String title, LocalDate publishDate, Person author) { 27 | this(null, title, publishDate, author); 28 | } 29 | 30 | 31 | 32 | @Override 33 | public String toString() { 34 | if(this.publishDate == null) { 35 | return String.format("%s by %s (None) %.2f", this.title, this.author, this.rating); 36 | } else { 37 | return String.format("%s by %s (%d) %.2f", this.title, this.author, this.publishDate.getYear(), this.rating); 38 | } 39 | } 40 | 41 | public String getIsbn() { 42 | return isbn; 43 | } 44 | 45 | // public void setIsbn(String isbn) { 46 | // //TODO: validate the isbn as a valid ISBN 47 | // if(isbn == null) { 48 | // throw new IllegalArgumentException("You cannot set an ISBN to null"); 49 | // } 50 | // this.isbn = isbn; 51 | // } 52 | 53 | public String getTitle() { 54 | return title; 55 | } 56 | 57 | 58 | public LocalDate getPublishDate() { 59 | return publishDate; 60 | } 61 | 62 | 63 | public Person getAuthor() { 64 | return author; 65 | } 66 | 67 | public double getAgeInYears() { 68 | Period p = Period.between(this.publishDate, LocalDate.now()); 69 | double years = p.getYears(); 70 | years += p.getDays() / 365.0; 71 | return years; 72 | 73 | } 74 | 75 | public double getRating() { 76 | if(this.rating == null) { 77 | return -1; 78 | } else { 79 | return this.rating; 80 | } 81 | } 82 | 83 | 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/Cheer.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | public class Cheer { 4 | 5 | public static void main(String args[]) { 6 | 7 | if (args.length != 3) { 8 | System.err.println("ERROR: provide a b n"); 9 | System.exit(1); 10 | } 11 | 12 | int a = Integer.parseInt(args[0]); 13 | int b = Integer.parseInt(args[1]); 14 | int n = Integer.parseInt(args[2]); 15 | 16 | if (a < 2 || b < 2 || n <= 0) { 17 | System.err.println("ERROR: provide valid inputs"); 18 | System.exit(2); 19 | } 20 | 21 | for (int i = 1; i <= n; i++) { 22 | if (i % (a * b) == 0) { 23 | System.out.println("Go Nebraska!"); 24 | } else if (i % a == 0) { 25 | System.out.println("Go Huskers!"); 26 | } else if (i % b == 0) { 27 | System.out.println("Go Mavs!"); 28 | } else { 29 | System.out.println(i); 30 | 31 | } 32 | } 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/ComputeRoots.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | /** 4 | * Chris Bourke 5 | * 2024-09-06 6 | * 7 | * TODO: write documentation 8 | */ 9 | public class ComputeRoots { 10 | 11 | public static void main(String args[]) { 12 | 13 | double a, b, c; 14 | 15 | if(args.length != 3) { 16 | System.out.printf("ERROR: you did not provide the correct number of command line arguments\n"); 17 | System.exit(1); 18 | } 19 | 20 | a = Double.parseDouble(args[0]); 21 | b = Double.parseDouble(args[1]); 22 | c = Double.parseDouble(args[2]); 23 | 24 | if(a == 0) { 25 | System.out.printf("ERROR: a cannot be zero, you have a linear equation, just solve it!\n"); 26 | System.exit(2); 27 | } 28 | 29 | double x1 = (-b + Math.sqrt( Math.pow(b, 2) - 4*a*c ) ) / (2*a); 30 | double x2 = (-b - Math.sqrt( Math.pow(b, 2) - 4*a*c ) ) / (2*a); 31 | 32 | System.out.printf("%fx^2 + %fx + %f has roots %f and %f\n", a, b, c, x1, x2); 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/Loan.java: -------------------------------------------------------------------------------- 1 | package unl.soc; 2 | 3 | public class Loan { 4 | 5 | /** 6 | * Returns the given value rounded to the nearest 7 | * cent (100th spot). 8 | * 9 | * @param x 10 | * @return 11 | */ 12 | public static double roundToCents(double x) { 13 | return Math.round(x * 100.0) / 100.0; 14 | } 15 | 16 | public static void main(String args[]) { 17 | 18 | double principle = 10000; 19 | int numYears = 5; 20 | double annualRate = 0.05; 21 | 22 | double monthlyRate = annualRate / 12; 23 | int numTerms = numYears * 12; 24 | double monthlyPayment = (monthlyRate * principle) / 25 | (1 - Math.pow(1 + monthlyRate, -numTerms)); 26 | monthlyPayment = roundToCents(monthlyPayment); 27 | 28 | double balance = principle; 29 | for(int month=1; monthhere 9 | * 10 | */ 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int main(int argc, char **argv) { 17 | 18 | const double tolerance = 0.0000001; 19 | 20 | if(argc != 3) { 21 | printf("ERROR: expected 2 numbers\n"); 22 | exit(1); 23 | } 24 | double x = atof(argv[1]); 25 | double y = atof(argv[2]); 26 | 27 | if(x < 0 || y < 0) { 28 | printf("ERROR: both values should be non-negative\n"); 29 | exit(2); 30 | } else if( fabs(x - y) < tolerance) { 31 | printf("agm(%f, %f) = %.20f\n", x, y, x); 32 | exit(0); 33 | } 34 | 35 | double a_mean_prev = x, a_mean_curr; 36 | double g_mean_prev = y, g_mean_curr; 37 | 38 | while( fabs(a_mean_prev - g_mean_prev) > tolerance ) { 39 | a_mean_curr = (a_mean_prev + g_mean_prev) / 2; 40 | g_mean_curr = sqrt(a_mean_prev * g_mean_prev); 41 | a_mean_prev = a_mean_curr; 42 | g_mean_prev = g_mean_curr; 43 | } 44 | printf("agm(%f, %f) = %.20f\n", x, y, a_mean_curr); 45 | 46 | 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/book.h: -------------------------------------------------------------------------------- 1 | 2 | typedef struct { 3 | int year; 4 | int month; 5 | int day; 6 | } Date; 7 | 8 | typedef struct { 9 | //TODO: think about an ID for a person 10 | char *lastName; 11 | char *firstName; 12 | Date dateOfBirth; 13 | } Person; 14 | 15 | typedef struct { 16 | char *isbn; 17 | char *title; 18 | Date publishDate; 19 | Person author; 20 | } Book; 21 | 22 | 23 | /** 24 | * Create a new book instance with the given pieces of data. 25 | * 26 | */ 27 | Book *createBook(const char *title, 28 | const char *authorFirstName, 29 | const char *authorLastName, 30 | int publishYear); 31 | 32 | /** 33 | * Initializes the (preexisting) book provided with the given data 34 | */ 35 | void initBook(Book *b, 36 | const char *title, 37 | const char *authorFirstName, 38 | const char *authorLastName, 39 | int publishYear); 40 | 41 | /** 42 | * Returns a string representation of the given book. 43 | */ 44 | char *bookToString(const Book *b); 45 | 46 | /** 47 | * Loads book data from the given file and returns an array 48 | * of book instances. Communicates the resulting size of the 49 | * array through the pass-by-reference variable numBooks. 50 | */ 51 | Book *loadBookData(const char *fileName, int *numBooks); 52 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/bookDemo.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Demonstration code template. 3 | * 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "book.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | Book *b1 = createBook("The Dispossessed", "Ursula", "le Guin", 1974); 17 | Book *b2 = createBook("Fahrenheit 451", "Ray", "Bradbury", 1953); 18 | 19 | char *s1 = bookToString(b1); 20 | char *s2 = bookToString(b2); 21 | 22 | printf("%s\n", s1); 23 | printf("%s\n", s2); 24 | 25 | int numBooks; 26 | Book *books = loadBookData("./goodreads-abridged.csv", &numBooks); 27 | for(int i=0; i 2 | #include 3 | #include 4 | 5 | #include "my_math.h" 6 | 7 | bool isPrime(int x) { 8 | 9 | if(x<=1) { 10 | return false; 11 | } else if(x == 2) { 12 | return true; 13 | } else if(x % 2 == 0) { 14 | return false; 15 | } else { 16 | for(int d=3; d<=sqrt(x); d+=2) { 17 | if(x % d == 0) { 18 | //x is NOT prime, it is COMPOSITE 19 | return false; 20 | } 21 | } 22 | return true; 23 | } 24 | } 25 | 26 | double agm(double x, double y) { 27 | 28 | double tolerance = 0.00000001; 29 | 30 | if(x < 0 || y < 0) { 31 | //TODO: what do we do when there are errors? 32 | } else if( fabs(x - y) < tolerance) { 33 | return x; 34 | } 35 | 36 | double a_mean_prev = x, a_mean_curr; 37 | double g_mean_prev = y, g_mean_curr; 38 | 39 | while( fabs(a_mean_prev - g_mean_prev) > tolerance ) { 40 | a_mean_curr = (a_mean_prev + g_mean_prev) / 2; 41 | g_mean_curr = sqrt(a_mean_prev * g_mean_prev); 42 | a_mean_prev = a_mean_curr; 43 | g_mean_prev = g_mean_curr; 44 | } 45 | return a_mean_curr; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/my_math.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /** 4 | * Returns true if the given integer x is 5 | * prime, false otherwise. 6 | */ 7 | bool isPrime(int x); 8 | 9 | /** 10 | * Returns the arithmetic-geometricmean of the two given 11 | * values. 12 | */ 13 | double agm(double x, double y); 14 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/my_math_tests.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Demonstration code template. 3 | * 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "my_math.h" 11 | 12 | int main(int argc, char **argv) { 13 | 14 | const double TOLERANCE = 0.0000001; 15 | 16 | double inputX, inputY, actual, expected; 17 | int numPassed = 0; 18 | int numFailed = 0; 19 | 20 | inputX = 24; 21 | inputY = 6; 22 | expected = 13.4581714817; 23 | actual = agm(inputX, inputY); 24 | if( fabs(expected - actual) <= TOLERANCE) { 25 | printf("agm(%f, %f) PASSED!\n", inputX, inputY); 26 | numPassed++; 27 | } else { 28 | printf("agm(%f, %f) FAILED!\n", inputX, inputY); 29 | numFailed++; 30 | } 31 | 32 | inputX = 13; 33 | inputY = 42; 34 | expected = 25.391250597; 35 | actual = agm(inputX, inputY); 36 | if( fabs(expected - actual) <= TOLERANCE) { 37 | printf("agm(%f, %f) PASSED!\n", inputX, inputY); 38 | numPassed++; 39 | } else { 40 | printf("agm(%f, %f) FAILED!\n", inputX, inputY); 41 | numFailed++; 42 | } 43 | 44 | int input = 1332894727; 45 | bool expected_bool = false; 46 | bool actual_bool = isPrime(input); 47 | if( expected_bool == actual_bool) { 48 | printf("isPrime(%d) PASSED!\n", input); 49 | numPassed++; 50 | } else { 51 | printf("isPrime(%d) FAILED!\n", input); 52 | numFailed++; 53 | } 54 | 55 | printf("Num passed: %d\n", numPassed); 56 | printf("Num failed: %d\n", numFailed); 57 | printf("Percent: %f%%\n", (double) numPassed / (numPassed + numFailed) * 100.0); 58 | 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /notes/1248-Fall2024/155H/code/num_primes.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This program computes the number of primes from 2 to n (inclusive). 3 | * 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /** 11 | * Returns true if the given integer x is prime, false if it is 12 | * composite. 13 | */ 14 | bool isPrime(int x); 15 | 16 | int main(int argc, char **argv) { 17 | 18 | int n = 1000000000; 19 | int numPrimes = 0; 20 | 21 | for(int x=2; x<=n; x++) { 22 | //determine if x is prime or not 23 | //for each potential divisor d = 2...n, test if x is divisible by d 24 | if( isPrime(x) ) { 25 | numPrimes++; 26 | } 27 | 28 | } 29 | printf("number of primes 2 to %d is %d\n", n, numPrimes); 30 | 31 | 32 | return 0; 33 | } 34 | 35 | bool isPrime(int x) { 36 | 37 | if(x<=1) { 38 | return false; 39 | } else if(x == 2) { 40 | return true; 41 | } else if(x % 2 == 0) { 42 | return false; 43 | } else { 44 | for(int d=3; d<=sqrt(x); d+=2) { 45 | if(x % d == 0) { 46 | //x is NOT prime, it is COMPOSITE 47 | return false; 48 | } 49 | } 50 | return true; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /notes/dev/scratch.md: -------------------------------------------------------------------------------- 1 | 2 | - Finish with enums 3 | - POSIX error handling 4 | 5 | ## How C does system-level error handling 6 | 7 | * The POSIX standard actually only defines 3 error codes: 8 | * `EDOM`: indicates an error in the *domain* (the input) of a function call; Example: `sqrt(-1)` 9 | * `ERANGE`: indicates an error in the *range* (the output) of a function call; Example: `log(0)` 10 | * `EILSEQ`: illegal byte sequence (rarely seen) 11 | * Each one of these is defined in `errno.h` (error number) 12 | * In the event of one of these errors, a global variable, `errno` is set with one of those three possible values 13 | * Demo 14 | 15 | ## Tool Demo: valgrind 16 | 17 | - valgrind demo 18 | 19 | x ** make demo file 20 | 21 | 22 | MISC: 23 | 24 | Hack 5: 25 | - use lab 5 as a reference/model 26 | - build in a tolerance! 27 | 28 | Course Midterm Evaluation 29 | 30 | ```java 31 | public double getAge() { 32 | Period p = Period.between(this.publishDate, LocalDate.now()); 33 | double y = p.getYears(); 34 | y += p.getDays() / 365.0; 35 | return y; 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /scripts/codepost/assignment.py: -------------------------------------------------------------------------------- 1 | 2 | class Assignment: 3 | """ 4 | A class that models an assignment in Canvas with a 5 | minimum of data 6 | """ 7 | 8 | id = None 9 | name = None 10 | points = None 11 | 12 | def __init__(self, id, 13 | name = None, 14 | points = None): 15 | self.id = id 16 | self.name = name 17 | self.points = points 18 | 19 | def __str__(self): 20 | return f"{self.name} ({self.id}) {self.points:.1f} pts" 21 | 22 | def __repr__(self): 23 | return f"{self.name} ({self.id}) {self.points:.1f} pts" 24 | 25 | def __hash__(self): 26 | return hash(self.id) 27 | 28 | def __eq__(self,other): 29 | """ 30 | Equality and ordering is determined based only on (canvas) id 31 | """ 32 | return self.id == other.id 33 | 34 | def __lt__(self,other): 35 | """ 36 | Equality and ordering is determined based only on (canvas) id 37 | """ 38 | return (self.id < other.id) 39 | -------------------------------------------------------------------------------- /scripts/codepost/canvas.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is the module loads basic data on the course from canvas including 3 | a full roster (including students, TAs, instructors) and assignment 4 | groups. 5 | 6 | """ 7 | 8 | from canvasUtils import getRoster 9 | from canvasUtils import getGroups 10 | 11 | # {"NUID" => Person} 12 | roster = getRoster() 13 | # [Group] 14 | groups = getGroups(roster) 15 | 16 | if __name__ == "__main__": 17 | for nuid,p in roster.items(): 18 | print(p) 19 | -------------------------------------------------------------------------------- /scripts/codepost/codepostGetSubmissions.py: -------------------------------------------------------------------------------- 1 | """ 2 | This script interfaces with codepost.io to pull and archive 3 | all submissions (files) from a particular assignment. It 4 | stores the files in a directory (assignment name)/subdirectory 5 | (student name(s)) structure. 6 | 7 | 8 | """ 9 | import argparse 10 | import codepost 11 | import sys 12 | import os 13 | import pprint 14 | from config import config 15 | from codepostUtils import get_assignment_id 16 | from codepostUtils import save_file 17 | 18 | parser = argparse.ArgumentParser() 19 | 20 | parser.add_argument("codepost_assignment_name", help= 21 | """The codepost.io assignment name (the ID is retrieved 22 | using this name; example: "Hack 1.0") 23 | """) 24 | args = parser.parse_args() 25 | codepost_assignment_name = args.codepost_assignment_name 26 | 27 | codepost_assignment_id = get_assignment_id(codepost_assignment_name) 28 | if codepost_assignment_id is None: 29 | print(f"No assignment \"{codepost_assignment_name}\" found.") 30 | exit(1) 31 | 32 | assignment = codepost.assignment.retrieve(id=codepost_assignment_id) 33 | 34 | 35 | print(f"Retrieving assignment \"{codepost_assignment_name}\" ({codepost_assignment_id})...") 36 | 37 | base_dir_name = f"{codepost_assignment_name.replace(' ', '_')}_{codepost_assignment_id}" 38 | print(f" Creating {base_dir_name}...") 39 | if not os.path.isdir(base_dir_name): 40 | os.makedirs(base_dir_name) 41 | 42 | submissions = assignment.list_submissions() 43 | 44 | for submission in submissions: 45 | stripped = [student[:student.find('@')] for student in submission.students] 46 | sub_dir_name = "_".join(stripped) 47 | #create subdir 48 | dir_name=base_dir_name+"/"+sub_dir_name 49 | print(f" Creating {dir_name}...") 50 | if not os.path.isdir(dir_name): 51 | os.makedirs(dir_name) 52 | for file in submission.files: 53 | file_name = file.name 54 | file_contents = file.code.encode('utf-8').decode('ascii','ignore') 55 | save_file(dir_name, file_name, file_contents) 56 | -------------------------------------------------------------------------------- /scripts/codepost/codepostInitRoster.py: -------------------------------------------------------------------------------- 1 | import codepost 2 | from config import config 3 | from course import course 4 | 5 | codepost.configure_api_key(config.codepost_api_key) 6 | 7 | def updateRoster(): 8 | """ 9 | Initializes or updates the roster in codepost.io based 10 | on the roster in canvas as well as the graders/instructors 11 | specified in config.py. 12 | 13 | `codepostValidateCourse.py` should be run to get a report 14 | of unsynched data before running this script. 15 | """ 16 | graderEmails = [] 17 | studentEmails = [] 18 | instructorEmails = [] 19 | 20 | for nuid,instructor in course.instructors.items(): 21 | if instructor.canvasEmail: 22 | instructorEmails.append(instructor.canvasEmail) 23 | else: 24 | print("WARNING, instructor %s has no email"%instructor) 25 | 26 | for nuid,grader in course.graders.items(): 27 | if grader.canvasEmail: 28 | graderEmails.append(grader.canvasEmail) 29 | else: 30 | print("WARNING, grader %s has no email"%grader) 31 | 32 | for nuid,student in course.students.items(): 33 | if student.canvasEmail: 34 | studentEmails.append(student.canvasEmail) 35 | else: 36 | print("WARNING, student %s has no email"%student) 37 | 38 | codepost.roster.update( 39 | id=config.codepost_course_id, 40 | students=studentEmails, 41 | graders=graderEmails, 42 | superGraders=graderEmails, 43 | courseAdmins=instructorEmails) 44 | 45 | updateRoster() 46 | -------------------------------------------------------------------------------- /scripts/codepost/codepostUtils.py: -------------------------------------------------------------------------------- 1 | 2 | from config import config 3 | import codepost 4 | 5 | codepost.configure_api_key(config.codepost_api_key) 6 | 7 | def get_assignment_id(assignment_name): 8 | """ 9 | Retrieves the codepost id (int) of the given assignment (string) 10 | """ 11 | codepost_course = codepost.course.retrieve(id=config.codepost_course_id) 12 | #generator comprehension 13 | return next( (a.id for a in codepost_course.assignments if a.name == assignment_name), None) 14 | 15 | def save_file(path, name, contents): 16 | file_path = path + "/" + name 17 | f = open(file_path, "w") 18 | f.write(contents) 19 | f.close() 20 | -------------------------------------------------------------------------------- /scripts/codepost/codepostValidateCourse.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pulls all data from codepost.io and canvas and gives a 3 | summary report (on codepost.io course info) and reports 4 | any inconsitencies in the roster 5 | """ 6 | import codepost 7 | from course import course 8 | from config import config 9 | 10 | codepost.configure_api_key(config.codepost_api_key) 11 | 12 | codepost_course = codepost.course.retrieve(id=config.codepost_course_id) 13 | 14 | print("Codepost.io Course: ") 15 | print("Id = " + str(codepost_course.id)) 16 | print("Name = " + codepost_course.name) 17 | print("Period = " + codepost_course.period) 18 | 19 | print("Assignments (" + str(len(codepost_course.assignments)) + "): ") 20 | for a in codepost_course.assignments: 21 | print("%-20s (id=%d)"%(a.name,a.id)) 22 | 23 | roster = codepost.roster.retrieve(id=config.codepost_course_id) 24 | graders = list() 25 | students = list() 26 | 27 | print("Admins (",len(roster.courseAdmins),")") 28 | for a in roster.courseAdmins: 29 | print(" %s"%a) 30 | graders.append(a); 31 | print("Graders (",len(roster.graders),")") 32 | for g in roster.graders: 33 | print(" %s"%g) 34 | graders.append(g); 35 | graders = list(set(graders)) 36 | print("Students (",len(roster.students),")") 37 | for s in roster.students: 38 | print(" %s"%s) 39 | students.append(s); 40 | 41 | # check that codepost graders are in canvas class 42 | print("Checking Instructors...") 43 | for nuid,instructor in course.instructors.items(): 44 | if instructor.canvasEmail not in graders: 45 | print("Instructor %s not in codepost"%instructor) 46 | else: 47 | graders.remove(instructor.canvasEmail) 48 | if graders: 49 | print("Instructors in codepost missing in canvas:") 50 | for g in graders: 51 | print(" %s"%g) 52 | 53 | # check that codepost students are in canvas class 54 | print("Checking Students...") 55 | for nuid,student in course.students.items(): 56 | if student.canvasEmail not in students: 57 | print("Student %s not in codepost"%student) 58 | else: 59 | students.remove(student.canvasEmail) 60 | if student: 61 | print("Students in codepost missing in canvas:") 62 | for s in students: 63 | print(" %s"%s) 64 | -------------------------------------------------------------------------------- /scripts/codepost/config.py: -------------------------------------------------------------------------------- 1 | """ 2 | Master configuration file for all scripts. 3 | 4 | This configuration file will contain sensitive information 5 | (NUIDs, passwords) and should *not* be tracked or committed 6 | to a remote repository (even a private one). If changes 7 | do need to be made, sensitive information should be removed 8 | before hand. 9 | 10 | To help avoid committing sensitive information, you should 11 | set this file to be untracked: 12 | git update-index --assume-unchanged config.py 13 | To track the file again you can use: 14 | git update-index --no-assume-unchanged config.py 15 | 16 | """ 17 | class Config: 18 | 19 | # Canvas API configuration 20 | canvas_url = "https://canvas.unl.edu/api/v1/" 21 | canvas_api_key = "" 22 | canvas_course_id = "" 23 | 24 | # To use canvas groups for assigning grading, set the name 25 | # of the group here. 26 | grading_group_name = "Hack Pairs" 27 | 28 | # codepost.io configuration 29 | codepost_api_key = "" 30 | codepost_course_id = None 31 | 32 | # Course-specific role configurations 33 | # - Instructors are given codepost admin access, but not assigned to grade 34 | # - Graders are given "super grader" access to codepost and assigned to 35 | # grade. An instructor must also be a grader if you want them to be 36 | # assigned grading duties. 37 | instructor_nuids = ["35140602", # Bourke 38 | ] 39 | # All graders' NUIDs 40 | grader_nuids = ["35140602", # Bourke 41 | ] 42 | 43 | config = Config() 44 | -------------------------------------------------------------------------------- /scripts/codepost/group.py: -------------------------------------------------------------------------------- 1 | from operator import attrgetter 2 | 3 | class Group: 4 | """ 5 | A group may consist of one or more students and has a 6 | direct connection to a group on Canvas in which students 7 | are either assigned or self select into groups through 8 | the "people" page. In the case that students are not 9 | assigned to a group, a Group object is still created for 10 | them as a "group of one". 11 | 12 | Codepost does not represent groups directly, however each 13 | submission may have more than one student assicated with it. 14 | """ 15 | 16 | canvasGroupId = None 17 | canvasGroupName = None 18 | # This is an array of Persons 19 | members = [] 20 | 21 | def __init__(self, canvasGroupId = None, 22 | canvasGroupName = None): 23 | self.canvasGroupId = canvasGroupId 24 | self.canvasGroupName = canvasGroupName 25 | 26 | def __str__(self): 27 | s = "" 28 | if len(self.members) > 1: 29 | s = " %-20s (%s) \n"%(self.canvasGroupName,self.canvasGroupId) 30 | for member in self.members: 31 | s += f" {member}\n" 32 | else: 33 | s += f" {self.members[0]}\n" 34 | return s 35 | 36 | def __eq__(self,other): 37 | return self.members == other.members 38 | 39 | def __lt__(self,other): 40 | return (self.members[0].name < other.members[0].name) 41 | 42 | def addMembers(self, members): 43 | self.members = sorted(members, key=attrgetter('name')) 44 | -------------------------------------------------------------------------------- /scripts/codepost/person.py: -------------------------------------------------------------------------------- 1 | 2 | class Person: 3 | """ 4 | A class that models a person which includes students, 5 | graders, instructors, etc. 6 | 7 | Each person is uniquely identified by their NUID and 8 | is expected to have credentials Canvas. 9 | 10 | For students, their email is usually their huskers email. 11 | 12 | Separate name elements (first, last) may not be available in 13 | Canvas and instead only a 'display' name may be available due 14 | to students being able to set a 'preferred name' in the 15 | registration system. Generally this should be sufficient 16 | for lexicographic ordering. 17 | """ 18 | 19 | nuid = None 20 | name = None 21 | canvasId = None 22 | canvasLogin = None 23 | canvasEmail = None 24 | group = None 25 | 26 | def __init__(self, nuid, 27 | name = None, 28 | canvasId = None, 29 | canvasLogin = None, 30 | canvasEmail = None): 31 | self.nuid = nuid 32 | self.name = name 33 | self.canvasId = canvasId 34 | self.canvasLogin = canvasLogin 35 | self.canvasEmail = canvasEmail 36 | 37 | def __str__(self): 38 | return "%-30s (%s) %s"%(self.name,self.nuid,self.canvasEmail) 39 | 40 | def __hash__(self): 41 | return hash(self.nuid) 42 | 43 | def __eq__(self,other): 44 | """ 45 | Equality and ordering is determined based only on NUID 46 | """ 47 | return self.nuid == other.nuid 48 | 49 | def __lt__(self,other): 50 | """ 51 | Equality and ordering is determined based only on NUID 52 | """ 53 | return (self.nuid < other.nuid) 54 | 55 | def toCsv(self): 56 | return "%s,%s,%s,%s,%s\n"%(self.nuid,self.name.replace(", ", ","),self.canvasId,self.canvasEmail,self.canvasLogin) 57 | -------------------------------------------------------------------------------- /scripts/codepost/readme.md: -------------------------------------------------------------------------------- 1 | 2 | This is a collection of python scripts used to pull data from 3 | Canvas and interact with codepost.io to assign graders, transfer 4 | grades, etc. 5 | 6 | # Setup 7 | 8 | ## Edit the `config.py` file 9 | 10 | 1. Enter your Canvas API key and course ID: 11 | - Click your account in the left navigation, then settings 12 | - Click "New Access Token" 13 | - Copy that to the `canvasApiKey` variable 14 | - Copy your Canvas course ID into the `canvasCourseId` variable 15 | This can be found from the URL for your course, for example 16 | if your course's URL is https://canvas.unl.edu/courses/12345 17 | then your course ID is 12345 18 | 19 | 2. Enter your codepost.io API key and course ID: 20 | - Click on user settings (gear icon, top right) 21 | - Copy your API token to the `codePostApiKey` variable 22 | - Copy the relevant Course ID to the `codePostCourseId` variable 23 | 24 | ## Running 25 | 26 | Each script can be run using `python3`; example: `python3 course.py`. 27 | However, only 4 scripts are intended to be run directly: 28 | 29 | - `course.py` will load all data from Canvas and UDB and print a 30 | roster. It will also print a raw list of email addresses if you 31 | need them for (say) Piazza or other communication tools. 32 | - `codepostInitRoster.py` - Initializes (or updates) the roster 33 | in codepost using canvas (enrolled students and TAs) and the 34 | roles defined in `config.py` 35 | - `codepostValidateCourseInfo.py` - this will list relevant data including 36 | necessary assignment IDs and roster from codepost and canvas. 37 | - `codepostAssignGraders.py` - a script that (randomly) assigns 38 | students' assignments to graders... 39 | -------------------------------------------------------------------------------- /scripts/php/mail.list: -------------------------------------------------------------------------------- 1 | cbourke (Christopher Bourke) 2 | ssamal (Ashok Samal) 3 | jstudent (John Student) 4 | -------------------------------------------------------------------------------- /scripts/php/makeTeams.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php 2 | -------------------------------------------------------------------------------- /slides/images/ascii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/images/ascii.png -------------------------------------------------------------------------------- /slides/images/triangleEquilateral.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/images/triangleEquilateral.png -------------------------------------------------------------------------------- /slides/images/triangleIsosceles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/images/triangleIsosceles.png -------------------------------------------------------------------------------- /slides/images/triangleScalene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/images/triangleScalene.png -------------------------------------------------------------------------------- /slides/lecture-arrays-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-arrays-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-arrays.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-arrays.pdf -------------------------------------------------------------------------------- /slides/lecture-basics-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-basics-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-basics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-basics.pdf -------------------------------------------------------------------------------- /slides/lecture-conditionals-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-conditionals-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-conditionals.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-conditionals.pdf -------------------------------------------------------------------------------- /slides/lecture-debugging-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-debugging-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-debugging.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-debugging.pdf -------------------------------------------------------------------------------- /slides/lecture-errorHandling-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-errorHandling-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-errorHandling.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-errorHandling.pdf -------------------------------------------------------------------------------- /slides/lecture-fileIO-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-fileIO-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-fileIO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-fileIO.pdf -------------------------------------------------------------------------------- /slides/lecture-functions-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-functions-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-functions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-functions.pdf -------------------------------------------------------------------------------- /slides/lecture-loops-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-loops-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-loops.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-loops.pdf -------------------------------------------------------------------------------- /slides/lecture-recursion-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-recursion-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-recursion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-recursion.pdf -------------------------------------------------------------------------------- /slides/lecture-searchingSorting-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-searchingSorting-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-searchingSorting.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-searchingSorting.pdf -------------------------------------------------------------------------------- /slides/lecture-strings-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-strings-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-strings.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-strings.pdf -------------------------------------------------------------------------------- /slides/lecture-structures-HandoutNoNotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-structures-HandoutNoNotes.pdf -------------------------------------------------------------------------------- /slides/lecture-structures.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbourke/ComputerScienceI/2a53d4a31c51a22880ac4b026144a2d829b7afbf/slides/lecture-structures.pdf --------------------------------------------------------------------------------