File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727 " logic"
2828 ]
2929 },
30+ {
31+ "uuid" : " d39f86fe-db56-461c-8a93-d87058af8366" ,
32+ "slug" : " reverse-string" ,
33+ "core" : false ,
34+ "unlocked_by" : null ,
35+ "difficulty" : 1 ,
36+ "topics" : [
37+ " strings"
38+ ]
39+ },
3040 {
3141 "uuid" : " d1a98c79-d3cc-4035-baab-0e334d2b6a57" ,
3242 "slug" : " isogram" ,
Original file line number Diff line number Diff line change 1+ # Reverse String
2+ Reverse a string
3+
4+ For example:
5+ input: "cool"
6+ output: "looc"
7+
8+ ## Submitting Incomplete Solutions
9+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
Original file line number Diff line number Diff line change 1+ def reverse (input = '' ):
2+ return input [::- 1 ]
Original file line number Diff line number Diff line change 1+ def reverse (input = '' ):
2+ pass
Original file line number Diff line number Diff line change 1+ import unittest
2+
3+ from reverse_string import reverse
4+
5+
6+ # Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1
7+
8+ class ReverseStringTests (unittest .TestCase ):
9+ def empty_string (self ):
10+ self .assertEqual (reverse ('' ), '' )
11+
12+ def a_word (self ):
13+ self .assertEqual (reverse ('robot' ), 'tobor' )
14+
15+ def a_capitalized_word (self ):
16+ self .assertEqual (reverse ('Ramen' ), 'nemaR' )
17+
18+ def a_sentence_with_punctuation (self ):
19+ self .assertEqual (reverse ('I\' m hungry!' ), '!yrgnuh m\' I' )
20+
21+ def a_palindrome (self ):
22+ self .assertEqual (reverse ('racecar' ), 'racecar' )
23+
24+
25+ if __name__ == '__main__' :
26+ unittest .main ()
You can’t perform that action at this time.
0 commit comments