Folding algorithm help.

rookie rookie at rooki.com
Mon Mar 18 14:20:41 PDT 2013


Hi,

I was trying to do a folding algorithm in D and just got stuck on 
how to approach the problem - I must be missing something (math).

Given the following:

    2   1  - Both folds are from Left to Right - 1 is the fist fold
    V   V
  1 | 2 | 3
  --------- - 3 Bottom to Up
  4 | 5 | 6

result

  6 | 5 | 4
-----------
  1 | 2 | 3

If folds cover one another so that there is no crossover like in 
the first fold above then a multidimensional stack could be used.

There were some interesting solutions for squares like:
https://groups.google.com/forum/#!msg/comp.lang.ruby/lf4Zd9fvuYY/tjT2q65mcFAJ


But nothing like the above.
It isn't homework.

Cheers,
Rookie


More information about the Digitalmars-d-learn mailing list