update theme and csci-1100 hw8
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
# =====================================================================================
|
||||
# It's recommended to use Alternate Theme Config to configure FixIt
|
||||
# Modifying this file may result in merge conflict
|
||||
# There are currently some restrictions to what a theme component can configure:
|
||||
# params, menu, outputformats and mediatypes
|
||||
# =====================================================================================
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
@@ -14,6 +16,13 @@ title = "FlareBlog"
|
||||
baseURL = "https://www.jamesflare.com/"
|
||||
# theme list
|
||||
theme = ["FixIt", "component-projects"]
|
||||
defaultContentLanguage = "en"
|
||||
# language code ["en", "zh-CN", "fr", "pl", ...]
|
||||
languageCode = "en"
|
||||
# language name ["English", "简体中文", "Français", "Polski", ...]
|
||||
languageName = "English"
|
||||
# whether to include Chinese/Japanese/Korean
|
||||
hasCJKLanguage = true
|
||||
# default amount of posts in each pages
|
||||
paginate = 12
|
||||
# copyright description used only for seo schema
|
||||
@@ -25,9 +34,6 @@ enableGitInfo = false
|
||||
# whether to use emoji code
|
||||
enableEmoji = true
|
||||
|
||||
defaultContentLanguage = "en"
|
||||
defaultContentLanguageInSubdir = true
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
# Related content Configuration
|
||||
# See: https://gohugo.io/content-management/related/
|
||||
@@ -94,18 +100,41 @@ defaultContentLanguageInSubdir = true
|
||||
########## necessary configurations ##########
|
||||
guessSyntax = true
|
||||
# Goldmark is from Hugo 0.60 the default library used for Markdown
|
||||
# https://gohugo.io/getting-started/configuration-markup/#goldmark
|
||||
[markup.goldmark]
|
||||
duplicateResourceFiles = false
|
||||
[markup.goldmark.extensions]
|
||||
definitionList = true
|
||||
footnote = true
|
||||
linkify = true
|
||||
strikethrough = true
|
||||
linkifyProtocol = 'https'
|
||||
strikethrough = false
|
||||
table = true
|
||||
taskList = true
|
||||
typographer = true
|
||||
# https://gohugo.io/getting-started/configuration-markup/#extras
|
||||
[markup.goldmark.extensions.extras]
|
||||
[markup.goldmark.extensions.extras.delete]
|
||||
enable = true
|
||||
[markup.goldmark.extensions.extras.insert]
|
||||
enable = true
|
||||
[markup.goldmark.extensions.extras.mark]
|
||||
enable = true
|
||||
[markup.goldmark.extensions.extras.subscript]
|
||||
enable = true
|
||||
[markup.goldmark.extensions.extras.superscript]
|
||||
enable = true
|
||||
# TODO passthrough refactor https://gohugo.io/getting-started/configuration-markup/#parserattributeblock
|
||||
# TODO hugo 0.122.0 https://gohugo.io/content-management/mathematics/
|
||||
[markup.goldmark.parser]
|
||||
[markup.goldmark.parser.attribute]
|
||||
block = true
|
||||
title = true
|
||||
[markup.goldmark.renderer]
|
||||
hardWraps = false
|
||||
# whether to use HTML tags directly in the document
|
||||
unsafe = true
|
||||
xhtml = false
|
||||
# Table Of Contents settings
|
||||
[markup.tableOfContents]
|
||||
ordered = false
|
||||
@@ -161,11 +190,6 @@ defaultContentLanguageInSubdir = true
|
||||
# -------------------------------------------------------------------------------------
|
||||
|
||||
[outputFormats]
|
||||
# Options to make output .md files
|
||||
[outputFormats.MarkDown]
|
||||
mediaType = "text/markdown"
|
||||
isPlainText = true
|
||||
isHTML = false
|
||||
# FixIt 0.3.0 | NEW Options to make output /archives/index.html file
|
||||
[outputFormats.archives]
|
||||
path = "archives"
|
||||
@@ -174,6 +198,7 @@ defaultContentLanguageInSubdir = true
|
||||
isPlainText = false
|
||||
isHTML = true
|
||||
permalinkable = true
|
||||
notAlternative = true
|
||||
# FixIt 0.3.0 | NEW Options to make output /offline/index.html file
|
||||
[outputFormats.offline]
|
||||
path = "offline"
|
||||
@@ -182,18 +207,29 @@ defaultContentLanguageInSubdir = true
|
||||
isPlainText = false
|
||||
isHTML = true
|
||||
permalinkable = true
|
||||
notAlternative = true
|
||||
# FixIt 0.3.0 | NEW Options to make output readme.md file
|
||||
[outputFormats.README]
|
||||
[outputFormats.readme]
|
||||
baseName = "readme"
|
||||
mediaType = "text/markdown"
|
||||
isPlainText = true
|
||||
isHTML = false
|
||||
notAlternative = true
|
||||
# FixIt 0.3.0 | CHANGED Options to make output baidu_urls.txt file
|
||||
[outputFormats.baidu_urls]
|
||||
baseName = "baidu_urls"
|
||||
mediaType = "text/plain"
|
||||
isPlainText = true
|
||||
isHTML = false
|
||||
notAlternative = true
|
||||
# FixIt 0.3.10 | NEW Options to make output search.json file
|
||||
[outputFormats.search]
|
||||
baseName = "search"
|
||||
mediaType = "application/json"
|
||||
rel = "search"
|
||||
isPlainText = true
|
||||
isHTML = false
|
||||
permalinkable = true
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
# Customizing Output Formats
|
||||
@@ -207,11 +243,11 @@ defaultContentLanguageInSubdir = true
|
||||
# taxonomy: ["HTML", "RSS"]
|
||||
# term: ["HTML", "RSS"]
|
||||
[outputs]
|
||||
home = ["HTML", "RSS", "JSON", "archives"]
|
||||
page = ["HTML", "MarkDown"]
|
||||
section = ["HTML", "RSS"]
|
||||
taxonomy = ["HTML"]
|
||||
term = ["HTML", "RSS"]
|
||||
home = ["html", "rss", "archives", "offline", "search"]
|
||||
page = ["html", "markdown"]
|
||||
section = ["html", "rss"]
|
||||
taxonomy = ["html"]
|
||||
term = ["html", "rss"]
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
# Taxonomies Configuration
|
||||
@@ -248,8 +284,6 @@ defaultContentLanguageInSubdir = true
|
||||
enablePWA = false
|
||||
# FixIt 0.2.14 | NEW whether to add external Icon for external links automatically
|
||||
externalIcon = false
|
||||
# FixIt 0.3.0 | NEW whether to reverse the order of the navigation menu
|
||||
navigationReverse = false
|
||||
# FixIt 0.3.0 | NEW whether to add site title to the title of every page
|
||||
# remember to set up your site title in `hugo.toml` (e.g. title = "title")
|
||||
withSiteTitle = true
|
||||
@@ -361,18 +395,22 @@ defaultContentLanguageInSubdir = true
|
||||
sticky = false
|
||||
showHome = false
|
||||
|
||||
# FixIt 0.3.10 | NEW Post navigation config
|
||||
[params.navigation]
|
||||
# whether to show the post navigation in section pages scope
|
||||
inSection = false
|
||||
# whether to reverse the next/previous post navigation order
|
||||
reverse = false
|
||||
|
||||
# Footer config
|
||||
[params.footer]
|
||||
enable = true
|
||||
# FixIt 0.2.17 | CHANGED Custom content (HTML format is supported)
|
||||
# For advanced use, see parameter `params.customFilePath.footer`
|
||||
custom = ""
|
||||
# whether to show copyright info
|
||||
copyright = true
|
||||
# whether to show the author
|
||||
author = true
|
||||
# Site creation year
|
||||
since = "2022"
|
||||
since = ""
|
||||
# FixIt 0.2.12 | NEW Public network security only in China (HTML format is supported)
|
||||
gov = ""
|
||||
# ICP info only in China (HTML format is supported)
|
||||
@@ -412,8 +450,12 @@ defaultContentLanguageInSubdir = true
|
||||
paginate = 20
|
||||
# date format (month and day)
|
||||
dateFormat = "01-02"
|
||||
# amount of RSS pages
|
||||
rss = 30
|
||||
# FixIt 0.3.10 | NEW Section feed config for RSS, Atom and JSON feed.
|
||||
[params.section.feed]
|
||||
# The number of posts to include in the feed. If set to -1, all posts.
|
||||
limit = -1
|
||||
# whether to show the full text content in feed.
|
||||
fullText = false
|
||||
# FixIt 0.2.13 | NEW recently updated pages config
|
||||
# TODO refactor to support archives, section, taxonomy and term
|
||||
[params.section.recentlyUpdated]
|
||||
@@ -422,14 +464,18 @@ defaultContentLanguageInSubdir = true
|
||||
days = 30
|
||||
maxCount = 10
|
||||
|
||||
# List (category or tag) page config
|
||||
# Term list (category or tag) page config
|
||||
[params.list]
|
||||
# special amount of posts in each list page
|
||||
paginate = 20
|
||||
# date format (month and day)
|
||||
dateFormat = "01-02"
|
||||
# amount of RSS pages
|
||||
rss = 10
|
||||
# FixIt 0.3.10 | NEW Term list feed config for RSS, Atom and JSON feed.
|
||||
[params.list.feed]
|
||||
# The number of posts to include in the feed. If set to -1, all posts.
|
||||
limit = -1
|
||||
# whether to show the full text content in feed.
|
||||
fullText = false
|
||||
|
||||
# FixIt 0.2.17 | NEW TagCloud config for tags page
|
||||
[params.tagcloud]
|
||||
@@ -441,8 +487,6 @@ defaultContentLanguageInSubdir = true
|
||||
|
||||
# Home page config
|
||||
[params.home]
|
||||
# amount of RSS pages
|
||||
rss = 10
|
||||
# Home page profile
|
||||
[params.home.profile]
|
||||
enable = true
|
||||
@@ -557,6 +601,14 @@ defaultContentLanguageInSubdir = true
|
||||
Phone = ""
|
||||
Email = "jamesflare1212@gmail.com"
|
||||
RSS = true
|
||||
# custom social links like the following
|
||||
# [params.social.twitter]
|
||||
# id = "lruihao"
|
||||
# weight = 3
|
||||
# prefix = "https://twitter.com/"
|
||||
# Title = "Twitter"
|
||||
# [social.twitter.icon]
|
||||
# class = "fa-brands fa-x-twitter fa-fw"
|
||||
|
||||
# Page config
|
||||
[params.page]
|
||||
@@ -636,7 +688,8 @@ defaultContentLanguageInSubdir = true
|
||||
closeComment = false
|
||||
# FixIt 0.3.0 | NEW page heading config
|
||||
[params.page.heading]
|
||||
# used with `markup.tableOfContents.ordered` parameter
|
||||
# FixIt 0.3.3 | NEW whether to capitalize automatic text of headings
|
||||
capitalize = false
|
||||
[params.page.heading.number]
|
||||
# whether to enable auto heading numbering
|
||||
enable = false
|
||||
@@ -664,6 +717,8 @@ defaultContentLanguageInSubdir = true
|
||||
mhchem = true
|
||||
# Code config
|
||||
[params.page.code]
|
||||
# FixIt 0.3.9 | NEW whether to enable the code wrapper
|
||||
enable = true
|
||||
# whether to show the copy button of the code block
|
||||
copy = true
|
||||
# FixIt 0.2.13 | NEW whether to show the edit button of the code block
|
||||
@@ -815,6 +870,7 @@ defaultContentLanguageInSubdir = true
|
||||
texRenderer = false # FixIt 0.2.16 | NEW
|
||||
search = false # FixIt 0.2.16 | NEW
|
||||
recaptchaV3Key = "" # FixIt 0.2.16 | NEW
|
||||
turnstileKey = "" # FixIt 0.3.8 | NEW
|
||||
reaction = false # FixIt 0.2.18 | NEW
|
||||
# Facebook comment config (https://developers.facebook.com/docs/plugins/comments)
|
||||
[params.page.comment.facebook]
|
||||
@@ -941,11 +997,16 @@ defaultContentLanguageInSubdir = true
|
||||
# FixIt 0.2.13 | NEW watermark's fontFamily
|
||||
fontFamily = "inherit"
|
||||
|
||||
# FixIt 0.2.12 | NEW Busuanzi count
|
||||
[params.ibruce]
|
||||
# FixIt 0.3.10 | NEW Busuanzi count
|
||||
[params.busuanzi]
|
||||
# whether to enable busuanzi count
|
||||
enable = false
|
||||
# Enable in post meta
|
||||
enablePost = false
|
||||
# busuanzi count core script source. Default is https://vercount.one/js
|
||||
source = "https://vercount.one/js"
|
||||
# whether to show the site views
|
||||
siteViews = true
|
||||
# whether to show the page views
|
||||
pageViews = true
|
||||
|
||||
# Site verification code config for Google/Bing/Yandex/Pinterest/Baidu/360/Sogou
|
||||
[params.verification]
|
||||
@@ -1046,22 +1107,17 @@ defaultContentLanguageInSubdir = true
|
||||
# "corner-indicator", "fill-left", "flash", "flat-top", "loading-bar", "mac-osx", "material", "minimal"]
|
||||
theme = "minimal"
|
||||
|
||||
# FixIt 0.2.17 | NEW Define custom file paths
|
||||
# Create your custom files in site directory `layouts/partials/custom` and uncomment needed files below
|
||||
[params.customFilePath]
|
||||
# aside = "custom/aside.html"
|
||||
# profile = "custom/profile.html"
|
||||
# footer = "custom/footer.html"
|
||||
# FixIt 0.3.10 | NEW Global Feed config for RSS, Atom and JSON feed.
|
||||
[params.feed]
|
||||
# The number of posts to include in the feed. If set to -1, all posts.
|
||||
limit = 10
|
||||
# whether to show the full text content in feed.
|
||||
fullText = true
|
||||
|
||||
# FixIt 0.2.15 | NEW Developer options
|
||||
# Select the scope named `public_repo` to generate personal access token,
|
||||
# Configure with environment variable `HUGO_PARAMS_GHTOKEN=xxx`, see https://gohugo.io/functions/os/getenv/#examples
|
||||
[params.dev]
|
||||
enable = false
|
||||
# Check for updates
|
||||
c4u = false
|
||||
# Please do not expose to public!
|
||||
githubToken = ""
|
||||
# Mobile Devtools config
|
||||
[params.dev.mDevtools]
|
||||
enable = false
|
||||
# "vConsole", "eruda" supported
|
||||
type = "vConsole"
|
||||
139
content/en/posts/csci-1100/exam-4-overview/index.md
Normal file
139
content/en/posts/csci-1100/exam-4-overview/index.md
Normal file
@@ -0,0 +1,139 @@
|
||||
---
|
||||
title: CSCI 1100 - Test 4 Overview and Practice Questions
|
||||
subtitle:
|
||||
date: 2024-04-26T03:54:07-04:00
|
||||
slug: csci-1100-exam-4overview
|
||||
draft: true
|
||||
author:
|
||||
name: James
|
||||
link: https://www.jamesflare.com
|
||||
email:
|
||||
avatar: /site-logo.avif
|
||||
description:
|
||||
keywords: ["CSCI 1100","Computer Science","Test 4","Practice Questions", "Python"]
|
||||
license:
|
||||
comment: true
|
||||
weight: 0
|
||||
tags:
|
||||
- CSCI 1100
|
||||
- Exam
|
||||
- RPI
|
||||
- Python
|
||||
- Programming
|
||||
categories:
|
||||
- Programming
|
||||
collections:
|
||||
- CSCI 1100
|
||||
hiddenFromHomePage: false
|
||||
hiddenFromSearch: false
|
||||
hiddenFromRss: false
|
||||
hiddenFromRelated: false
|
||||
summary:
|
||||
resources:
|
||||
- name: featured-image
|
||||
src: featured-image.jpg
|
||||
- name: featured-image-preview
|
||||
src: featured-image-preview.jpg
|
||||
toc: true
|
||||
math: false
|
||||
lightgallery: false
|
||||
password:
|
||||
message:
|
||||
repost:
|
||||
enable: false
|
||||
url:
|
||||
|
||||
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
|
||||
---
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Overview
|
||||
|
||||
- The final exam will be held Monday, April 29, 2024 from 6:30 pm - 8:30 pm. Note that this will be a two-hour exam.
|
||||
- Most students will take the exam from 6:30 pm - 8:30 pm (120 minutes). The exam will be given in 308 DCC for most students.
|
||||
- Students who provided an accommodation letter indicating the need for extra time or a quiet location will be given extra time beyond the 2 hour base. Shianne Hulbert will send you a reminder for your time and location. Use whatever information she sends you. It overrides any assignments given you on Submitty. If you show up at your Submitty location or time, you will be allowed to take the exam, but you will lose the accommodations.
|
||||
- Students MUST:
|
||||
- Go to their assigned rooms.
|
||||
- Bring their IDs to the exam.
|
||||
- Sit in the correct room/section.
|
||||
- Put away all calculators, phones, etc. and take off/out all headphones and earbuds
|
||||
|
||||
Failing to do one of these may result in a 20 point penalty on the exam score. Failure to do all can cost up to 80 points.
|
||||
|
||||
- During the exam, if you are doubtful/confused about a problem, simply state your assumptions and/or interpretation as comments right before your code and write your solution accordingly.
|
||||
- Exam coverage is the entire semester, except for the following:
|
||||
- JSON data format
|
||||
- Images
|
||||
|
||||
You do not need to know the intricacies of tkinter GUI formatting, but you should understand the GUI code structure we outlined (Lecture Notes and Class Code), be able to trace through event driven code and write small methods that are invoked by the GUI. Consider the lecture exercises for Lecture 22 and the modifications you made to the BallDraw class during Lab 11 for practice.
|
||||
|
||||
- Please review lecture notes, class exercises, labs, homework, practice programs, and tests, working through problems on your own before looking at the solutions.
|
||||
- You are expected to abide by the following Honor code when appearing for this exam:
|
||||
|
||||
"On my honor, I have neither given nor received any aid on this exam."
|
||||
|
||||
- As part of our regular class time on Monday April 22, we will answer questions about the course material, so bring your questions!
|
||||
- There are often study events held on campus, for example UPE often holds tutoring sessions. I do not know of any specific events right now, but we will post anything we learn to the Submitty discussion forum. Please monitor the channel if you are looking for help.
|
||||
- What follows are a few additional practice problems. These are by no means comprehensive, so rework problems from earlier in the semester. All the material from tests 1, 2, and 3 are also fair game. This is a comprehensive final exam.
|
||||
- We have separately provided Spring 2017's final exam.
|
||||
|
||||
## Questions
|
||||
|
||||
### Merge Without Extend
|
||||
|
||||
> Write a version of `merge` that does all of the work inside the `while` loop and does not use the `extend`.
|
||||
|
||||
### Three Way Merge
|
||||
|
||||
> Using what you learned from writing the solution to the previous problem, write a function to merge three sorted lists. For example:
|
||||
>
|
||||
> ```python
|
||||
> print(three_way_merge([2, 3, 4, 4, 4, 5], [1, 5, 6, 9], [6, 9, 13]))
|
||||
> ```
|
||||
>
|
||||
> Should output:
|
||||
>
|
||||
> ```
|
||||
> [1, 2, 3, 4, 4, 4, 5, 5, 6, 6, 9, 9, 13]
|
||||
> ```
|
||||
|
||||
### Score Range Counts
|
||||
|
||||
> Given a list of test scores, where the maximum score is 100, write code that prints the number of scores that are in the range 0-9, 10-19, 20-29, ... 80-89, 90-100. Try to think of several ways to do this. Outline test cases you should add.
|
||||
>
|
||||
> For example, given the list of scores:
|
||||
>
|
||||
> ```python
|
||||
> scores = [12, 90, 100, 52, 56, 76, 92, 83, 39, 77, 73, 70, 80]
|
||||
> ```
|
||||
>
|
||||
> The output should be something like:
|
||||
>
|
||||
> ```
|
||||
> [0,9]: 0
|
||||
> [10,19]: 1
|
||||
> [20,29]: 0
|
||||
> [30,39]: 1
|
||||
> [40,49]: 0
|
||||
> [50,59]: 2
|
||||
> [60,69]: 0
|
||||
> [70,79]: 4
|
||||
> [80,89]: 2
|
||||
> [90,100]: 3
|
||||
> ```
|
||||
|
||||
### Closest 10 Values
|
||||
|
||||
> Given a list of floating point values containing at least 10 values, how do you find the 10 values that are closest to each other? In other words, find the smallest interval that contains 10 values. By definition the minimum and maximum of this interval will be values in the original list. These two values and the 8 in between constitute the desired answer. This is a bit of a challenging variation on earlier problems from the semester. Start by outlining your approach. Outline the test cases. For example, given the list:
|
||||
>
|
||||
> ```python
|
||||
> values = [1.2, 5.3, 1.1, 8.7, 9.5, 11.1, 2.5, 3, 12.2, 8.8, 6.9, 7.4,
|
||||
> 0.1, 7.7, 9.3, 10.1, 17, 1.1]
|
||||
> ```
|
||||
>
|
||||
> The list of the closest 10 should be:
|
||||
>
|
||||
> ```
|
||||
> [6.9, 7.4, 7.7, 8.7, 8.8, 9.3, 9.5, 10.1, 11.1, 12.2]
|
||||
> ```
|
||||
BIN
content/en/posts/csci-1100/hw-8/HW8.zip
Normal file
BIN
content/en/posts/csci-1100/hw-8/HW8.zip
Normal file
Binary file not shown.
154
content/en/posts/csci-1100/hw-8/index.md
Normal file
154
content/en/posts/csci-1100/hw-8/index.md
Normal file
@@ -0,0 +1,154 @@
|
||||
---
|
||||
title: "CSCI 1100 - Homework 8 - Bears, Berries, and Tourists Redux - Classes"
|
||||
subtitle:
|
||||
date: 2024-09-13T15:36:47-04:00
|
||||
slug: csci-1100-hw-8
|
||||
draft: false
|
||||
author:
|
||||
name: James
|
||||
link: https://www.jamesflare.com
|
||||
email:
|
||||
avatar: /site-logo.avif
|
||||
description: This blog post introduces a Python programming assignment for analyzing and comparing text documents using natural language processing techniques, such as calculating word length, distinct word ratios, and Jaccard similarity between word sets and pairs.
|
||||
keywords: ["Python", "Classes", "Simulation", "Homework 8"]
|
||||
license:
|
||||
comment: true
|
||||
weight: 0
|
||||
tags:
|
||||
- CSCI 1100
|
||||
- Homework
|
||||
- RPI
|
||||
- Python
|
||||
- Programming
|
||||
categories:
|
||||
- Programming
|
||||
collections:
|
||||
- CSCI 1100
|
||||
hiddenFromHomePage: false
|
||||
hiddenFromSearch: false
|
||||
hiddenFromRss: false
|
||||
hiddenFromRelated: false
|
||||
summary: This blog post provides a detailed guide on completing Homework 8 for CSCI 1100, focusing on simulating a berry field with bears and tourists using Python classes. It covers the creation of BerryField, Bear, and Tourist classes, and instructions for submitting the assignment.
|
||||
resources:
|
||||
- name: featured-image
|
||||
src: featured-image.jpg
|
||||
- name: featured-image-preview
|
||||
src: featured-image-preview.jpg
|
||||
toc: true
|
||||
math: true
|
||||
lightgallery: false
|
||||
password:
|
||||
message:
|
||||
repost:
|
||||
enable: false
|
||||
url:
|
||||
|
||||
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
|
||||
---
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Overview
|
||||
|
||||
This homework is worth 100 points toward your overall homework grade and is due Thursday, April 18, 2024, at 11:59:59 pm. It has three parts. The first two are not worth many points and may end up being worth 0. They are mainly there to give you information to help you debug your solution. Please download `hw8_files.zip` and unzip it into the directory for your HW8. You will find data files and sample outputs for each of the parts.
|
||||
|
||||
The goal of this assignment is to work with classes. You will be asked to write a simulation engine and use classes to encapsulate data and functionality. You will have a lot of design choices to make. While we have done simulations before, this one will be more complex. It is especially important that you start slowly, build a program that works for simple cases, test it, and then add more complexity. We will provide test cases of increasing difficulty. Make sure you develop slowly and test thoroughly.
|
||||
|
||||
## Submission Instructions
|
||||
|
||||
In this homework, for the first time, you will be submitting multiple files to Submitty that together comprise a single program. Please follow these instructions carefully.
|
||||
|
||||
Each of Part 1, Part 2, and Part 3 will require you to write a main program: `hw8_part1.py`, `hw8_part2.py`, and `hw8_part3.py`, respectively. You must also submit three modules per part in addition to this main file, each of which encapsulates a class. The first is a file called `BerryField.py` that contains your BerryField class, a file called `Bear.py` that contains your Bear class, and a file called `Tourist.py` that contains your Tourist class.
|
||||
|
||||
As always, make sure you follow the program structure guidelines. You will be graded on good program structure as well as program correctness.
|
||||
|
||||
Remember as well that we will be continuing to test homeworks for similarity. So, follow our guidelines for the acceptable levels of collaboration. You can download the guidelines from the resources section in the Course Materials if you need a refresher. We take this very seriously and will not hesitate to impose penalties when warranted.
|
||||
|
||||
## Getting Started
|
||||
|
||||
You will need to write at least three classes for this assignment corresponding to a BerryField, a Bear, and a Tourist. We are going to give you a lot of freedom in how you organize these three classes, but each class must have at least an initializer and a string method. Additional methods are up to you. Each of the classes is described below.
|
||||
|
||||
### BerryField
|
||||
|
||||
The BerryField class must maintain and manage the location of berries as a square Row X Column grid with (0,0) being the upper left corner and (N-1, N-1) being the lower right corner. Each space holds 0-10 berry units.
|
||||
|
||||
- The initializer class must, minimally, be able to take in a grid of values (think of our Sudoku lab) and use it to create a berry field with the values contained in the grid.
|
||||
- The string function must, minimally, be able to generate a string of the current state of the berry patch. Each block in the grid must be formatted with the `"{:>4}"` format specifier. If there is a bear at the location, the grid should have a `"B"`; if there is a tourist, the grid should have a `"T"`; and if there is both a bear and a tourist, the grid should have an `"X"`. If there is neither a bear nor a tourist, it should have the number of berries at the location.
|
||||
- Berries grow. The BerryField class must provide a way to grow the berry field. When the berries grow, any location with a value `1 <= number of berries < 10` will gain an extra berry.
|
||||
- Berries also spread. Any location with no berries that is adjacent to a location with 10 berries will get 1 berry during the grow operation.
|
||||
|
||||
### Bear
|
||||
|
||||
Each Bear has a location and a direction in which they are walking. Bears are also very hungry. In your program, you must manage 2 lists of bears. The first list contains those bears that are currently walking in the field. The second is a queue of bears waiting to enter the field.
|
||||
|
||||
- The initializer class must, minimally, be able to take in a row and column location and a direction of travel.
|
||||
- The string function must, minimally, be able to print out the location and direction of travel for the bear and if the bear is asleep.
|
||||
- Bears can walk `North (N)`, `South (S)`, `East (E)`, `West (W)`, `NorthEast (NE)`, `NorthWest (NW)`, `SouthEast (SE)`, or `SouthWest (SW)`. Once a bear starts walking in a direction, it never turns.
|
||||
- Bears are always hungry. Every turn, unless there is a tourist on the same spot, the bear eats all the berries available on the space and then moves in its current direction to the next space. This continues during the current turn until the bear eats 30 berries or runs into a tourist.
|
||||
- For the special case of a bear and a tourist being in the same place during a turn, the bear does not eat any berries, but the tourist mysteriously disappears and the bear falls asleep for three turns.
|
||||
- Once a bear reaches the boundary of the field (its row or column becomes -1 or N), it is no longer walking in the field and need not be considered any longer.
|
||||
|
||||
### Tourist
|
||||
|
||||
Each Tourist has a location. Just like with bears, you must maintain a list of tourists currently in the field and a queue of tourists waiting to enter the field.
|
||||
|
||||
- The initializer class must, minimally, be able to take in a row and column location.
|
||||
- Tourists see a bear if the bear is within 4 of their current position.
|
||||
- The string function must, minimally, be able to print out the location of the tourist and how many turns have passed since they have seen a bear.
|
||||
- Tourists stand and watch. They do not move, but they will leave the field if:
|
||||
1. Three turns pass without them seeing a bear; they get bored and go home.
|
||||
2. They can see three bears at the same time; they get scared and go home.
|
||||
3. A bear runs into them; they mysteriously disappear and can no longer be found in the field.
|
||||
|
||||
## Execution
|
||||
|
||||
Remember to get `hw8_files_F19.zip` from the Course Materials section of Submitty. It has two sample input files and the expected output for your program.
|
||||
|
||||
For this homework, all of the data required to initialize your classes and program can be found in JSON files. Each of your 3 parts should start by asking for the name of the JSON file, reading the file, and then creating the objects you need based on the data read. The code below will help you with this.
|
||||
|
||||
```python
|
||||
f = open("bears_and_berries_1.json")
|
||||
data = json.loads(f.read())
|
||||
print(data["berry_field"])
|
||||
print(data["active_bears"])
|
||||
print(data["reserve_bears"])
|
||||
print(data["active_tourists"])
|
||||
print(data["reserve_tourists"])
|
||||
```
|
||||
|
||||
You will see that the field is a list of lists where each `[row][column]` value is the number of berries at that location; the `"active_bears"` and `"reserve_bears"` entries are lists of three-tuples `(row, column, direction)` defining the bears; and the `"active_tourists"` and `"reserve_tourists"` entries are lists of two-tuples `(row, column)` defining the tourists.
|
||||
|
||||
## Part 1
|
||||
|
||||
In Part 1, read the JSON file, create your objects, and then simply report on the initial state of the simulation by printing out the berry field, active bears, and active tourists. Name your program `hw8_part1.py` and submit it along with the three classes you developed.
|
||||
|
||||
## Part 2
|
||||
|
||||
In Part 2, start off the same by reading the JSON file, create your objects, and again print out the initial state of the simulation. Then run five turns of the simulation by:
|
||||
|
||||
- Growing the berries
|
||||
- Moving the bears
|
||||
- Checking on the tourists
|
||||
- Printing out the state of the simulation
|
||||
|
||||
Do not worry about the reserve bears or reserve tourists entering the field, but report on any tourists or bears that leave. Name your program `hw8_part2.py` and submit it along with the three classes you developed.
|
||||
|
||||
## Part 3
|
||||
|
||||
In Part 3, do everything you did in Part 2, but make the following changes:
|
||||
|
||||
- After checking on the tourists, if there are still bears in the reserve queue and at least 500 berries, add the next reserve bear to the active bears.
|
||||
- Then, if there are still tourists in the reserve queue and at least 1 active bear, add the next reserve tourist to the field.
|
||||
- Instead of stopping after 5 turns, run until there are no more bears on the field and no more bears in the reserve list, or if there are no more bears on the field and no more berries.
|
||||
- Finally, instead of reporting status every turn, report it every 5 turns and then again when the simulation ends.
|
||||
|
||||
As you go, report on any tourists or bears that leave or enter the field. Name your program `hw8_part3.py` and submit it along with the three classes you developed.
|
||||
|
||||
## Supporting Files
|
||||
|
||||
{{< link href="HW6.zip" content="HW6.zip" title="Download HW6.zip" download="HW6.zip" card=true >}}
|
||||
|
||||
## Solution
|
||||
|
||||
> [!NOTE]
|
||||
> I didn't get a full mark in this assignment, so I didn't post the solution. I may redo it to get a full mark solution. After that, I will add it here.
|
||||
BIN
hugo_extended_0.134.2_linux-amd64.deb
Normal file
BIN
hugo_extended_0.134.2_linux-amd64.deb
Normal file
Binary file not shown.
@@ -1,9 +1,10 @@
|
||||
{{- define "title" -}}
|
||||
{{- .Title -}}
|
||||
{{- title .Title -}}
|
||||
{{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "content" -}}
|
||||
{{- $title := title .Title -}}
|
||||
{{- $params := partial "function/params.html" -}}
|
||||
{{- $toc := .Scratch.Get "toc" -}}
|
||||
{{- $tocEmpty := eq .TableOfContents `<nav id="TableOfContents"></nav>` -}}
|
||||
@@ -11,8 +12,12 @@
|
||||
<aside class="aside-collection animate__animated animate__fadeIn animate__faster" aria-label="{{ T "collections" }}">
|
||||
{{- /* Collection List */ -}}
|
||||
{{- partial "single/collection-list.html" . -}}
|
||||
{{- /* Custom part for aside */ -}}
|
||||
{{- partial (.Scratch.Get "customFilePath").aside . -}}
|
||||
|
||||
{{- /* TODO Related Content */ -}}
|
||||
{{/* {{- partial "single/related.html" . -}} */}}
|
||||
|
||||
{{- /* Custom Aside */ -}}
|
||||
{{- block "custom-aside" . }}{{ end -}}
|
||||
</aside>
|
||||
|
||||
<article class="page single">
|
||||
@@ -84,50 +89,44 @@
|
||||
<!--{{- $comment := .Scratch.Get "comment" | default dict -}}
|
||||
{{- $visitorIcon := dict "Class" "fa-regular fa-eye fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- $commentIcon := dict "Class" "fa-regular fa-comments fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- if $comment.enable -}}
|
||||
{{- /* Visitor Count */ -}}
|
||||
{{- if $comment.artalk.enable -}}
|
||||
<span class="comment-visitors" data-flag-title="{{ .Title }}">
|
||||
{{ $visitorIcon }}<span class="artalk-visitor-count" data-page-key="{{ .RelPermalink }}">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- else if ($comment.valine.enable | and $comment.valine.visitor) -}}
|
||||
<span id="{{ .RelPermalink }}" class="leancloud_visitors comment-visitors" data-flag-title="{{ .Title }}">
|
||||
{{ $visitorIcon }}<span class="leancloud-visitors-count">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- else if $comment.waline.enable | and $comment.waline.pageview -}}
|
||||
<span class="comment-visitors" data-flag-title="{{ .Title }}">
|
||||
{{ $visitorIcon }}<span data-path="{{ .RelPermalink }}" class="waline-pageview-count">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- else if $comment.twikoo.enable | and $comment.twikoo.visitor -}}
|
||||
<span id="{{ .RelPermalink }}" class="comment-visitors" data-flag-title="{{ .Title }}">
|
||||
{{ $visitorIcon }}<span id="twikoo_visitors">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- else if .Site.Params.ibruce.enable | and .Site.Params.ibruce.enablePost -}}
|
||||
<span id="busuanzi_container_page_pv" class="busuanzi_visitors comment-visitors" data-flag-title="{{ .Title }}">
|
||||
{{ $visitorIcon }}<span id="busuanzi_value_page_pv">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- end -}}
|
||||
{{- else if .Site.Params.ibruce.enable | and .Site.Params.ibruce.enablePost -}}
|
||||
<span id="busuanzi_container_page_pv" class="busuanzi_visitors comment-visitors" data-flag-title="{{ .Title }}">
|
||||
{{ $visitorIcon }}<span id="busuanzi_value_page_pv">-</span> {{ T "single.views" }}
|
||||
{{- if $comment.enable | and $comment.artalk.enable -}}
|
||||
<span class="comment-visitors" data-flag-title="{{ $title }}">
|
||||
{{- $visitorIcon }}<span class="artalk-visitor-count" data-page-key="{{ .RelPermalink }}">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- else if $comment.enable | and $comment.valine.enable | and $comment.valine.visitor -}}
|
||||
<span id="{{ .RelPermalink }}" class="leancloud_visitors comment-visitors" data-flag-title="{{ $title }}">
|
||||
{{- $visitorIcon }}<span class="leancloud-visitors-count">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- else if $comment.enable | and $comment.waline.enable | and $comment.waline.pageview -}}
|
||||
<span class="comment-visitors" data-flag-title="{{ $title }}">
|
||||
{{- $visitorIcon }}<span data-path="{{ .RelPermalink }}" class="waline-pageview-count">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- else if $comment.enable | and $comment.twikoo.enable | and $comment.twikoo.visitor -}}
|
||||
<span id="{{ .RelPermalink }}" class="comment-visitors" data-flag-title="{{ $title }}">
|
||||
{{- $visitorIcon }}<span id="twikoo_visitors">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- else if .Site.Params.busuanzi.enable | and .Site.Params.busuanzi.pageViews | and hugo.IsProduction -}}
|
||||
<span id="busuanzi_container_page_pv" class="busuanzi_visitors comment-visitors" data-flag-title="{{ $title }}">
|
||||
{{- $visitorIcon }}<span id="busuanzi_value_page_pv">-</span> {{ T "single.views" }}
|
||||
</span>
|
||||
{{- end -}}
|
||||
{{- /* Comment Count */ -}}
|
||||
{{- if $comment.enable -}}
|
||||
{{- if $comment.artalk.enable -}}
|
||||
<span class="comment-count" data-flag-title="{{ .Title }}">
|
||||
<span class="comment-count" data-flag-title="{{ $title }}">
|
||||
{{ $commentIcon }}<span class="artalk-comment-count" data-page-key="{{ .RelPermalink }}">-</span> {{ T "single.comments" }}
|
||||
</span>
|
||||
{{- else if $comment.valine.enable | and $comment.valine.commentCount -}}
|
||||
<span class="comment-count" data-flag-title="{{ .Title }}">
|
||||
<span class="comment-count" data-flag-title="{{ $title }}">
|
||||
{{ $commentIcon }}<span data-xid="{{ .RelPermalink }}" class="valine-comment-count">-</span> {{ T "single.comments" }}
|
||||
</span>
|
||||
{{- else if $comment.waline.enable | and $comment.waline.comment -}}
|
||||
<span class="comment-count" data-flag-title="{{ .Title }}">
|
||||
<span class="comment-count" data-flag-title="{{ $title }}">
|
||||
{{ $commentIcon }}<span data-path="{{ .RelPermalink }}" class="waline-comment-count">-</span> {{ T "single.comments" }}
|
||||
</span>
|
||||
{{- else if $comment.twikoo.enable | and $comment.twikoo.commentCount -}}
|
||||
<span id="{{ .RelPermalink }}" class="comment-count" data-flag-title="{{ .Title }}">
|
||||
<span id="{{ .RelPermalink }}" class="comment-count" data-flag-title="{{ $title }}">
|
||||
{{ $commentIcon }}<span id="twikoo-comment-count">-</span> {{ T "single.comments" }}
|
||||
</span>
|
||||
{{- end -}}
|
||||
@@ -161,21 +160,7 @@
|
||||
|
||||
{{- /* Content */ -}}
|
||||
{{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
{{- if $params.password -}}
|
||||
{{- $saltLen := strings.RuneCount (trim $params.password "") -}}
|
||||
{{- $saltLen = cond (eq (mod $saltLen 2) 0) (add $saltLen 1) $saltLen -}}
|
||||
{{- $base64EncodeContent := $content | base64Encode -}}
|
||||
{{- $content = printf "%v%v%v"
|
||||
(substr $base64EncodeContent 0 $saltLen)
|
||||
(substr (sha256 $params.password) $saltLen)
|
||||
(substr $base64EncodeContent $saltLen)
|
||||
-}}
|
||||
{{- end -}}
|
||||
<div class="content" id="content"
|
||||
{{- with $params.endFlag }} data-end-flag="{{ . }}"{{- end -}}
|
||||
{{- with $params.password }} data-password="{{ md5 . }}"{{- end -}}
|
||||
{{- with $params.password }} data-content="{{ $content }}"{{- end -}}
|
||||
>
|
||||
<div class="content" id="content"{{ with $params.endFlag }} data-end-flag="{{ . }}"{{ end }}>
|
||||
{{- if not $params.password -}}
|
||||
{{- /* Expiration Reminder */ -}}
|
||||
{{- partial "single/expiration-reminder.html" . -}}
|
||||
@@ -195,17 +180,23 @@
|
||||
{{- /* Collection Navigation */ -}}
|
||||
{{- partial "single/collection-nav.html" . -}}
|
||||
|
||||
{{- /* FixIt Decryptor */ -}}
|
||||
{{- partial "single/fixit-decryptor.html" . -}}
|
||||
{{- /* Content Encryption */ -}}
|
||||
{{- dict "Content" $content "Password" $params.password "Message" $params.message | partial "plugin/fixit-encryptor.html" -}}
|
||||
|
||||
{{- /* Custom block before post footer */ -}}
|
||||
{{- block "custom-post__footer:before" . }}{{ end -}}
|
||||
|
||||
{{- /* Footer */ -}}
|
||||
{{- partial "single/footer.html" . -}}
|
||||
|
||||
{{- /* Reward after Footer */ -}}
|
||||
{{- /* Reward after post footer */ -}}
|
||||
{{- if eq $reward.position "after" -}}
|
||||
{{- partial "single/reward.html" . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Custom block after post footer */ -}}
|
||||
{{- block "custom-post__footer:after" . }}{{ end -}}
|
||||
|
||||
{{- /* Comment */ -}}
|
||||
{{- partial "single/comment.html" . -}}
|
||||
</article>
|
||||
|
||||
Submodule themes/FixIt updated: 1ed0acdf35...849d7d486d
Submodule themes/component-projects updated: adcb7d3520...259e0a1105
Reference in New Issue
Block a user