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. Re: Question regarding CIS 194 Homework Assignment 1
(Konstantin Saveljev)
----------------------------------------------------------------------
Message: 1
Date: Wed, 20 May 2015 15:09:01 +0300
From: Konstantin Saveljev <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question regarding CIS 194 Homework
Assignment 1
Message-ID:
<cakncejpt3nav5csw4c3fbaqtv9x11notlz-bjc+hu_zhrdo...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hey,
>> Firstly, I am confused as to how the doubled values are being added to
>> the undoubled number in the above example. It looks like only the
>> individual numbers of the doubled values are being added
The assignment states "Add the *digits* of the doubled values and the
undoubled digits", so it specifically states to add digits (which are 0 1 2
3 ... 9) and that is why when you have [2, 3, 16, 6] you do not simply do 2
+ 3 + 16 + 6 but you do it digit wise 2 + 3 + 1 + 6 + 6. That is [2, 3, 16,
6] becomes "23166" and you simply sum all the digits.
>> If we are to follow the algorithm described (double the value of "every
>> second digit" beginning from the right, last digit unchanged", then the
>> above numbers are identical EXCEPT For the last digits (1 and 2)
The assignment states "Add the digits of the doubled values *and the
undoubled digits*", so the sum will be different for the two numbers
provided in the example because both doubled and undoubled values (their
digits actually) are being summed. That is why for the first number
validates gives True and for the other it gives False.
Hope that was clear enough for you to understand. You got confused by a
single sentence in the assignment.
Konstantin
On Wed, May 20, 2015 at 2:47 PM, Vaibhav Goel <[email protected]> wrote:
> My apologies, this is only tangentially related to Haskell and I am not
> looking for a solution. I am confused with the assignment itself and
> hence asking here.
>
> The assignment
> (https://www.seas.upenn.edu/~cis194/spring13/hw/01-intro.pdf) says:
>
> ====== BEGIN
> Double the value of every second digit beginning from the right.
> That is, the last digit is unchanged; the second-to-last digit is dou-
> bled; the third-to-last digit is unchanged; and so on. For example,
> [1,3,8,6]
> becomes
> [2,3,16,6]
>
> Add the digits of the doubled values and the undoubled dig-
> its from the original number. For example,
> [2,3,16,6]
> becomes
> 2+3+1+6+6 = 18
> ======== END
>
> Firstly, I am confused as to how the doubled values are being added to
> the undoubled number in the above example. It looks like only the
> individual numbers of the doubled values are being added
>
> Secondly, later on in the assignment:
>
> ======== BEGIN
> Example
> :
> validate 4012888888881881 = True
> Example
> :
> validate 4012888888881882 = False
>
> ========= END
>
> If we are to follow the algorithm described (double the value of "every
> second digit" beginning from the right, last digit unchanged", then the
> above numbers are identical EXCEPT For the last digits (1 and 2)
>
>
> Any help is appreciated in decoding these instructions. Again please do
> not provide Haskell code, since I want to attempt to write it myself. I
> am just looking for help with the algorithm.
>
> Regards,
> _______________________________________________
> 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/20150520/b402eaf3/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 83, Issue 51
*****************************************