Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
June 6th, 2013, 08:07 AM
 Filip.V
Registered User

Join Date: May 2013
Posts: 19
Time spent in forums: 2 h 8 m
Reputation Power: 0
Compare 2 groups of numbers

This is my last question.

With calculations I have made 192 numbers (num1 to num192)
Their value can be anything,also negative and also doubles.
example:
num1=-1O
num2=23

The second row are 60 numbers (number1 to number60)
Their value is 1 to 60
example:
number1=1
number2=2
number60=60

From the 60 numbers I want to delete every number that is the same number as in the 192.

#2
June 6th, 2013, 10:34 AM
 Akshat1
Contributing User

Join Date: Feb 2013
Posts: 92
Time spent in forums: 22 h 38 m 33 sec
Reputation Power: 1
Started working on this one.

#3
June 6th, 2013, 10:37 AM
 rrashkin
Contributing User

Join Date: May 2012
Location: 39N 104.28W
Posts: 141
Time spent in forums: 2 Days 47 m 39 sec
Reputation Power: 2
take a look at sets, specifically the intersection method.

#4
June 6th, 2013, 12:32 PM
 Filip.V
Registered User

Join Date: May 2013
Posts: 19
Time spent in forums: 2 h 8 m
Reputation Power: 0
That was a very good solution Akshat1,Thank you.

#5
June 6th, 2013, 12:36 PM
 Filip.V
Registered User

Join Date: May 2013
Posts: 19
Time spent in forums: 2 h 8 m
Reputation Power: 0
Thanks

#6
June 7th, 2013, 02:29 AM
 Filip.V
Registered User

Join Date: May 2013
Posts: 19
Time spent in forums: 2 h 8 m
Reputation Power: 0
For the first row of 192 numbers maybe I must eliminate the negatives and doubles in it.
Also eliminate the numbers lower than 1 and higher dan 60.
And fill it up with value 0 for numbers not in that list.
Then the first row can be 60 numbers to compare with the other 60.

#7
June 9th, 2013, 02:16 PM
 Filip.V
Registered User

Join Date: May 2013
Posts: 19
Time spent in forums: 2 h 8 m
Reputation Power: 0
I think this is the solution.
I must try it with 192 numbers

num1=1
num2=2
num3=3
num4=5
num5=3
num6=6

number1=2
number2=5
number3=6

t = [num1, num2, num3, num4, num5 ,num6]
s = [number1, number2, number3]

print list(set(t) - set(s))

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Compare 2 groups of numbers