My Math Forum How many combinations of 4 weights on a line?

 Applied Math Applied Math Forum

April 23rd, 2017, 11:47 PM   #11
Senior Member

Joined: Feb 2016
From: Australia

Posts: 1,597
Thanks: 546

Math Focus: Yet to find out.
Quote:
 Originally Posted by romsek what I did was take the alphabet (0,3,4,7,8 ) and create all 6 tuples of it then select those tuples for which the sum of the elements is 20 or less. Then remove the 0's Mathematica is a real joy to work with once you get it, which took me years....
You've posted large lists in other threads. I'm curious if you punch them in manually here, or can Mathematica help with that process?

April 24th, 2017, 01:37 AM   #12
Senior Member

Joined: Sep 2015
From: USA

Posts: 1,981
Thanks: 1027

Quote:
 Originally Posted by Joppy You've posted large lists in other threads. I'm curious if you punch them in manually here, or can Mathematica help with that process?
mathematica has "copy as latex"

April 24th, 2017, 06:09 AM   #13
Math Team

Joined: Oct 2011

Posts: 12,624
Thanks: 845

Quote:
 Originally Posted by romsek what I did was take the alphabet (0,3,4,7,8 ) and create all 6 tuples of it
Why include "0"?

April 24th, 2017, 09:25 AM   #14
Senior Member

Joined: Sep 2015
From: USA

Posts: 1,981
Thanks: 1027

Quote:
 Originally Posted by Denis Why include "0"?
because it's easier to generate the 6 tuples than all the 1,2,3,4,5,6 tuples.

0 just stands for no weights.

Just convenience in coding.

April 24th, 2017, 09:38 AM   #15
Math Team

Joined: Oct 2011

Posts: 12,624
Thanks: 845

Quote:
 Originally Posted by romsek because it's easier to generate the 6 tuples than all the 1,2,3,4,5,6 tuples. 0 just stands for no weights. Just convenience in coding.
Hmmm...I must be missing something...

We know 0 appears only once (as first item).
So we set count=1, and print a damn 0!

So to complete job, we only need alphabet (3,4,7,8 ).
(whatever the hell "alphabet" means!)

April 24th, 2017, 09:51 AM   #16
Senior Member

Joined: Sep 2015
From: USA

Posts: 1,981
Thanks: 1027

Quote:
 Originally Posted by Denis Hmmm...I must be missing something... We know 0 appears only once (as first item). So we set count=1, and print a damn 0! So to complete job, we only need alphabet (3,4,7,8 ). (whatever the hell "alphabet" means!)
it's just the way mathematica does things. It's simpler code to get all the length 6 tuples at once.

Alphabet is just the term for the elements you are making tuples out of.

the code

(* create the set of possible weights *)
ab = {0, 3, 4, 7, 8};

(* now create the possible sets of 6 weights *)
wts = Tuples[ab, {6}];

(* remove duplicates *)
wts = Map[Sort[#] &, wts] // DeleteDuplicates;

(* select those that have total weight <= 20 *)
wts = Select[wts, (# /. List -> Plus) <= 20 &];

(* remove the zeros *)
wts = Map[DeleteCases[#, x_ /; x == 0] &, wts];

(* display the weights *)
wts // MatrixForm

the language is totally cryptic but once you get used to it and used to thinking in lists it's tremendously versatile

Last edited by romsek; April 24th, 2017 at 10:15 AM.

 April 24th, 2017, 10:36 AM #17 Math Team   Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 12,624 Thanks: 845 YUK! I'm remaining faithful to Miss UBasic...
 April 24th, 2017, 11:46 AM #18 Math Team   Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 12,624 Thanks: 845 Curious... Limitless number of weights, from 1kg to 9 kg. How many combinations of 6 weights where total weight < 26kg? Order does not matter: like, 111177 and 771111 both qualify. Miss UBasic tells me 129,157 With Mathematica, how long does it take to perform this?
April 24th, 2017, 01:26 PM   #19
Senior Member

Joined: Sep 2015
From: USA

Posts: 1,981
Thanks: 1027

Quote:
 Originally Posted by Denis Curious... Limitless number of weights, from 1kg to 9 kg.
what does that mean?

is pi one of the weights? how about e? :P

Assuming weights 1,2,3,4,5,6,7,8,9

I'm getting nothing close to 129k.

I show 994 for the weight set above when all combos must be length 6.

Attached Images
 Clipboard01.jpg (22.8 KB, 3 views)

Last edited by romsek; April 24th, 2017 at 01:34 PM.

April 24th, 2017, 05:27 PM   #20
Math Team

Joined: Oct 2011

Posts: 12,624
Thanks: 845

Quote:
 Originally Posted by romsek Assuming weights 1,2,3,4,5,6,7,8,9 I'm getting nothing close to 129k. I show 994 for the weight set above when all combos must be length 6.
Yer assuming correctly...just as I CLEARLY stated

994?! How in heck did mathematica come up with that...

There are a total of 9^6 = 531441 combinations.
Of those, 129157 have digits that add up <26.
1: 111111
2: 111112
3: 111113
...
129155: 993121
129156: 993211
129157: 994111

Sooo....where did you goof?!

 Tags combinations, line, sequences, weights

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post mathmaniac Physics 24 February 1st, 2013 04:09 PM mydisguise08 Geometry 2 September 2nd, 2009 04:07 PM billiboy Applied Math 4 June 15th, 2009 11:26 PM totus Applied Math 4 February 28th, 2009 09:08 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top