Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive


  • To: mathgroup at
  • Subject: [mg2611] Re:[mg2258] Puzzle
  • From: penny at (Des Penny)
  • Date: Mon, 27 Nov 1995 21:36:16 -0500

>Here's a nice puzzle.  Find the four numbers in the following sequence
>which total 100:  {6, 44, 30, 15, 24, 12, 33, 23, 18}.  It would seem that
>there might be a nice way to do this with Mathematica.  Any takers?

>Will Self
>Billings, Montana

Hi MathGroupers:

This is my first posting to the group.

I was catching up on my MathGroup messages over the last few days and came
up with a different approach to the above problem.  While not as elegant as
some of the other methods presented, it does have the merit of finding the
solution if you allow the numbers to be chosen more than once:

set={6, 44, 30, 15, 24, 12, 33, 23, 18};

spam=Outer[List,set,set,set,set];  (* Gives all possible combinations of 4
numbers from set *)

spam=Map[Sort[#]&,spam];  (* This allows the Union to remove duplicates *)

OUT:6561  (* It's big!! *)



Cases[spam,x_ /;(Apply[Plus,x]==100)]

{{6, 6, 44, 44}, {15, 18, 23, 44}, {23, 23, 24, 30}}

Thanks to Allan Hayes and Scott Herod for showing me how to apply Monty
Python to Mma.


Des Penny

Des Penny
Physical Science Dept.
Southern Utah University
Cedar City, UT 84720

VOICE: (801) 586-7708
FAX:    (801) 865-8051
e-mail: penny at

  • Prev by Date: Re: [Q] {a,b,c}->{{a,b},{b,c}}
  • Next by Date: Re: Why no simplification ?
  • Previous by thread: Re:Puzzle
  • Next by thread: Complex Matrices