Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Difficulty understanding the Towers of Hanoi exercise from
      CIS194 (John Del Rosario)
   2. Re:  Difficulty understanding the Towers of Hanoi exercise
      from CIS194 (Petr V?penka)
   3. Re:  Difficulty understanding the Towers of Hanoi exercise
      from CIS194 (Kim-Ee Yeoh)


----------------------------------------------------------------------

Message: 1
Date: Sun, 30 Aug 2015 14:27:49 +0800
From: John Del Rosario <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Difficulty understanding the Towers of
        Hanoi exercise from CIS194
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

I've just completed the first exercise (Credit Card Number Validation)
and was quite happy with myself.

But moving on to the next exercise I found myself having trouble trying
to understand some parts of the question.

I've solved Towers of Hanoi before with an imperative language,
but I'm having trouble visualising the steps described in this paragraph:

To move n discs (stacked in increasing size) from peg a to peg b using peg c
as temporary storage,
1. move n-1 discs from a to c using b as temporary storage
2. move the top disc from a to b
3. move n-1 discs from c to b using a as temporary storage.

I've never seen the solution described this way before.
So if I start with 5 discs, then for the first step I'll be moving 4 (n-1) 
discs? But
can't I only move 1 disc at a time?

And step 2 says to move the top disc from a to b. Which disc is the top disc at 
this point?

I'm still in a very imperative mindset (and having no formal training doesn't 
help),
but I'm hoping that will improve as I go through this course!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150830/0b8a8c09/attachment-0001.html>

------------------------------

Message: 2
Date: Sun, 30 Aug 2015 10:22:20 +0200
From: Petr V?penka <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Difficulty understanding the Towers
        of Hanoi exercise from CIS194
Message-ID:
        <candmeuel+89dec1celxpfqnovatu2jxap_c44d-kl5foyfv...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

The tower of hanoi function you are writing is doing the "move n discs from
peg A to peg C using peg B" stuff.

1. moving n-1 discs doesn't mean moving them in one step, but rather using
the proper sequence of moves that results in (n-1) discs to be moved
2. after you've moved n-1 discs, only one disc is left on the peg and it is
the largest disc from the set of n discs
3. do the same as in point 1

Try to translate the steps literally to code, it will work and
understanding will come after that :)

Best, PV

On Sun, Aug 30, 2015 at 8:27 AM, John Del Rosario <[email protected]> wrote:

> I've just completed the first exercise (Credit Card Number Validation)
> and was quite happy with myself.
>
> But moving on to the next exercise I found myself having trouble trying
> to understand some parts of the question.
>
> I've solved Towers of Hanoi before with an imperative language,
> but I'm having trouble visualising the steps described in this paragraph:
>
> To move n discs (stacked in increasing size) from peg a to peg b using peg
> c
> as temporary storage,
> 1. move n-1 discs from a to c using b as temporary storage
> 2. move the top disc from a to b
> 3. move n-1 discs from c to b using a as temporary storage.
>
> I've never seen the solution described this way before.
> So if I start with 5 discs, then for the first step I'll be moving 4 (n-1)
> discs? But
> can't I only move 1 disc at a time?
>
> And step 2 says to move the top disc from a to b. Which disc is the top
> disc at this point?
>
> I'm still in a very imperative mindset (and having no formal training
> doesn't help),
> but I'm hoping that will improve as I go through this course!
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150830/2ef1cffc/attachment-0001.html>

------------------------------

Message: 3
Date: Sun, 30 Aug 2015 16:16:44 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Difficulty understanding the Towers
        of Hanoi exercise from CIS194
Message-ID:
        <capy+zdqozj+1qr+xyvfrkkoto1oduzwtnppwexq+uqmvqq5...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sun, Aug 30, 2015 at 1:27 PM, John Del Rosario <[email protected]> wrote:

> So if I start with 5 discs, then for the first step I'll be moving 4 (n-1)
> discs? But
> can't I only move 1 disc at a time?
>

Yes, the problem description elides a few explanations.

The idea is that there are two kinds of moves: "atomic" moves where we move
1 disc at a time.

And then there's a "big" move, comprising a sequence of atomic moves. One
big move accomplishes one unified goal. An example of a big move is moving
4 discs from one peg to another.

In the problem text, whether a "move" refers to an atomic move or a big
move is something left for the reader to infer.

A shortcut is to take every mention of "move" to mean a sequence of one or
more atomic moves. But that clashes with the fact that Move is a type
synonym representing only atomic moves.

Result: confusion.

More precise wording of the problem will help. I have nothing to do with
CIS194, but allow me to thank you for the pedagogical bug report all the
same.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150830/70b75d52/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 86, Issue 24
*****************************************

Reply via email to