首页 > 其他分享 >CS202 Caesar’s Challenge

CS202 Caesar’s Challenge

时间:2023-07-02 15:24:28浏览次数:44  
标签:10 code assignment Challenge Caesar letter CS202 your points


CS202 Assignment 3-- Caesar’s Challenge (group assignment)
Due: 11:59pm 06/26/2023(Monday)
Introduction
As a renowned detective, Sherlock Holmes receives a lot of mail. Some of his mail included
puzzles from his rivals, attempting to be the first to confuse Sherlock. Unfortunately, many of
these correspondents are not very creative. In particular, he frequently gets “secret” messages
encoded with Caesar ciphers. Although these ciphers are trivial for Sherlock to crack, he has
much better things to do, and has therefore passed this task on to Dr. Watson. Help relieve Dr.
Watson of this boring job by writing a program to automatically decipher these messages.
Caesar cipher
A Caesar cipher takes as input a message string and a shift value n, and shifts each letter in the
message forward through the alphabet by n letters. For example, let's say n = 1. Then, shifting
the letter ‘A’ forward by 1 would return ‘B’, and shifting ‘B’ forward by 2 would return ‘D’.
The alphabet should wrap around - shifting ‘Z’ forward by 1 would return ‘A.’ For example,
shifting the word “HAL” forward by 1 would return “IBM”, and shifting “Abcdefghijklm,
nopqrstuvwxyz!” forward by 5 will return “Fghijklmnopqr, stuvwxyzabcde!”. (Notice that the
case of the letters is preserved, and non-letter symbols are unchanged.)
It might be easier to understand what "shifting forward" means if you look
at https://computerscienced.co.uk/site/caesar-cipher-wheel/caesar-cipher/
Decoding a message encoded with a shift of n is equivalent to encoding a message with a shift
of 26 − n. Of course, these rivals haven’t given Sherlock the shift value - your program has to
figure it out itself. One way to do this is by shifting the message by all 26 possible shifts, and
returning the one that seems most like English. To do this, you might find helpful this 26-
element array, holding the frequencies of each letter in English:
double[] englishFrequencies = {0.08167, 0.01492, 0.02782,
0.04253, 0.12702, 0.02228, 0.02015, 0.06094, 0.06966,
0.00153, 0.00772, 0.04025, 0.02406, 0.06749, 0.07507,
0.01929, 0.00095, 0.05987, 0.06327, 0.09056, 0.02758,
0.00978, 0.02360, 0.00150, 0.01974, 0.00074};
That is, 8.167% of all letters in English text are A, 1.492% are B, ... and 0.074% are Z.
Specification
Implement the class CaesarDecipher, which consists of the method
public static String decipher(String ciphertext);
Example
Input
decipher("Me m dqzaizqp pqfqofuhq, Etqdxaow Taxyqe dqoquhqe m bxqftadm ar rmz
ymux.");
Output
As a renowned detective, Sherlock Holmes receives a plethora of fan mail.
Hints:
Use a brute-force strategy to try every possible key value (1 ~ 25) and calculate the
frequency error that it generates, 代写CS202程序for example, the frequency error can be the summation of the
absolute frequency difference between the actual frequency of a letter in the deciphered text and
the given frequency of that letter in English text. For example, for a key candidate of 6, letter ‘W’
would be deciphered to letter ‘C’, and the absolute frequency difference would be:
| occurrence of letter ‘C’ in the deciphered text – 0.02782 |
After calculating the frequency errors for all candidate key values, choose the one with the smallest
frequency error, and use that key to decipher the ciphertext.
Submission requirements:
1. Submit your .java file to canvas. Use extra methods when necessary. Do not put everything
in the decipher().
2. A screenshot of your running result. (png, jpg, pdf, or docx)
3. Each group can have at most two students. If you work with another student in a group,
submit a README.docx or README.txt containing both students’ names and a
description of each student’s work in this assignment. Both students need to submit his/her
assignment to canvas. I might randomly pick students to ask you give me a demo and
explain how your code works.
4. Make sure your code is free of compile errors. A project with compile errors in it will earn
you a very low grade.
5. Follow the Java style guide (Files/ASSIGNMENTS/JavaStyleGuide.pdf) and comment
your code whenever necessary.
6. Refer to (Files/AQuickGuide2Eclipse.pdf) for how to import an existing project into
Eclipse, how to open a workspace, etc.
Academic Honesty:
Your code must be your own. Any format of sharing code is not allowed and is considered
plagiarism.


CS202 Final Project—Spelling Bee (group assignment)
Due: 11:59pm 06/30/2023(Friday)
No late submission is accepted.
Assignment
Follow the instructions in the assignment PDF file at the following link:
http://nifty.stanford.edu/2022/eroberts-spelling-bee-wordle/SpellingBee/java/SpellingBeeAssignment.pdf
Please read the PDF file carefully and let me know if you have any questions.
The assignment starter Java file is: Final_SpellingBee.zip. (This is a zipped Eclipse project folder
containing the starter code. You can import it to an Eclipse workspace and add code to it.)
Grading
To receive 100 on this assignment, you need to complete the first 3 milestones from the
assignment that you can find on pages 5 and 6 in the above-mentioned
SpellingBeeAssignment.pdf file.
Milestone 1 is worth 40 points, Milestone 2 is worth 30 points, and Milestone 3 is also worth 30
points.
Milestone 1 points:
• The letters appear on the screen when the user presses ENTER (10 points).
• The condition of "The puzzle must contain exactly seven characters" is met (10 points).
• The condition of "Every character must be one of the 26 letters" is met (10 points).
• The condition of "No letter may appear more than once in the puzzle" is met (10 points).
Milestone 2 points:
• The condition of "The word is at least four letters long" is met (10 points).
• The condition of "The word does not contain any letters other than the seven letters in the
puzzle" is met (10 points).
• The condition of "The word contains the center letter, which appears at the start of the
puzzle string" is met (10 points).
Milestone 3 points:
• Scoring is implemented (10 points).
• Pangram is implemented. Make sure that you use Color.BLUE to make the pangram
word stand out in blue color (10 points).
• Both "the number of words found" and "the total score" are shown on the screen (10
points).
Bonus
If you complete the 4th milestone (see page 6 of the SpellingBeeAssignment.pdf file), you will
receive 30 bonus points in addition to your 100 points for this assignment.
Submission
1. Please upload your zipped Eclipse project folder that you completed, based on the
provided starter code.
2. A pdf or docx file containing screenshots of your running results. Specifically, show a few
test cases for all the milestones that you completed. In your screenshots, create your own
spelling bee problems, instead of using the example ones in the PDF file.
3. Each group can have at most two students. If you work with another student in a
group, submit a README.docx or README.txt containing both students’ names
and a description of each student’s work in this assignment. Both students need to
submit his/her assignment to canvas. I might randomly pick students to ask you give me
a demo and explain how your code works.
4. Make sure your code is free of compile errors. A project with compile errors in it will earn
you a very low grade.
5. Follow the Java style guide (Files/ASSIGNMENTS/JavaStyleGuide.pdf) and comment
your code whenever necessary.
6. Refer to (Files/AQuickGuide2Eclipse.pdf) for how to import an existing project into
Eclipse, how to open a workspace, etc.
Academic Honesty:
Your code must be your own. Any format of sharing code is not allowed and is considered
plagiarism.

 WX:codehelp

标签:10,code,assignment,Challenge,Caesar,letter,CS202,your,points
From: https://www.cnblogs.com/javanew/p/17520823.html

相关文章

  • buaa os lab4-challenge 信号系统的实现
    buaaoslab4-challenge信号系统的实现信号是什么生活中我们会收到各种各样的信号,比如老师在群里布置了一个新的ddl,或者肚子发出咕咕的叫声提醒我们该吃饭了,接收到信号之后我们并不是马上处理,需要等到一些合适的时机并前横利弊,比如对于人来说肯定是吃饭重要,所以我们会忽略ddl......
  • hihoCoder Challenge 28 异或问题 思维
    Givenasequencea[1..n],youneedtocalculatehowmanyintegersSsatisfythefollowingconditions:(1).0≤S<260(2).Foreveryiin[1,n-1],(a[i]xorS)≤(a[i+1]xorS)InputOnthefirstlinethereisonlyoneintegernOnthesecondlinethere......
  • Caesar一个全新的敏感文件发现工具
    https://github.com/0ps/Caesar 一 支持主流平台:得益于golang的跨平台优势。一次编译,到处运行。二 强大的并发:golang的并发独树一帜。12线程下能实现每秒千级请求。为了安全性,默认只设置了3线程。三 路径记忆功能:Caesar可以记忆路径的击中次数,下次运行的时候,击中次......
  • codeforces 118D D. Caesar's Legions(dp)
    题目链接:codeforces118D题目大意:给出n1个1,n2个2,给出k1和k2代表连续的1和2的最大长度,问能够构造的合法的不同串的数量。题目分析:能够递推,所以想到能够利用dp做。首先我们定义状态,dp[i][j][k][2]代表以1或2结尾,结尾相同的元素的数量为k,1的总数是j的当前序列长度为i的串的数量。首先......
  • YACS2022年10月乙组
    T1:录制节目可以将原题转化成有\(n\)条线段,可以保留若干条线段,并且可以分成两部分,使得每部分的线段互不相交先将所有线段按右端点做升序排序,且按左端点做降序排序然后维护两个变量last1和last2last1:第一个部分的最后的端点last2:第二个部分的最后的端点尽量让\(\min(......
  • 02.Deep Reinforcement Learning for Quantitative Trading Challenges and Opportuni
    DeepReinforcementLearningforQuantitativeTradingChallengesandOpportunities量化交易的深度强化学习:挑战与机遇---IEEE背景量化交易:量化交易是指借助现代统......
  • YACS2023年2月乙组
    T3:最大子集本题是01背包的变种题记dp[i]表示选到的奶牛的智商总和为\(i\)时对应的情商总和的最大值这里由于\(x\)可能是负数,所以需要将\(i\)向后偏移\(3e5\)......
  • YACS2023年2月丙组
    T1:格式改写代码实现s=input()cnt=0forcins:ifc.isupper():cnt+=1ans=min(cnt,len(s)-cnt)print(ans)T2:倍数统计代码实......
  • Identity and Access Management Challenges in Contemporary IoT Ecosystems
    Didyouknow?By2030,thenumberofIoTdevicesworldwideisexpectedtoswellfrom7.6billionto24.1billion.Thisundeniablypaintsapictureofthefutur......
  • XSS Challenges
    XSS挑战(由yamagata21)-阶段#1(int21h.jp)题目要求注入JavaScript命令:alert(document.domain);Stage#1输入321来定位代码的位置,发现是处于<b></b>标签之内,没有......