You are not logged in.
I want to ask you something: Can I choose both players from a same match in problem 1? For example, is {A,B,C,D,E} a valid combination in problem 1?
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
I'm geting this for problem 2.
data Player = Player Char Int
instance Show Player where
show (Player name _) = show [name]
players = cutinto2 $ zipWith Player ['A'..'T'] [91,109,104,95,79,120,86,114,106,94,
80,118,75,127,103,97,107,93,94,105]
choose :: [b] -> Int -> [[b]]
_ `choose` 0 = [[]]
[] `choose` _ = []
(x:xs) `choose` k = (x:) `fmap` (xs `choose` (k-1)) ++ xs `choose` k
cutinto2 :: [b] -> [[b]]
cutinto2 [x,y] = [[x,y]]
cutinto2 (x:y:xs) = [[x,y]] ++ cutinto2 xs
value (Player _ x) = x
combies = foldr (++) [] (sequence `map` choose players 5)
main = print $ filter (\p -> sum(map value p) <= 500) combies
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
Well, you never specified that you don't want the two letters that are grouped together to both appear in a combination.
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Hello,
You didn't mention all the constraints, please do that.
Offline
I'm using this principle to solve the second problem:
a. Generate a list of five matches.
b. Map a cartesian product over each set of five matches.
c. Check if the result is <= 500
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
He didn't mention that some can't be included in the 5.
Last edited by ElainaVW (2015-01-17 15:47:23)
Offline
I'm using this principle to solve the second problem:
a. Generate a list of five matches.
b. Map a cartesian product over each set of five matches.
c. Check if the result is <= 500
Won't you just get 25 ordered pairs?
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Problem:
There are 10 matches (A vs B, C vs D, E vs F, etc.).
Only one player from each match can be used.
5 players must be picked.
The total combined cost of the 5 picked, must be less that or equal to 500.
All combinations over 500 are not important.I need to be able to generate a list of combinations, that fit this criteria, along with associated prices.
I'm sorry I thought i did list that in the problem, here is what I wrote before. I thought I wrote that in the second line.
Edit: I see that I added this to the second problem and forgot to mention it in the first set. I apologize for not including that information.
Last edited by NickMeyers (2015-01-17 16:01:12)
Offline
Okay I see what you want now.
Offline
I want to ask you something: Can I choose both players from a same match in problem 1? For example, is {A,B,C,D,E} a valid combination in problem 1?
In problem one I forgot to add that constraint, I meant to say that only one player from each match could be used, sorry for leaving that out.
Offline
Okay I see what you want now.
Thanks Elaina! Sorry for not addressing that earlier
Offline
Which problem do you want solved?
Offline
The answer to question 1 with the new constraints is 4957
Here are the combinations:
Link
Last edited by Agnishom (2015-01-17 16:38:34)
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
Problem:
There are 10 matches (A vs B, C vs D, E vs F, etc.).
Only one player from each match can be used.
5 players must be picked.
The total combined cost of the 5 picked, must be less that or equal to 500.
All combinations over 500 are not important.I need to be able to generate a list of combinations, that fit this criteria, along with associated prices.
Data Set:
Match Cost
1 A 91
B 1092 C 104
D 95
3 E 79
F 1204 G 86
H 1145 I 106
J 94
6 K 80
L 118
7 M 75
N 127
8 O 103
P 97
9 Q 107
R 93
10 S 94
T 105
This one is the one I was looking to solve
Offline
I suppose post 27 already solves that problem.
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
Edit: I didn't see the the word this was a hyperlink. Thank you!! What was the total number?
The answer to question 1 with the new constraints is 4957
Here are the combinations:
Link
This is fantastic, can this be done with the second problem with the new constraints?
Problem:
There are 10 matches (A vs B, C vs D, E vs F, etc.).
Only one player from each match can be used.
5 players must be picked.
The total combined cost of the 5 picked, must be less that or equal to 500.
All combinations over 500 are not important.I need to be able to generate a list of combinations, that fit this criteria, along with associated prices.
Data Set:
Match Cost
1 A 91
B 1092 C 104
D 95
3 E 79
F 1204 G 86
H 1145 I 106
J 94
6 K 80
L 118
7 M 75
N 127
8 O 103
P 97
9 Q 107
R 93
10 S 94
T 105
Last edited by NickMeyers (2015-01-17 16:50:10)
Offline
I will count(not manually, of course) and tell you in around 5 minutes.
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
I believe you posted that is was 4166 earlier? Is that correct?
Thanks again!
Offline
Oh, yes. It is 4166.
Can you please check around 10 random cases from the text file I gave you to be sure if that is what you want?
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
Stefy is also getting the same result! yay!
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
I think you got it!! I am looking though it and not seeing any conflicts.
Thank you all so much!!!
Offline
4166 is correct.
Offline
Thank you Elaina!
Offline
Checking 10 random cases isn't very likely to spot an error.
Offline
True but checking more than 10 random cases is likely to be tedious.
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline