www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Folding algorithm help.

reply "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:
https://groups.google.com/forum/#!msg/comp.lang.ruby/lf4Zd9fvuYY/tjT2q65mcFAJ


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

Cheers,
Rookie
Mar 18 2013
next sibling parent reply =?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
parent "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. Your diagram is: 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
prev sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
rookie:

 There were some interesting solutions for squares like:
 https://groups.google.com/forum/#!msg/comp.lang.ruby/lf4Zd9fvuYY/tjT2q65mcFAJ
The Ruby code by Luke Blanshard converted to D: http://codepad.org/gtWDdRoJ 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
next sibling parent "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:
 https://groups.google.com/forum/#!msg/comp.lang.ruby/lf4Zd9fvuYY/tjT2q65mcFAJ
The Ruby code by Luke Blanshard converted to D: http://codepad.org/gtWDdRoJ 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
prev sibling parent "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:
 https://groups.google.com/forum/#!msg/comp.lang.ruby/lf4Zd9fvuYY/tjT2q65mcFAJ
The Ruby code by Luke Blanshard converted to D: http://codepad.org/gtWDdRoJ 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