[Haskell-beginners] Question regarding CIS 194 Homework Assignment 1

Vaibhav Goel vgoel at fastmail.com
Wed May 20 11:47:00 UTC 2015


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,


More information about the Beginners mailing list