assignment6
.pdf
keyboard_arrow_up
School
University of California, Davis *
*We aren’t endorsed by this school
Course
680
Subject
Computer Science
Date
Dec 6, 2023
Type
Pages
3
Uploaded by ConstableBeaverMaster735 on coursehero.com
Homework Assignments
Homework Assignment 6
This is your final project report, and talk.
Homework Assignment 5
This is a short video synopsis of your final project.
Homework Assignment 4
This was your final project proposal
Homework Assignment 3
Paper part due Thursday, March 5, at the start of class, code by midnight.
This assignment focusses on intelligent search. See handout for details.
Clarifications
N starts at 0.
floating point input sequences are possible, i.e.:
odd05% ./prog1 .2 .4 .6 .8
With floating point numbers, remember there is a roundoff issue. Be sure to include a tolerance when determing
if floating point numbers are equal.
Your goal is to find the shortest (smallest number of leaf nodes) possible sequence function that solves the
problem.
Use the command line to input sequences to your program, i.e.:
odd05% ./prog1 0 1 2 3 4 5
Shortest function is:
N
Next item is:
6
odd05% ./prog1 2 3 4 5
Shortest function is:
N + 2
Next item is:
6
Be sure to include a
Makefile
, and include any special instructions for running your program by using a
readme.txt
file.
I will be testing your code on the Ubuntu machines (the machines in Stocker 307), so be sure it compiles and
runs there!
C++ programs must use the suffix ".cc".
You MAY NOT use the suffix ".cpp" which some other operating
systems use.
Text files, e.g. script output, should be submitted with the suffix ".txt" e.g. "testcase1.txt", or "test1.txt".
You are to turn in your code electronically by using the
submit
program on the Ubuntu machines, i.e. those in
Stocker 307
(BE SURE TO USE THE MACHINES IN 307 TO RUN SUBMIT(e.g. odd01.cs.ohio.edu, or
pu1.cs.ohio.edu), DO NOT USE PRIME, P1, or P2.).
To use this method to submit this first program:
~cs6800/bin/submit prog1 prog1.cc test1.txt test2.txt test3.txt Makefile readme.txt
or using the unix wildcard '*' command:
~cs6800/bin/submit prog1 prog1.cc test* Makefile readme.txt
Note: the first word after the submit command is the name of the assignment to submit, this will change
depending on which assignment you are submitting. For homework assignments you will use
prog1
,
prog2
, etc.
Be sure to limit any single submission to at most 20 files.
There is also an interactive version of the command:
odd01.cs.ohio.edu>
~cs6800/bin/submit
This version allows you to check what has been submitted, as well as several other commands. Here is an
example of its use:
odd01.cs.ohio.edu>
~cs6800/bin/submit
**
Welcome to the submit program.
**
- This program submits programs for CS6800.
Remember you can use this program either as menu driven, or
command-line driven. Type submit -h for more help.
Please type the assignment name to submit:
prog1
At any point: ^C will quit, with no changes to any files.
Enter one of the following choices:
s: submit new files
r: review the files submitted
d: delete/remove all files previously submitted
l: check late record
q: quit
Choice:
Or for help:
/home/cs6800/bin/submit -h
Homework Assignment 2
Due Thursday, February 13 at the start of class.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
CHALLENGE ACTIVITY
5.10.2: Simon says
Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one paint to userScore. Upon a mismatch, exit the loop using a break statement Assume simon Pattern and userPattern are always the same length. Ex The following patterns yield a userScore of 4:
simonPattern: RRGBRYYBGY
userPattern: RRGBBRYBGY
Learn how our autograde works
13
14
simonPattern- scnr.next(); userPattern - scnr.nextO:
15
16
17
for (i=0; i<10; i++) {
18
if O[ simornPattern:
19
20 21
if (
22
23
24
userPattern:
25
26
returns
System.out.println("userScore: userScore);
매매
arrow_forward
# Create Custom Transformer
Create a custom transformer, just as we did in the lecture video entitled "Custom Transformers", that performs two computations:
1. Adds an attribute to the end of the numerical data (i.e. new last column) that is equal to $\frac{x_1^3}{x_5}$ for each observation. In other words, for each instance, you will cube the $x_1$ column and then divide by the $x_5$ column.
2. Drops the entire $x_4$ feature column if the passed function argument `drop_x4` is `True` and doesn't drop the column if `drop_x4` is `False`. (See further instructions below.)
You must name your custom transformer class `Assignment4Transformer`. Your class should include an input parameter called `drop_x4` with a default value of `True` that deletes the $x_4$ feature column when its value is `True`, but preserves the $x_4$ feature column when you pass a value of `False`.
This transformer will be used in a pipeline. In that pipeline, an imputer will be run *before* this transformer. Keep…
arrow_forward
def upgrade_stations(threshold: int, num_bikes: int, stations: List["Station"]) -> int: """Modify each station in stations that has a capacity that is less than threshold by adding num_bikes to the capacity and bikes available counts. Modify each station at most once.
Return the total number of bikes that were added to the bike share network.
Precondition: num_bikes >= 0
>>> handout_copy = [HANDOUT_STATIONS[0][:], HANDOUT_STATIONS[1][:]] >>> upgrade_stations(25, 5, handout_copy) 5 >>> handout_copy[0] == HANDOUT_STATIONS[0] True >>> handout_copy[1] == [7001, 'Lower Jarvis St SMART / The Esplanade', \ 43.647992, -79.370907, 20, 10, 10] True """
arrow_forward
C++ Please explain the code below.
It doesn't have to be long, as long as you explain what the important parts of your code do. You can also explain it line by line for best ratings. Thank you so much!
#include <iostream>#include "linkedlist.h"
void bubbleSort(List*);void selectionSort(List*);void insertionSort(List*);
int main(void) { char li; cin >> li; List* list; if (li == 'A') { list = new ArrayList(); } else { list = new LinkedList(); } int length; cin >> length; int input; for (int i = 0; i < length; i++) { cin >> input; list->add(input); } list->print(); char sym; cin >> sym; switch (sym) { case 'B': bubbleSort(list); break; case 'I': insertionSort(list); break; case 'S': selectionSort(list); break; } return 0;};
//Perform two of three sorting algorithms here.//Reminder: Do not use methods…
arrow_forward
def determineHours(): with open ("StudyHours.txt", "r") as file1: data = file1.readlines() total_study_hours = 0
for i, line in enumerate(data): if "error" in line: print(f"Error found in line {i + 1}: {line}") correct = input("Do you want to correct this line?(y\n)") if correct == "y": new_line = input("Enter corrected line:") data[i]=new_line for record in data: fields = record.strip().split(',') name = fields[0].title() credits = int(fields[1]) grade = fields[2]
if grade == 'A':#determine weekly study hours based on desired grade study_hours = 15 * credits elif grade == 'B': study_hours = 12 * credits elif grade == 'C': study_hours = 9 * credits elif…
arrow_forward
A readinglist is a doubly linked list in which each element of the list is a book. So, you must make sure that Books are linked with the previous prev and next element.
A readinglist is unsorted by default or sorted (according to title) in different context. Please pay attention to the task description below. Refer to the relevance classes for more detail information.
Implement the add_book_sorted method of the ReadingList class.
Assume the readinglist is sorted by title, the add_book_sorted method takes an argument new_book (a book object), it adds the new_book to the readinglist such that the readinglist remain sorted by title.
For example, if the readinglist contain the following 3 books:
Title: Artificial Intelligence Applications Author: Cassie Ng Published Year: 2000 Title: Python 3 Author: Jack Chan Published Year: 2016 Title: Zoo Author: Cassie Chun Published Year: 2000
If we add another book (titled "Chinese History"; author "Qin Yuan"; and published year 1989) to the…
arrow_forward
Please help me write the code to produce the outcome scenarios below. Thank you
1. A Grave is a dictionary with two keys:
'name': A string value with the grave's occupant's name
'message': A string value with the grave's message
Define a function named count_shouters that consumes a list of graves and produces an integer representing the number of graves that had their messages in all capital letters. Hint: use the .upper() method.
You are not required to document of unit test the function.
2.
A Media is a dictionary with the following keys:
"name": The name of this media
"kind": Either "movie", "song", or "game"
"duration": The length of this media in minutes
Define the function longest_kind that consumes a list of Media and produces a string value representing the kind that had the highest duration. If the list is empty, return the value None.
You are not required to document of unit test the function.
arrow_forward
Create a .txt file with 3 rows of various movies data of your choice in the following table format:
Movie ID number of viewers rating release year Movie name 0000012211 174 8.4 2017 "Star Wars: The Last Jedi" 0000122110 369 7.9 2017 "Thor: Ragnarok"
Create a class Movie which instantiates variables corresponds to the table columns. Implement getters, setters, constructors and toString.
----Important
1. Implement two search methods to search Movies by their rating from unsorted array and by year (first) and a rating (second) from unsorted List. Test your methods and explain their time complexity.
arrow_forward
Please help me with the assignment below
The assignment:
Make a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in random order. Handle lookups by name and also reverse lookups by phone number. Use a binary search for both lookups. This assignment needs a resource class and a driver class. The resource class and the driver class will be in two separate files. The driver class needs to have only 5 or 7 lines of code. The code needs to be written in Java. Please help me with exactly what I asked for help.
arrow_forward
Help me solve this problem!:
Method Skeletons and a Loop Roundup
Practice these steps again and then solve the set of loop problems. These problems are more difficult than those in the previous lesson, so you'll need to take your time and work through each one step-by-step.
Here is the link: https://codecheck.it/files/1906092225agosqgnp6wc7mwgcfpf6s4wky
arrow_forward
Movie Recommendations via Item-Item Collaborative Filtering. You are providedwith real-data (Movie-Lens dataset) of user ratings for different movies. There is a readmefile that describes the data format. In this project, you will implement the item-item collab-orative filtering algorithm that we discussed in the class. The high-level steps are as follows:
a) Construct the profile of each item (i.e., movie). At the minimum, you should use theratings given by each user for a given item (i.e., movie). Optionally, you can use other in-formation (e.g., genre information for each movie and tag information given by user for eachmovie) creatively. If you use this additional information, you should explain your method-ology in the submitted report.
b) Compute similarity score for all item-item (i.e., movie-movie) pairs. You will employ thecentered cosine similarity metric that we discussed in class.
c) Compute the neighborhood set Nfor each item (i.e. movie). You will select the moviesthat…
arrow_forward
1.Reverse a string
2) If you used positive indices to reverse your string originally, use negative indices
3) Use a slice to reverse a string
4) Show some code using lstrip() -- just show a line of code you don't need to show your entire project
arrow_forward
Log
There was a storm recently on Jolibi village. The storm was so strong that some treesfell. There are some logs of varied length lying on the ground. The village ground canbe represented by a string of length N, where the i-th character is either 1 or 0. A singlelog is represented by consecutive characters of 1, and two different logs are separated byone or more 0. For example, for the string 1100010111, there are 3 logs. The first one atposition 1 to 2 with length 2, the second one at position 6 with length 1, and the thirdone at position 8 to 10 with length 3.As a carpenter, you want to take one of these logs home. Because you are the seniorcarpenter, you may take the longest log home. Determine the length of the longest log!
Format InputThe first line contains an integer N, the length of the string. The next line contains a string of length N, which represents thevillage ground.
Format OutputOutput an integer X, the length of the longest log.
Constraints• 1 ≤ N ≤ 104• the i-th…
arrow_forward
Q3: Lecture Hall Dan holds his CSC108 lectures in a rectangular N X M lecture hall. In other words, this lecture hall has N rows of seats, each of them containing exactly M seats. Here's my attempt at drawing this layout when N = 3 and M = 5: Dan Off 00 lecture hall layout with 3 rows and 5 seats per row The rows are numbered from 1 to N starting from the front row. Similarly, the columns are numbered from 1 to M starting from the leftmost column. We write (r, c) to denote the c-th seat in the r-th row. When Dan walks into the lecture hall this morning, some of the seats are already taken (this is the initial layout of the lecture hall). After that, the students come in one group at a time. From experience, Dan knows that when a group of K students enter the lecture hall, they look for K consecutive empty seats. That is, they try to find an empty seat (r, c) such that for all integers i in [0, K-1], the seat (r, c + 1) exists and is empty. If they can't find K consecutive empty seats,…
arrow_forward
/** * Returns the value associated with the given key in this symbol table. * Takes advantage of the fact that the keys appear in increasing order to terminate * early when possible. * * @param key the key * @return the value associated with the given key if the key is in the symbol table * and {@code null} if the key is not in the symbol table * @throws IllegalArgumentException if {@code key} is {@code null} */ public Value get(Key key) { // TODO // Change this code to make use of the fact the list is sorted to terminate early // when possible. if (key == null) throw new IllegalArgumentException("argument to get() is null"); return null; }
Use loops for this method but do not use the keys() method. Note: You are modifying the implementation of the methods, but not their interface or contract.
arrow_forward
/** * Returns the value associated with the given key in this symbol table. * Takes advantage of the fact that the keys appear in increasing order to terminate * early when possible. * * @param key the key * @return the value associated with the given key if the key is in the symbol table * and {@code null} if the key is not in the symbol table * @throws IllegalArgumentException if {@code key} is {@code null} */ public Value get(Key key) { // TODO // Change this code to make use of the fact the list is sorted to terminate early // when possible. Also, solve this using recursion. To do this, you will need to // add a recursive helper function that takes the front of a list (Node) as an argument // and returns the correct value. if (key == null) throw new IllegalArgumentException("argument to get() is null"); for (Node x = first; x != null; x = x.next) { if (key.equals(x.key))…
arrow_forward
/** * Returns the value associated with the given key in this symbol table. * Takes advantage of the fact that the keys appear in increasing order to terminate * early when possible. * * @param key the key * @return the value associated with the given key if the key is in the symbol table * and {@code null} if the key is not in the symbol table * @throws IllegalArgumentException if {@code key} is {@code null} */ public Value get(Key key) { // TODO // Change this code to make use of the fact the list is sorted to terminate early // when possible. Also, solve this using recursion. To do this, you will need to // add a recursive helper function that takes the front of a list (Node) as an argument // and returns the correct value. if (key == null) throw new IllegalArgumentException("argument to get() is null"); for (Node x = first; x != null; x = x.next) { if (key.equals(x.key))…
arrow_forward
/** * Returns the value associated with the given key in this symbol table. * Takes advantage of the fact that the keys appear in increasing order to terminate * early when possible. * * @param key the key * @return the value associated with the given key if the key is in the symbol table * and {@code null} if the key is not in the symbol table * @throws IllegalArgumentException if {@code key} is {@code null} */ public Value get(Key key) { // TODO // Change this code to make use of the fact the list is sorted to terminate early // when possible. if (key == null) throw new IllegalArgumentException("argument to get() is null"); return null; }
arrow_forward
/** * Returns the value associated with the given key in this symbol table. * Takes advantage of the fact that the keys appear in increasing order to terminate * early when possible. * * @param key the key * @return the value associated with the given key if the key is in the symbol table * and {@code null} if the key is not in the symbol table * @throws IllegalArgumentException if {@code key} is {@code null} */ public Value get(Key key) { // TODO // Change this code to make use of the fact the list is sorted to terminate early // when possible. Also, solve this using recursion. To do this, you will need to // add a recursive helper function that takes the front of a list (Node) as an argument // and returns the correct value. if (key == null) throw new IllegalArgumentException("argument to get() is null"); for (Node x = first; x != null; x = x.next) { if (key.equals(x.key))…
arrow_forward
/** * Returns the value associated with the given key in this symbol table. * Takes advantage of the fact that the keys appear in increasing order to terminate * early when possible. * * @param key the key * @return the value associated with the given key if the key is in the symbol table * and {@code null} if the key is not in the symbol table * @throws IllegalArgumentException if {@code key} is {@code null} */ public Value get(Key key) { // TODO // Change this code to make use of the fact the list is sorted to terminate early // when possible. if (key == null) throw new IllegalArgumentException("argument to get() is null"); for (Node x = first; x != null; x = x.next) { if (key.equals(x.key)) return x.val; } return null; }
You may not use the keys() method. Note: You are modifying the implementation of the methods, but not their interface or contract.
arrow_forward
Here you are required to draw a bar chart of batchwise strength of Avionics Department with following features through python:
Add suitable label in the x axis, y axis and a title.
Display a horizontal bar chart.
Display a vertical bar chart.
Use different color for each bar.
Attach a text label above each bar displaying its strength (number of students).
You are given two lists/arrays:
Batch = [Ave-01, Ave-02, Ave-03, Ave-04, Ave-05, Ave-06]
Num_Students = [29,50,35,45,50,40]
arrow_forward
q1a.py file:
https://drive.google.com/file/d/1IRPCW9JpEdY7T6IqTVsEj8WBPVhOSyvP/view?usp=sharing
q1a.py that contains three mystery functions, namely funcA, funcB, and funcC, that process a Python list.Evaluate the scalability of the three functions empirically, based on the time taken to processlists of sizes 500, 1000, 2000 and 4000.
arrow_forward
this code gives me an error
Traceback (most recent call last): File "main.py", line 2, in <module> from IntList import IntList File "/home/runner/local/submission/IntList.py", line 24, in <module> if new_node.data > current.next.data: NameError: name 'new_node' is not defined
The original code given that can be edited is below
class IntList: def __init__(self): self.head = None self.tail = None
def append(self, new_node): if self.head == None: self.head = new_node self.tail = new_node else: self.tail.next = new_node new_node.prev = self.tail self.tail = new_node
def prepend(self, new_node): if self.head == None: self.head = new_node self.tail = new_node else: new_node.next = self.head self.head.prev = new_node self.head = new_node
def insert_after(self, current_node, new_node): if self.head is None:…
arrow_forward
Version:0.9 StartHTML:0000000105 EndHTML:0000002393 StartFragment:0000000141 EndFragment:0000002353
A smaller bucket with capacity 1 (unit of volume) is used to fifill a larger bucket with
capacity v (units of volume). A farmer successively draws water from a well using the smaller bucket and poors the content in the larger bucket.
Suppose the successive amounts of water taken out of the well form a sequence of independent uniform over [0, 1] random variables.
(a) On average, how many times will the farmer have to draw water out of the well to fifill the larger bucket if its volume is v = 1?
(b) Repeat for v = 2.
arrow_forward
Results are not the same at the end and I do not get the right result after choosing number 3. The images below is how it should look like going from entering first student to printing information of a faculty. Here's part of my code :
class UniversityPersonnelManagement {public static void main(String[] args) {//create list to store Student objectsArrayList<Student> studentList = new ArrayList<Student>();//create list to store Faculty objectsArrayList<Faculty> facultyList = new ArrayList<Faculty>();System.out.println("Welcome to my Personal Management Program");for (;;) {int input = 0;System.out.println(" Choose one of the options:");System.out.println("1- Add a new Faculty member");System.out.println("2- Add a new Student");System.out.println("3- Print tuition invoice for a student");System.out.println("4- Print information of a faculty");System.out.println("5- Exit Program");System.out.print("\n Enter your selection: ");Scanner s = new Scanner(System.in);try…
arrow_forward
C++
Given the commands below, what do they do?
for (position = 1 through aList.getLength()/2)
{
a = aList.getEntry(aList.getLength()-position+1)
aList.setEntry(aList.getEntry(aList.getLength()-position+1))
aList.setEntry(a,position)
}
A. randomize the entries
B. sort the entries
C. reverse the order of the entries
D. count how many entries there are
arrow_forward
Twitter Data:
twitter_url = 'https://raw.githubusercontent.com/Explore-AI/Public-Data/master/Data/twitter_nov_2019.csv'twitter_df = pd.read_csv(twitter_url)twitter_df.head()
Question: Write the Number of Tweets per Day
Write a function which calculates the number of tweets that were posted per day.
Function Specifications:
It should take a pandas dataframe as input.
It should return a new dataframe, grouped by day, with the number of tweets for that day.
The index of the new dataframe should be named Date, and the column of the new dataframe should be 'Tweets', corresponding to the date and number of tweets, respectively.
The date should be formated as yyyy-mm-dd, and should be a datetime object. Hint: look up pd.to_datetime to see how to do this.
arrow_forward
astfoodStats Assignment Description
For this assignment, name your R file fastfoodStats.R
For all questions you should load tidyverse, openintro, and lm.beta. You should not need to use any other libraries.
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(openintro))
suppressPackageStartupMessages(library(lm.beta))
The actual data set is called fastfood.
Continue to use %>% for the pipe. CodeGrade does not support the new pipe.
Round all float/dbl values to two decimal places.
All statistics should be run with variables in the order I state
E.g., "Run a regression predicting mileage from mpg, make, and type" would be:
lm(mileage ~ mpg + make + type...)
To access the fastfood data, run the following:
fastfood <- openintro::fastfood
Create a correlation matrix for the relations between calories, total_fat, sugar, and calcium for all items at Sonic, Subway, and Taco Bell, omitting missing values with na.omit().
Assign the…
arrow_forward
Create a file quote.txt in your project with the following quote:
we observe today not a victoryof party but a celebrationof freedom symbolizing an endas well as a beginningsignifying renewal as wellas change
Your program will make a dictionary with each key being a word from the file and each value being a list of integers.
Each list will contain the row numbers the corresponding word appears in.
i.e. “a” appears in lines 1, 2, and 4 so your dictionary should have { “a” : [1, 2, 4] } as one of its key/value pairs.
Hint: You’ll need nested loops. The outer for loop should read one line from the file at a time and use the enumerate function (so you can keep track of which line you’re currently reading)
After the file is read, print the data in your dictionary. Your program’s output should resemble the following output:
observe 1 today 1 not 1 a 1 2 4 victory 1 of 2 3 party 2 but 2 celebration 2 freedom 3 symbolizing 3 an 3 end 3 as 4 4 5 6 well 4 5 beginning 4 signifying 5…
arrow_forward
In Dist.txt it will add vaccine in storage like how many vaccines are needed and from where is coming and Add search function in which from user it will check how many vaccines are available in storage this will be done in Vaccine.txt somewhat like in image given
#include <stdio.h>#include <stdlib.h>#include <string.h>
struct vacc{ char vaccName[15];
char vaccCode[2];
char country[15];
int qty;
float population;
}v[10];
// Function Declarations
void create_inventory();
void update_vacc_qty();
int search_vaccine();
void display_vaccine();
// Main Function starts here
int main()
{
//create_inventory();
//display_vaccine();
//search_vaccine();
update_vacc_qty();
return 0;
}
//Function to Create Vaccine.txt as per the given table
void create_inventory()
{
int option = 1;
// variables to collect data as per table given
char vaccName[15];
char vaccCode[2];
char country[15];
int qty;
float populaion;
//File definition
FILE *infile;
infile = fopen("Vaccine.txt","w");…
arrow_forward
1. A list of students (student ID, first name, last name, list of 4 test grades) will be transformed intoStudent objects. We will provide this file for you.a. Each feature will be separated by commas, however; the grades will be separated byspaces, as shown in this example line: 82417619,Erik,Macik,95.6 85 100 88[Hint: It seems like you might need to use the split method twice]b. Your program should work with any file with any number of lines.2. A menu will be displayed on loop to the user (meaning after a user completes a selection, themenu will be displayed again, unless the user exits).The menu options should be the following:a. View Student Grade and Averageb. Get Test Averagec. Get Top Student per examd. Exit3. Your system shall incorporate the following classes. Each class will require one file.GRADE CALCULATORPurposeA class that contains useful methods that can be used to calculate averages andconvert grades to letter gradesAttributes: NoneMethodsconvertToLetterGrade(double…
arrow_forward
Collapse positive integer intervals
def collapse_intervals(items):
This function is the inverse of the previous problem of expanding positive integer intervals. Given a nonempty list of positive integer items guaranteed to be in sorted ascending order, create and return the unique description string where every maximal sublist of consecutive integers has been condensed to the notation first-last. Such encoding doesn’t actually save any characters when first and last differ by only one. However, it is usually more important for the encoding to be uniform than to be pretty. As a general principle, uniform and consistent encoding of data allows the processing of that data to also be uniform in the tools down the line.
If some maximal sublist consists of a single integer, it must be included in the result string all by itself without the minus sign separating it from the now redundant last number. Make sure that the string returned by your function does not contain any whitespace…
arrow_forward
Exercise 11.10. Two words are “rotate pairs” if you can rotate one of them and get the other (see rotate_word in Exercise 8.12).
Exercise 8.12. ROT13 is a weak form of encryption that involves “rotating” each letter in a word by 13 places. To rotate a letter means to shift it through the alphabet, wrapping around to the beginning if necessary, so ’A’ shifted by 3 is ’D’ and ’Z’ shifted by 1 is ’A’. Write a function called rotate_word that takes a string and an integer as parameters, and that returns a new string that contains the letters from the original string “rotated” by the given amount. For example, “cheer” rotated by 7 is “jolly” and “melon” rotated by -10 is “cubed”. You might want to use the built-in functions ord, which converts a character to a numeric code, and chr, which converts numeric codes to characters. Potentially offensive jokes on the Internet are sometimes encoded in ROT13. If you are not easily offended, find and decode some of them.
Please solve Exercise 11.10 -…
arrow_forward
A basic wooden railway set contains the pieces shown in figure below. It identifies the quantityof each type of piece denoted by ‘x’. Each piece is not uniquely identified by a primary keyvalue only labeled by type. i.e., Input information only states quantity of types such as twelvestraight pieces, two branch pieces, two merge pieces, and sixteen curve pieces.
Pieces connect the knob to opening, with subtend curves extending the arc from start to end by45 degrees, and the pieces can be flipped over for track direction.
The task is to connect these pieces into a railway that has no overlapping tracks and no looseends where a train could run off onto the floor.
Question: Suppose that the pieces fit together exactly with no slack. Give a precise formulation of thetask as a search problem. Write a Java algorithm to assemble optimally solving the problem.
arrow_forward
Hello I need help creating " A TO DO LIST" code in java for an interactive test driver . Your interactive test driver loop will allow users to:
Add a task. This will require you to capture the subject, priority, and dueDate. Here are some tips on using Java LocalDates. Use now() for the startDate. TaskId should start at 1 and increment each time a task is added.
View the next task in the queue using the peek() method and then optionally complete the current task using the poll() method.
View a list of all tasks. This will require the use of an iterator and the peek() method on each element. Use isEmpty() to check if there are items in your queue and if not, display "No tasks in queue."
View a single task by id. This will require iterating the task list until the id is found and then displaying it.
Remove a task by id. This will require you to iterate through the Task queue until you find the task with the matching id. Use remove(task) and confirm to the user that the…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
CHALLENGE ACTIVITY
5.10.2: Simon says
Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one paint to userScore. Upon a mismatch, exit the loop using a break statement Assume simon Pattern and userPattern are always the same length. Ex The following patterns yield a userScore of 4:
simonPattern: RRGBRYYBGY
userPattern: RRGBBRYBGY
Learn how our autograde works
13
14
simonPattern- scnr.next(); userPattern - scnr.nextO:
15
16
17
for (i=0; i<10; i++) {
18
if O[ simornPattern:
19
20 21
if (
22
23
24
userPattern:
25
26
returns
System.out.println("userScore: userScore);
매매
arrow_forward
# Create Custom Transformer
Create a custom transformer, just as we did in the lecture video entitled "Custom Transformers", that performs two computations:
1. Adds an attribute to the end of the numerical data (i.e. new last column) that is equal to $\frac{x_1^3}{x_5}$ for each observation. In other words, for each instance, you will cube the $x_1$ column and then divide by the $x_5$ column.
2. Drops the entire $x_4$ feature column if the passed function argument `drop_x4` is `True` and doesn't drop the column if `drop_x4` is `False`. (See further instructions below.)
You must name your custom transformer class `Assignment4Transformer`. Your class should include an input parameter called `drop_x4` with a default value of `True` that deletes the $x_4$ feature column when its value is `True`, but preserves the $x_4$ feature column when you pass a value of `False`.
This transformer will be used in a pipeline. In that pipeline, an imputer will be run *before* this transformer. Keep…
arrow_forward
def upgrade_stations(threshold: int, num_bikes: int, stations: List["Station"]) -> int: """Modify each station in stations that has a capacity that is less than threshold by adding num_bikes to the capacity and bikes available counts. Modify each station at most once.
Return the total number of bikes that were added to the bike share network.
Precondition: num_bikes >= 0
>>> handout_copy = [HANDOUT_STATIONS[0][:], HANDOUT_STATIONS[1][:]] >>> upgrade_stations(25, 5, handout_copy) 5 >>> handout_copy[0] == HANDOUT_STATIONS[0] True >>> handout_copy[1] == [7001, 'Lower Jarvis St SMART / The Esplanade', \ 43.647992, -79.370907, 20, 10, 10] True """
arrow_forward
C++ Please explain the code below.
It doesn't have to be long, as long as you explain what the important parts of your code do. You can also explain it line by line for best ratings. Thank you so much!
#include <iostream>#include "linkedlist.h"
void bubbleSort(List*);void selectionSort(List*);void insertionSort(List*);
int main(void) { char li; cin >> li; List* list; if (li == 'A') { list = new ArrayList(); } else { list = new LinkedList(); } int length; cin >> length; int input; for (int i = 0; i < length; i++) { cin >> input; list->add(input); } list->print(); char sym; cin >> sym; switch (sym) { case 'B': bubbleSort(list); break; case 'I': insertionSort(list); break; case 'S': selectionSort(list); break; } return 0;};
//Perform two of three sorting algorithms here.//Reminder: Do not use methods…
arrow_forward
def determineHours(): with open ("StudyHours.txt", "r") as file1: data = file1.readlines() total_study_hours = 0
for i, line in enumerate(data): if "error" in line: print(f"Error found in line {i + 1}: {line}") correct = input("Do you want to correct this line?(y\n)") if correct == "y": new_line = input("Enter corrected line:") data[i]=new_line for record in data: fields = record.strip().split(',') name = fields[0].title() credits = int(fields[1]) grade = fields[2]
if grade == 'A':#determine weekly study hours based on desired grade study_hours = 15 * credits elif grade == 'B': study_hours = 12 * credits elif grade == 'C': study_hours = 9 * credits elif…
arrow_forward
A readinglist is a doubly linked list in which each element of the list is a book. So, you must make sure that Books are linked with the previous prev and next element.
A readinglist is unsorted by default or sorted (according to title) in different context. Please pay attention to the task description below. Refer to the relevance classes for more detail information.
Implement the add_book_sorted method of the ReadingList class.
Assume the readinglist is sorted by title, the add_book_sorted method takes an argument new_book (a book object), it adds the new_book to the readinglist such that the readinglist remain sorted by title.
For example, if the readinglist contain the following 3 books:
Title: Artificial Intelligence Applications Author: Cassie Ng Published Year: 2000 Title: Python 3 Author: Jack Chan Published Year: 2016 Title: Zoo Author: Cassie Chun Published Year: 2000
If we add another book (titled "Chinese History"; author "Qin Yuan"; and published year 1989) to the…
arrow_forward
Please help me write the code to produce the outcome scenarios below. Thank you
1. A Grave is a dictionary with two keys:
'name': A string value with the grave's occupant's name
'message': A string value with the grave's message
Define a function named count_shouters that consumes a list of graves and produces an integer representing the number of graves that had their messages in all capital letters. Hint: use the .upper() method.
You are not required to document of unit test the function.
2.
A Media is a dictionary with the following keys:
"name": The name of this media
"kind": Either "movie", "song", or "game"
"duration": The length of this media in minutes
Define the function longest_kind that consumes a list of Media and produces a string value representing the kind that had the highest duration. If the list is empty, return the value None.
You are not required to document of unit test the function.
arrow_forward
Create a .txt file with 3 rows of various movies data of your choice in the following table format:
Movie ID number of viewers rating release year Movie name 0000012211 174 8.4 2017 "Star Wars: The Last Jedi" 0000122110 369 7.9 2017 "Thor: Ragnarok"
Create a class Movie which instantiates variables corresponds to the table columns. Implement getters, setters, constructors and toString.
----Important
1. Implement two search methods to search Movies by their rating from unsorted array and by year (first) and a rating (second) from unsorted List. Test your methods and explain their time complexity.
arrow_forward
Please help me with the assignment below
The assignment:
Make a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in random order. Handle lookups by name and also reverse lookups by phone number. Use a binary search for both lookups. This assignment needs a resource class and a driver class. The resource class and the driver class will be in two separate files. The driver class needs to have only 5 or 7 lines of code. The code needs to be written in Java. Please help me with exactly what I asked for help.
arrow_forward
Help me solve this problem!:
Method Skeletons and a Loop Roundup
Practice these steps again and then solve the set of loop problems. These problems are more difficult than those in the previous lesson, so you'll need to take your time and work through each one step-by-step.
Here is the link: https://codecheck.it/files/1906092225agosqgnp6wc7mwgcfpf6s4wky
arrow_forward
Movie Recommendations via Item-Item Collaborative Filtering. You are providedwith real-data (Movie-Lens dataset) of user ratings for different movies. There is a readmefile that describes the data format. In this project, you will implement the item-item collab-orative filtering algorithm that we discussed in the class. The high-level steps are as follows:
a) Construct the profile of each item (i.e., movie). At the minimum, you should use theratings given by each user for a given item (i.e., movie). Optionally, you can use other in-formation (e.g., genre information for each movie and tag information given by user for eachmovie) creatively. If you use this additional information, you should explain your method-ology in the submitted report.
b) Compute similarity score for all item-item (i.e., movie-movie) pairs. You will employ thecentered cosine similarity metric that we discussed in class.
c) Compute the neighborhood set Nfor each item (i.e. movie). You will select the moviesthat…
arrow_forward
1.Reverse a string
2) If you used positive indices to reverse your string originally, use negative indices
3) Use a slice to reverse a string
4) Show some code using lstrip() -- just show a line of code you don't need to show your entire project
arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education