SlideShare uma empresa Scribd logo
1 de 4
Baixar para ler offline
WEEK
TWO
Problems for Week 2
Here are the second week’s problems for the NCSS Challenge 2009! This is the first set of problems that will
count towards your overall score in the Challenge.
This is the printable (PDF) version. You will need to login to submit solutions to each problem:
http://challenge.ncss.edu.au/accounts/profile/
Our scoring system is simple: each question is worth 10 points. If you submit a solution that passes all of our
tests the first time you submit, you’ll get the full 10 points.
You can submit multiple times. No points will be deducted for the first four incorrect submissions, but on your 5th
incorrect submission for a single problem, one point will be deducted from your possible score for that problem.
Another point will be deducted on your 10th incorrect submission, and so on. It doesn’t hurt to try a problem --
if you submit a few times but don’t pass all of the tests, the points you have scored for other problems will not
be affected.
Good luck!
1 Better Biscuits for your Bucks
You have joined a startup that is about to go public with a new iPhone application. This application, called better
biscuits for their bucks, is going to help shoppers everywhere by comparing the value for money of two packets
of biscuits.
Your program should read four lines of input using raw_input. There are two lines for each packet of biscuits.
The first line is the cost of packet 1 of biscuits (as a float). The second line is the number of biscuits in packet 1
(as an integer). The third line is the cost of packet 2, and the fourth line is the number of biscuits in packet 2.
Output the packet that is the best value, that is, the packet with the lower price per biscuit. If packet 1 is better
value, your program should print:
packet 1
For example, if the first packet has 17 biscuits and costs $5.50 and the second packet has only 3 biscuits and costs
$4, then obviously the careful shopper will purchase the first packet.
The interaction with your program might look like this:
Cost of packet 1? 5.5
Biscuits in packet 1? 17
Cost of packet 2? 4
Biscuits in packet 2? 3
packet 1
If two packets provide equal value for money, then your program should output:
packet 1 or 2
Of course in this case, we would consider the appropriate course of action to be to purchase both packets (more
biscuits, you see), but we’ll leave that up to the shopper.
c National Computer Science School 2005-2009 1
NCSS Challenge (Beginners) WEEK TWO
Hint
We’re only going to test the output of your program — not anything you pass as the prompt for raw_input.
2 Pirate line counter
Pirate Bob still can’t speak correctly! His shipmates are starting to worry about other pirates stealing the buried
treasure, and so need to find someone who can understand what he’s saying. The key to understanding him might
be the rolling r at the end of his words, and want to find one of their fellow pirates who rolls their r’s a lot too, to
figure out what Bob’s saying.
Your task is to help them count how many lines contain a double lowercase r in different lines of text. The rr
can occur anywhere within a line, but the two r’s have to be next to each other with nothing else in between. You
will need to read in any number of lines of input (up to a blank line), and output the number of lines which have
at least one ’rr’ in them.
So for example, for the input
Yarr Har
the output would be
1
But for the input
Ahoy m’hearties
Yo ho ho and a bottle of rrrrum
Tharrrr be th’ treasure
The output would be
2
3 lerCrypto scramb
Secret Agent No. 86 is really impressed with the new cipher he’s come up with, for disguising secret messages
between covert operatives. It works by removing the last letter of a line, and adding that letter to the front of the
line instead. So the line:
Meet me on the bridge
Is cunningly disguised as:
eMeet me on the brid
Unfortunately, Agent 86’s boss (The Chief) wasn’t quite so impressed. He says Agent 86 needs to come up with
a cipher that obeys Kerckhoffs’ Principle: a cryptosystem should still be secure even if everything about the
system, except the key, is public knowledge. That is, his cipher should involve some kind of key so that even if
the enemy agents know how his cipher works, they can’t decipher it without also knowing the key.
After quite a lot of thought Agent 86 came up with the following improvement. The key will be an integer, say
n, and his new cipher will be the old one repeated n times.
For example, he can encrypt the message above using the key 3 by first writing:
eMeet me on the bridg
c National Computer Science School 2005-2009 2
NCSS Challenge (Beginners) WEEK TWO
Then:
geMeet me on the brid
and finally:
dgeMeet me on the bri
This takes a fair bit longer than the old cipher, so your task is to write a program to automate this. It will read
in multiple lines of input. The first line will be the key (an integer), and then after that will be the message to
encript (the plaintext), possibly spread over multiple lines. You need to print out the encrypted plaintext.
For example, given the input:
1
Meet me on the bridge
beware
pigeons
Your program should print out:
eMeet me on the bridg
ebewar
spigeon
4 Find the odd one out
Please help me debug this program! I’m having trouble with my logic skills.
I trying to write a program to do something very simple: I have to read in three lines and find the odd one out. I
know that two of the three lines will always be the same and the other one different. I want to print out only the
one that is different.
For example, if the input was:
Row, row, row your boat
Gently down the stream
Row, row, row your boat
It should print:
Gently down the stream
As another example, if the input was:
Row, row, row your boat
Gently down the stream
Gently down the stream
It should print:
Row, row, row your boat
Here is some code I wrote that I thought would do it, but it isn’t working. Can you please fix it for me?
c National Computer Science School 2005-2009 3
NCSS Challenge (Beginners) WEEK TWO
line1 = raw_input()
line2 = raw_input()
line3 = raw_input()
if line1 != line3:
if line2 != line3:
print line3
else:
if line1 = line3:
print line2
else:
print ’line1’
Hint
Start by downloading the file from here and trying to run it!
5 encrypt.reverse()
The following program uses a fairly simple set of transformations to encrypt its input (the plaintext), which is a
single line consisting of lower case letters and punctuation.
line = raw_input(’Enter the plaintext’)
line = line.replace(’o’, ’E’)
line = line.replace(’e’, ’O’)
line = line.replace(’ray’, ’YAR’)
line = line.replace(’yar’, ’RAY’)
split = len(line)/2
line = line[split:] + line[:split]
print line.upper()
Submit a program to read the output of this program, decrypt it and print out the original plaintext again.
Hint
Try running the program with various inputs. When you have written a solution, test it by running some inputs
through this program, then running the result through your code to make sure it gives the original back again.
c National Computer Science School 2005-2009 4

Mais conteúdo relacionado

Mais de hccit

Snr ipt 10_syll
Snr ipt 10_syllSnr ipt 10_syll
Snr ipt 10_syllhccit
 
Snr ipt 10_guide
Snr ipt 10_guideSnr ipt 10_guide
Snr ipt 10_guidehccit
 
3 d modelling_task_sheet_2014_yr11
3 d modelling_task_sheet_2014_yr113 d modelling_task_sheet_2014_yr11
3 d modelling_task_sheet_2014_yr11hccit
 
10 ict photoshop_proj_2014
10 ict photoshop_proj_201410 ict photoshop_proj_2014
10 ict photoshop_proj_2014hccit
 
Photoshop
PhotoshopPhotoshop
Photoshophccit
 
Flash
FlashFlash
Flashhccit
 
Griffith sciences pathway programs overview
Griffith sciences pathway programs overviewGriffith sciences pathway programs overview
Griffith sciences pathway programs overviewhccit
 
Griffith info tech brochure
Griffith info tech brochureGriffith info tech brochure
Griffith info tech brochurehccit
 
Pm sql exercises
Pm sql exercisesPm sql exercises
Pm sql exerciseshccit
 
Repairs questions
Repairs questionsRepairs questions
Repairs questionshccit
 
Movies questions
Movies questionsMovies questions
Movies questionshccit
 
Australian birds questions
Australian birds questionsAustralian birds questions
Australian birds questionshccit
 
Section b
Section bSection b
Section bhccit
 
Section a
Section aSection a
Section ahccit
 
Ask manual rev5
Ask manual rev5Ask manual rev5
Ask manual rev5hccit
 
Case study report mj
Case study report mjCase study report mj
Case study report mjhccit
 
Mj example case_study_layout_intro_completedq
Mj example case_study_layout_intro_completedqMj example case_study_layout_intro_completedq
Mj example case_study_layout_intro_completedqhccit
 
Case study plan mj
Case study plan mjCase study plan mj
Case study plan mjhccit
 

Mais de hccit (20)

Snr ipt 10_syll
Snr ipt 10_syllSnr ipt 10_syll
Snr ipt 10_syll
 
Snr ipt 10_guide
Snr ipt 10_guideSnr ipt 10_guide
Snr ipt 10_guide
 
3 d modelling_task_sheet_2014_yr11
3 d modelling_task_sheet_2014_yr113 d modelling_task_sheet_2014_yr11
3 d modelling_task_sheet_2014_yr11
 
10 ict photoshop_proj_2014
10 ict photoshop_proj_201410 ict photoshop_proj_2014
10 ict photoshop_proj_2014
 
Photoshop
PhotoshopPhotoshop
Photoshop
 
Flash
FlashFlash
Flash
 
Griffith sciences pathway programs overview
Griffith sciences pathway programs overviewGriffith sciences pathway programs overview
Griffith sciences pathway programs overview
 
Griffith info tech brochure
Griffith info tech brochureGriffith info tech brochure
Griffith info tech brochure
 
Pm sql exercises
Pm sql exercisesPm sql exercises
Pm sql exercises
 
Repairs questions
Repairs questionsRepairs questions
Repairs questions
 
Movies questions
Movies questionsMovies questions
Movies questions
 
Australian birds questions
Australian birds questionsAustralian birds questions
Australian birds questions
 
Section b
Section bSection b
Section b
 
B
BB
B
 
A
AA
A
 
Section a
Section aSection a
Section a
 
Ask manual rev5
Ask manual rev5Ask manual rev5
Ask manual rev5
 
Case study report mj
Case study report mjCase study report mj
Case study report mj
 
Mj example case_study_layout_intro_completedq
Mj example case_study_layout_intro_completedqMj example case_study_layout_intro_completedq
Mj example case_study_layout_intro_completedq
 
Case study plan mj
Case study plan mjCase study plan mj
Case study plan mj
 

Último

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Questions2

  • 1. WEEK TWO Problems for Week 2 Here are the second week’s problems for the NCSS Challenge 2009! This is the first set of problems that will count towards your overall score in the Challenge. This is the printable (PDF) version. You will need to login to submit solutions to each problem: http://challenge.ncss.edu.au/accounts/profile/ Our scoring system is simple: each question is worth 10 points. If you submit a solution that passes all of our tests the first time you submit, you’ll get the full 10 points. You can submit multiple times. No points will be deducted for the first four incorrect submissions, but on your 5th incorrect submission for a single problem, one point will be deducted from your possible score for that problem. Another point will be deducted on your 10th incorrect submission, and so on. It doesn’t hurt to try a problem -- if you submit a few times but don’t pass all of the tests, the points you have scored for other problems will not be affected. Good luck! 1 Better Biscuits for your Bucks You have joined a startup that is about to go public with a new iPhone application. This application, called better biscuits for their bucks, is going to help shoppers everywhere by comparing the value for money of two packets of biscuits. Your program should read four lines of input using raw_input. There are two lines for each packet of biscuits. The first line is the cost of packet 1 of biscuits (as a float). The second line is the number of biscuits in packet 1 (as an integer). The third line is the cost of packet 2, and the fourth line is the number of biscuits in packet 2. Output the packet that is the best value, that is, the packet with the lower price per biscuit. If packet 1 is better value, your program should print: packet 1 For example, if the first packet has 17 biscuits and costs $5.50 and the second packet has only 3 biscuits and costs $4, then obviously the careful shopper will purchase the first packet. The interaction with your program might look like this: Cost of packet 1? 5.5 Biscuits in packet 1? 17 Cost of packet 2? 4 Biscuits in packet 2? 3 packet 1 If two packets provide equal value for money, then your program should output: packet 1 or 2 Of course in this case, we would consider the appropriate course of action to be to purchase both packets (more biscuits, you see), but we’ll leave that up to the shopper. c National Computer Science School 2005-2009 1
  • 2. NCSS Challenge (Beginners) WEEK TWO Hint We’re only going to test the output of your program — not anything you pass as the prompt for raw_input. 2 Pirate line counter Pirate Bob still can’t speak correctly! His shipmates are starting to worry about other pirates stealing the buried treasure, and so need to find someone who can understand what he’s saying. The key to understanding him might be the rolling r at the end of his words, and want to find one of their fellow pirates who rolls their r’s a lot too, to figure out what Bob’s saying. Your task is to help them count how many lines contain a double lowercase r in different lines of text. The rr can occur anywhere within a line, but the two r’s have to be next to each other with nothing else in between. You will need to read in any number of lines of input (up to a blank line), and output the number of lines which have at least one ’rr’ in them. So for example, for the input Yarr Har the output would be 1 But for the input Ahoy m’hearties Yo ho ho and a bottle of rrrrum Tharrrr be th’ treasure The output would be 2 3 lerCrypto scramb Secret Agent No. 86 is really impressed with the new cipher he’s come up with, for disguising secret messages between covert operatives. It works by removing the last letter of a line, and adding that letter to the front of the line instead. So the line: Meet me on the bridge Is cunningly disguised as: eMeet me on the brid Unfortunately, Agent 86’s boss (The Chief) wasn’t quite so impressed. He says Agent 86 needs to come up with a cipher that obeys Kerckhoffs’ Principle: a cryptosystem should still be secure even if everything about the system, except the key, is public knowledge. That is, his cipher should involve some kind of key so that even if the enemy agents know how his cipher works, they can’t decipher it without also knowing the key. After quite a lot of thought Agent 86 came up with the following improvement. The key will be an integer, say n, and his new cipher will be the old one repeated n times. For example, he can encrypt the message above using the key 3 by first writing: eMeet me on the bridg c National Computer Science School 2005-2009 2
  • 3. NCSS Challenge (Beginners) WEEK TWO Then: geMeet me on the brid and finally: dgeMeet me on the bri This takes a fair bit longer than the old cipher, so your task is to write a program to automate this. It will read in multiple lines of input. The first line will be the key (an integer), and then after that will be the message to encript (the plaintext), possibly spread over multiple lines. You need to print out the encrypted plaintext. For example, given the input: 1 Meet me on the bridge beware pigeons Your program should print out: eMeet me on the bridg ebewar spigeon 4 Find the odd one out Please help me debug this program! I’m having trouble with my logic skills. I trying to write a program to do something very simple: I have to read in three lines and find the odd one out. I know that two of the three lines will always be the same and the other one different. I want to print out only the one that is different. For example, if the input was: Row, row, row your boat Gently down the stream Row, row, row your boat It should print: Gently down the stream As another example, if the input was: Row, row, row your boat Gently down the stream Gently down the stream It should print: Row, row, row your boat Here is some code I wrote that I thought would do it, but it isn’t working. Can you please fix it for me? c National Computer Science School 2005-2009 3
  • 4. NCSS Challenge (Beginners) WEEK TWO line1 = raw_input() line2 = raw_input() line3 = raw_input() if line1 != line3: if line2 != line3: print line3 else: if line1 = line3: print line2 else: print ’line1’ Hint Start by downloading the file from here and trying to run it! 5 encrypt.reverse() The following program uses a fairly simple set of transformations to encrypt its input (the plaintext), which is a single line consisting of lower case letters and punctuation. line = raw_input(’Enter the plaintext’) line = line.replace(’o’, ’E’) line = line.replace(’e’, ’O’) line = line.replace(’ray’, ’YAR’) line = line.replace(’yar’, ’RAY’) split = len(line)/2 line = line[split:] + line[:split] print line.upper() Submit a program to read the output of this program, decrypt it and print out the original plaintext again. Hint Try running the program with various inputs. When you have written a solution, test it by running some inputs through this program, then running the result through your code to make sure it gives the original back again. c National Computer Science School 2005-2009 4