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 1996

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

Search the Archive

Re: programming comptition II (correction)

  • To: mathgroup at
  • Subject: [mg5051] Re: [mg5043] programming comptition II (correction)
  • From: fransm at (Frans Martens)
  • Date: Wed, 23 Oct 1996 01:38:12 -0400
  • Sender: owner-wri-mathgroup at


My previous solution of Problem One was wrong.
The wrong solution is with the example:

li1 = Array[f, {2,3,4}]
li2 = Array[g, {2,3,4}]


A solution is


Frans Martens
Eindhoven University of Technology
The Netherlands

Begin forwarded message:

>From: Xah Lee <xah at>
>Subject: [mg5043] programming comptition II

Two pure programing problems some of you will enjoy.

Problem One: Constructing Dimensions.
Given a one dimensional list, how to partition it so it becomes a  
list with a specified Dimensions. Example and solution:

Array[f, {5,2,3}]
First@ Fold[Partition, Flatten@ %, Reverse at {5,2,3} ]
%% === %


Problem Two: Pairing of Nodes.
Given two list of the same Dimensions, how to combine the list so  
the end nodes of the new list pair the end nodes of given lists.  
and solution:

Clear[li1, li2]

li1 = Array[f, {2,3,4}]
li2 = Array[g, {2,3,4}]

Transpose[ {li1, li2},
RotateRight@ Range@ Length@ Dimensions@ {li1, li2}

Please post your alternative approach.

 xah at; 74631.731 at 
 Mountain View, CA, USA

  • Prev by Date: Re: programming comptition II
  • Next by Date: New Maeder book
  • Previous by thread: Re: programming comptition II
  • Next by thread: New Maeder book