summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--day1/exercise/collatz.py6
-rw-r--r--day1/exercise/datestring.py5
-rw-r--r--day1/exercise/duplicate_marks.py11
3 files changed, 12 insertions, 10 deletions
diff --git a/day1/exercise/collatz.py b/day1/exercise/collatz.py
index 7bed967..3ace3ac 100644
--- a/day1/exercise/collatz.py
+++ b/day1/exercise/collatz.py
@@ -1,10 +1,8 @@
a = int( raw_input( 'Enter number: ') )
while a != 4:
- print a
+ print a,
if a % 2 == 1:
a = a * 3 + 1
else:
a /= 2
-print 4
-print 2
-print 1
+print 4, 2, 1
diff --git a/day1/exercise/datestring.py b/day1/exercise/datestring.py
index 4e8cad4..5a9c50f 100644
--- a/day1/exercise/datestring.py
+++ b/day1/exercise/datestring.py
@@ -1,6 +1,5 @@
-month2mm = { 'JAN': 1, 'FEB': 2, 'MAR': 3, 'APR': 4, 'MAY': 5,
-'JUN': 6, 'JUL': 7, 'AUG': 8, 'SEP': 9, 'OCT': 10, 'NOV': 11,
-'DEC': 12 }
+month2mm = { 'JAN': 1, 'FEB': 2, 'MAR': 3, 'APR': 4, 'MAY': 5, 'JUN': 6,
+'JUL': 7, 'AUG': 8, 'SEP': 9, 'OCT': 10, 'NOV': 11, 'DEC': 12 }
COMMA = ','
SPACE = ' '
diff --git a/day1/exercise/duplicate_marks.py b/day1/exercise/duplicate_marks.py
index ce4cbca..8ad85d1 100644
--- a/day1/exercise/duplicate_marks.py
+++ b/day1/exercise/duplicate_marks.py
@@ -1,13 +1,18 @@
students = {
- 'Madhu': 12,
+ 'Madhu': 45,
'Shantanu':45,
'Puneeth': 54,
'Vattam': 35,
- 'KD': 50,
+ 'KD': 54,
+ 'Asokan': 45
}
all_marks = students.values()
unique_marks = set(all_marks)
print "Number of Duplicate marks: ", len(all_marks) - len(unique_marks)
-print "Duplicate marks: ", set(all_marks - list(unique_marks))
+
+for i in unique_marks:
+ all_marks.remove(i)
+
+print "Duplicate marks:", set(all_marks)