## digitalmars.D.learn - Folding algorithm help.

• rookie (21/21) Mar 18 2013 Hi,
• =?UTF-8?B?QWxpIMOHZWhyZWxp?= (8/21) Mar 18 2013 I have absolulety no idea what this is about but I am brave enough to
• Zz (18/46) Mar 18 2013 Ali,
• bearophile (7/9) Mar 18 2013 The Ruby code by Luke Blanshard converted to D:
• rookie (6/16) Mar 19 2013 Hi bearophile,
• rookie (6/16) Mar 19 2013 Hi bearophile,
"rookie" <rookie rooki.com> writes:
```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:

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

Cheers,
Rookie
```
Mar 18 2013
=?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
```On 03/18/2013 02:20 PM, rookie wrote:
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

I have absolulety no idea what this is about but I am brave enough to
offer a correction. :) According to my nil understanding the result
should be the following:

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

Ali
```
Mar 18 2013
"Zz" <zz nospam.com> writes:
```On Monday, 18 March 2013 at 22:31:20 UTC, Ali Ã‡ehreli wrote:
On 03/18/2013 02:20 PM, rookie wrote:
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

I have absolulety no idea what this is about but I am brave
enough to offer a correction. :) According to my nil
understanding the result should be the following:

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

Ali

Ali,

It about trying to get help with a problem that froze my brain.

Right X 1 Up, Left X 1 Up, Bottom Y 1 Up - Which is different
from what I presented.

Look at the above fold as:
Left X 2 UP, Left X 1 Up, Bottom Y 1 Up - Where the numbers are
physical location in an open sheet.

Try folding the paper according to the diagram above the first
fold is 2nd from the left - 1 can't be in the middle for the
above sequence, generally it's folding and counting from the top
to bottom.

If all fold's from the left are within the sheet I don't have a
problem but once something goes beyond the sheet like in the fist
fold i'm stunned.

Cheers,
Rookie
```
Mar 18 2013
"bearophile" <bearophileHUGS lycos.com> writes:
```rookie:

There were some interesting solutions for squares like:

The Ruby code by Luke Blanshard converted to D:

Ruby is very flexible, and its multi-precision integers help
avoid some bugs, but I often prefer the coding precision D offers.

Bye,
bearophile
```
Mar 18 2013
"rookie" <rookie rooki.com> writes:
```On Tuesday, 19 March 2013 at 00:36:20 UTC, bearophile wrote:
rookie:

There were some interesting solutions for squares like:

The Ruby code by Luke Blanshard converted to D:

Ruby is very flexible, and its multi-precision integers help
avoid some bugs, but I often prefer the coding precision D
offers.

Bye,
bearophile

Hi bearophile,

Thanks for the sample.

Someone gave me a direction to try out (once I've read the
material) and I'll be writing it later.

Rookie
```
Mar 19 2013
"rookie" <rookie rooki.com> writes:
```On Tuesday, 19 March 2013 at 00:36:20 UTC, bearophile wrote:
rookie:

There were some interesting solutions for squares like:

The Ruby code by Luke Blanshard converted to D:

Ruby is very flexible, and its multi-precision integers help
avoid some bugs, but I often prefer the coding precision D
offers.

Bye,
bearophile

Hi bearophile,

Thanks for the sample.

Someone gave me a direction to try out (once I've read the
material) and I'll be writing it later.

Rookie
```
Mar 19 2013