From 8204ad3281a77c10c0172a974d60097ae7a2001e Mon Sep 17 00:00:00 2001 From: Steve Newbury Date: Wed, 17 Sep 2014 15:20:20 +0100 Subject: [PATCH 1/3] Create stevenewbs entry for competition 7 --- Challenge_7/stevenewbs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Challenge_7/stevenewbs diff --git a/Challenge_7/stevenewbs b/Challenge_7/stevenewbs new file mode 100644 index 0000000..eb8b151 --- /dev/null +++ b/Challenge_7/stevenewbs @@ -0,0 +1,34 @@ +""" + The MIT License (MIT) + +Copyright (c) 2014 Steve Newbury + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + +# This matches the numeral representation from the challenge code in the mag + +m=[('M',1000),('C M',900),('D',500),('C D',400),('C',100),('X C',90),('L',50),('X L',40),('X',10),('I X',9),('V',5),('I V',4),('I',1)] +n=int(raw_input("Num: ")) +while n>0: + for s,v in m: + if n-v >= 0: + print s, + n-=v + break From 2f4277d1ab0e62750ae39a884851eef8fba1c821 Mon Sep 17 00:00:00 2001 From: Steve Newbury Date: Wed, 17 Sep 2014 15:21:57 +0100 Subject: [PATCH 2/3] Fix indenting --- Challenge_7/stevenewbs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Challenge_7/stevenewbs b/Challenge_7/stevenewbs index eb8b151..4ede977 100644 --- a/Challenge_7/stevenewbs +++ b/Challenge_7/stevenewbs @@ -27,8 +27,8 @@ THE SOFTWARE. m=[('M',1000),('C M',900),('D',500),('C D',400),('C',100),('X C',90),('L',50),('X L',40),('X',10),('I X',9),('V',5),('I V',4),('I',1)] n=int(raw_input("Num: ")) while n>0: - for s,v in m: - if n-v >= 0: - print s, - n-=v - break + for s,v in m: + if n-v >= 0: + print s, + n-=v + break From cf07d79425a01c53c2c43e13fbd87f8af7bc71a6 Mon Sep 17 00:00:00 2001 From: Steve Newbury Date: Thu, 18 Sep 2014 10:07:24 +0100 Subject: [PATCH 3/3] Break vs continue for numeral representation The challenge code shows 20 = X I X I Where as mine shows 20 = X X Changing the break for a continue gives you this difference --- Challenge_7/stevenewbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Challenge_7/stevenewbs b/Challenge_7/stevenewbs index 4ede977..4e22b36 100644 --- a/Challenge_7/stevenewbs +++ b/Challenge_7/stevenewbs @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -# This matches the numeral representation from the challenge code in the mag +# This matches the numeral representation from the challenge code in the mag if you change the "break" to "continue" m=[('M',1000),('C M',900),('D',500),('C D',400),('C',100),('X C',90),('L',50),('X L',40),('X',10),('I X',9),('V',5),('I V',4),('I',1)] n=int(raw_input("Num: "))