Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#51 2015-01-18 05:11:24

ElainaVW
Member
Registered: 2013-04-29
Posts: 580

Re: Combination Problem

Then why not save time and not check any?

Offline

#52 2015-01-18 12:47:17

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

Exactly.

I di not cehck any. I became mean and decided to waste his time instead of mine


'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

#53 2015-01-18 16:19:38

ElainaVW
Member
Registered: 2013-04-29
Posts: 580

Re: Combination Problem

Immobile computers can't become mean.

Offline

#54 2015-01-18 19:33:01

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

Actually they are very mean.


'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

#55 2015-01-19 05:19:14

ElainaVW
Member
Registered: 2013-04-29
Posts: 580

Re: Combination Problem

How so?

Offline

#56 2015-01-19 12:41:54

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

I stole 200 MB of data last friday


'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

#57 2015-01-19 14:37:51

ElainaVW
Member
Registered: 2013-04-29
Posts: 580

Re: Combination Problem

Sure you want to admit that?

Hello Nick,

Are we done with this problem or do you need more?

Last edited by ElainaVW (2015-01-19 14:53:32)

Offline

#58 2015-01-19 20:17:35

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

That's just between you and I.


'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

#59 2015-01-20 11:09:35

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

Hello there! Yes I do need another one if you are willing to help Elaina!  I am going to try out the Mathematica program later this week so I can try to figure these out with out bugging you.  I really appreciate the help!!!

The way you posted the results in post #15 was really helpful and was the best format to use and read because I could see all the numbers! If possible could you do the same for the next problem?  I hope by next week I will have the time to go through some tutorials and get familiar with the program. Which may lead me to more questions, but I hope it won't be too difficult.

Thanks again, I will post my problem shortly, and with a little narrower constraints.

Last edited by NickMeyers (2015-01-20 12:41:06)

Offline

#60 2015-01-20 12:01:56

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

Thanks for the help! Here is the new problem with a narrowed range (>or = to 495 and < or = to 500 instead of 480-500) this time.
There are 4 players with the same value (in matches 5 and 7), they need to count as individuals even though they are the same cost.

Problem #3:

Contraints:
Only one player from each match can be used.
There are 10 matches (A vs B, C vs D, E vs F, etc.).
5 players must be picked.
The total combined cost of the 5 picked, must be > or = to 495 and < or = to 500 (495-500)
All combinations 494 and under, or over 500 are not important.

I need to be able to generate a list of combinations, that fit this criteria, along with associated costs.

Data Set:
Match    Cost
1    A    114   
      B    88
   
2    C    116   
      D    84
   
3    E    112
      F    87
   
4    G    102 
      H    98 

5    I    104   
      J    96
   
6    K    103   
      L     97
   
7    M    104   
      N    96
   
8    O    106
      P    94
   
9    Q    120
      R    80
   
10   S   117   
      T    83

Results:
After using both forms of the results, Elaina's list was the easiest format to use.  I found it easier to search through when the numbers were used with the totals instead of the letters. This format:

{75, 80, 94, 118, 120, 487}
{75, 80, 94, 118, 127, 494}
{75, 80, 94, 120, 127, 496}

Even if there are players with the same cost, this still works for me, as long as there are counted and listed as individuals. The one like this last week were usable, there are 2 sets with the same costs this week.

{75, 94, 94, 109, 127, 499}
{75, 94, 94, 114, 118, 495}
{75, 94, 94, 114, 120, 497} 

Let me know if I can clarify any questions.  Thank you for the help!!

Last edited by NickMeyers (2015-01-20 12:20:59)

Offline

#61 2015-01-23 07:37:04

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

Agnishom wrote:
ElainaVW wrote:

Hello,

This is a restricted partition problem from a multiset. I have run it off by computer and the answer s 206.

For an analytical answer I have sent it off to bobbym.

Hi Elaina;

I'm getting an answer of 9763. Can you check?

In[7]:= Select[
  Subsets[{12, 7, 10, 9, 7, 13, 11, 9, 8, 13, 10, 10, 8, 11, 11, 9, 7,
     11, 9, 12}, {5}], Total[#] <= 50 &] // Length

Out[7]= 9763

Also,

data Player = Player Char Int

instance Show Player where
        show (Player name _) = show [name]

players = zipWith Player ['A'..'T'] [12,7,10,9,7,13,11,9,8,13,10,10,8,11,11,9,7,11,9,12]

choose :: [b] -> Int -> [[b]]
_      `choose` 0       = [[]]
[]     `choose` _       =  []
(x:xs) `choose` k       =  (x:) `fmap` (xs `choose` (k-1)) ++ xs `choose` k

value (Player _ x) = x

check n = filter (\p -> sum(map value p) <= 50) (choose players 5)

main = print $ check 5

gives this.

Agnishom, I know nothing about programming, but if I retype this into Haskell with my new numbers will it generate the answer? I downloaded Haskell, but I don't think I am doing it right...

Any chance you could let me know how to set a problem like this up?  Is it really complicated?  Would I just be able to copy and paste the framework for it and then just add new numbers?

Last edited by NickMeyers (2015-01-23 07:38:52)

Offline

#62 2015-01-23 08:03:17

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

Like I said, I have no idea what I am doing.... I tried copying and pasting that into the Haskell WinGHCi window, but I get this message:

GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> In[7]:= Select[
  Subsets[{12, 7, 10, 9, 7, 13, 11, 9, 8, 13, 10, 10, 8, 11, 11, 9, 7,
     11, 9, 12}, {5}], Total[#] <= 50 &] // Length

<interactive>:8:27: parse error on input ‘{’

I am sure there is more to it than copying and pasting, but if this can be set up with a copy and paste, please lat me know...

Is is possible to attach/send the file?

Thanks!!!

Last edited by NickMeyers (2015-01-23 08:04:57)

Offline

#63 2015-01-23 12:38:17

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

What file do you want me to provide?

Select[
  Subsets[{12, 7, 10, 9, 7, 13, 11, 9, 8, 13, 10, 10, 8, 11, 11, 9, 7,
     11, 9, 12}, {5}], Total[#] <= 50 &] // Length

is not actually haskell code. It's Mathematica.

If you have haskell, copy this and save to a file named 'script.hs' and run it with the haskell interpreter:

data Player = Player Char Int

instance Show Player where
        show (Player name _) = show [name]

players = zipWith Player ['A'..'T'] [12,7,10,9,7,13,11,9,8,13,10,10,8,11,11,9,7,11,9,12]

choose :: [b] -> Int -> [[b]]
_      `choose` 0       = [[]]
[]     `choose` _       =  []
(x:xs) `choose` k       =  (x:) `fmap` (xs `choose` (k-1)) ++ xs `choose` k

value (Player _ x) = x

check n = filter (\p -> sum(map value p) <= 50) (choose players 5)

main = print $ check 5

'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

#64 2015-01-23 18:13:23

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

I don't really know which file I need, because I am so new to this.  But this is awesome and I will give it a try! Do I insert different numbers for my new problem in this area [12,7,10,9,7,13,11,9,8,13,10,10,8,11,11,9,7,11,9,12] ?

If the numbers are the same, such as the two sets with 104 and 96 in the last problem, and I want to designate them as separate, what would I have to do so they show up in the results as separate numbers (such as 104a, 104b and 96a, 96b)?

Last edited by NickMeyers (2015-01-23 18:15:26)

Offline

#65 2015-01-24 02:12:20

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

We'll look into that but I want to ask you if you did figure out how to run a haskell script in Windows


'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

#66 2015-01-24 03:29:35

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

Agnishom wrote:

We'll look into that but I want to ask you if you did figure out how to run a haskell script in Windows

Not yet, but looking through this online guide to try to figure it out. Does that involve creating a .hs file and running it?

Last edited by NickMeyers (2015-01-24 03:30:28)

Offline

#67 2015-01-24 04:05:11

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

NickMeyers wrote:

If the numbers are the same, such as the two sets with 104 and 96 in the last problem, and I want to designate them as separate, what would I have to do so they show up in the results as separate numbers (such as 104a, 104b and 96a, 96b)?

You know what I just realized, if you post the results in the letter format like you did for the first combination problem, I can just copy and paste that in to Microsoft Word and use the replace function.  Where I can assign the numbers in place of the letters, and for the numbers that are the same I can just replace with the number keep the letter attached.  Which would generate the perfect list!

Any chance you could post the results in the letter format again (like here http://pastebin.com/jh4bqPUj)  for the latest problem?

Offline

#68 2015-01-24 04:19:04

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

What online guide?

I will do that later. I am very tired and I am in bed now.

What do you need all these for, actually?


'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

#69 2015-01-24 04:59:34

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

Have you been up all night?!? Thanks for the help!! I really appreciate it.

The online guide is the one here http://learnyouahaskell.com/chapters its a ebook I found while looking at youtube tutorials.

I use this to try to see all the combinations available for a game, it helps me see all the different combinations, I go through each one and see what combinations I like. It's kinda weird, but fun for me.  I would like to learn how to set problems up like this on my own eventually, but this programming lingo is very complicated.

Thanks again for the help!

Offline

#70 2015-01-24 10:23:14

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

but this programming lingo is very complicated.

Use a lamguage of your choice


'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

#71 2015-01-26 13:24:21

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

I still am trying to get Haskell figured out, I have one more problem and then won't have any for a few weeks.  Hopefully in that time I can figure this out.  This one only has 9 matchups, but all of the other rules apply.

There is something I am not doing right I will continue to mess with it, but I can't figure out how to make a .hs file or anything. I will keep trying, I think I just need to read more about it.

I still have not been able to figure out how to run a script. What do I need to google to find info for this specific problem/running a script on windows? I feel like I should be smart enough to figure this out...I'll keep searching

Thanks!

Contraints:
Only one player from each match can be used.
There are 9 matches (A vs B, C vs D, E vs F, etc.).
5 players must be picked.
The total combined cost of the 5 picked, must be > or = to 495 and < or = to 500 (495-500)
All combinations 494 and under, or over 500 are not important.
I need to be able to generate a list of combinations, that fit this criteria, along with associated costs.


Data Set:
Match    Cost
1    A    119   
      B    83
   
2    C    103 
      D    97
   
3    E    108
      F    92
   
4    G    118
      H    80

5    I    102
      J    98
   
6    K    105   
      L     94
   
7    M    117   
      N    80
   
8    O    109
      P    89
   
9    Q    107
      R    93

Offline

#72 2015-01-27 20:12:44

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination Problem

Can you please write down the list as {119, 83,103.. to save me some time?


'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

#73 2015-01-28 08:50:22

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

Yeah no problem! You are helping me out so, just let me know anything I can do to make it easier!

Thanks!!

{119, 83, 103, 97, 108, 92, 118, 80, 102, 98, 105, 94, 117, 80, 109, 89, 107, 93}

Offline

#74 2015-01-30 01:05:38

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Combination 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

#75 2015-02-01 04:50:09

NickMeyers
Member
Registered: 2015-01-17
Posts: 46

Re: Combination Problem

Thank you Agnishom!! I really appreciate your help!!  Over the next couple weeks I will keep trying to figure out how to do this!!  The list is perfect, no errors, I went through it all, thank you!

Offline

Board footer

Powered by FluxBB