From ce9b2aaf8e869c63c538ef9e91624bcbff0236bd Mon Sep 17 00:00:00 2001 From: Benjamin Holland Date: Fri, 28 Apr 2017 09:31:22 -0700 Subject: [PATCH] Fixed #270 --- assets/questions/reverseWords.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/assets/questions/reverseWords.js b/assets/questions/reverseWords.js index d20ffe04..bfa8eb7f 100644 --- a/assets/questions/reverseWords.js +++ b/assets/questions/reverseWords.js @@ -27,6 +27,14 @@ globalData.questions['reverseWords'] = { // eslint-disable-line dot-notation auxiliaryCode: { python: `class AuxiliaryCode(object): + @classmethod + def reverseString(cls, s): + return str(s[::-1]) + + @classmethod + def reverseWordOrder(cls, s): + return s.split(' ')[::-1] + @classmethod def forgetLastWord(cls, s): result = "" @@ -88,6 +96,23 @@ globalData.questions['reverseWords'] = { // eslint-disable-line dot-notation "last reversed word." ].join('') ] + }, { + buggyFunctionName: 'AuxiliaryCode.reverseString', + messages: [ + "Read the instructions closely. Did you overlook something important?", + [ + "It looks like you're reversing the entire string instead of each word. " + ].join('') + ] + }, { + buggyFunctionName: 'AuxiliaryCode.reverseWordOrder', + messages: [ + "Are you sure you're interpreting the instructions correctly?", + [ + "It looks like you're reversing the order of the words instead of their ", + "contents. Is this what you were asked to do?" + ].join('') + ] }], performanceTests: [] }, {