My Math Forum  

Go Back   My Math Forum > College Math Forum > Applied Math

Applied Math Applied Math Forum


Thanks Tree6Thanks
Reply
 
LinkBack Thread Tools Display Modes
April 23rd, 2017, 11:47 PM   #11
Senior Member
 
Joined: Feb 2016
From: Australia

Posts: 1,322
Thanks: 453

Math Focus: Yet to find out.
Quote:
Originally Posted by romsek View Post
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?
Joppy is offline  
 
April 24th, 2017, 01:37 AM   #12
Senior Member
 
romsek's Avatar
 
Joined: Sep 2015
From: Southern California, USA

Posts: 1,413
Thanks: 717

Quote:
Originally Posted by Joppy View Post
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"
romsek is offline  
April 24th, 2017, 06:09 AM   #13
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 10,485
Thanks: 693

Quote:
Originally Posted by romsek View Post
what I did was take the alphabet (0,3,4,7,8 ) and create all 6 tuples of it
Why include "0"?
Denis is offline  
April 24th, 2017, 09:25 AM   #14
Senior Member
 
romsek's Avatar
 
Joined: Sep 2015
From: Southern California, USA

Posts: 1,413
Thanks: 717

Quote:
Originally Posted by Denis View Post
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.
romsek is offline  
April 24th, 2017, 09:38 AM   #15
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 10,485
Thanks: 693

Quote:
Originally Posted by romsek View Post
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!)
Denis is offline  
April 24th, 2017, 09:51 AM   #16
Senior Member
 
romsek's Avatar
 
Joined: Sep 2015
From: Southern California, USA

Posts: 1,413
Thanks: 717

Quote:
Originally Posted by Denis View Post
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.
romsek is offline  
April 24th, 2017, 10:36 AM   #17
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 10,485
Thanks: 693

YUK! I'm remaining faithful to Miss UBasic...
Denis is offline  
April 24th, 2017, 11:46 AM   #18
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 10,485
Thanks: 693

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?
Denis is offline  
April 24th, 2017, 01:26 PM   #19
Senior Member
 
romsek's Avatar
 
Joined: Sep 2015
From: Southern California, USA

Posts: 1,413
Thanks: 717

Quote:
Originally Posted by Denis View Post
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
File Type: jpg Clipboard01.jpg (22.8 KB, 3 views)

Last edited by romsek; April 24th, 2017 at 01:34 PM.
romsek is offline  
April 24th, 2017, 05:27 PM   #20
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 10,485
Thanks: 693

Quote:
Originally Posted by romsek View Post
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?!
Denis is offline  
Reply

  My Math Forum > College Math Forum > Applied Math

Tags
combinations, line, sequences, weights



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unequal Weights mathmaniac Physics 24 February 1st, 2013 04:09 PM
Geometry or weights? mydisguise08 Geometry 2 September 2nd, 2009 04:07 PM
Find previous weights from current weights & percent change billiboy Applied Math 4 June 15th, 2009 11:26 PM
keyword relativity datatype weights and algorithm totus Applied Math 4 February 28th, 2009 09:08 PM





Copyright © 2017 My Math Forum. All rights reserved.