{"action":"created","issue":{"url":"https://api.github.com/repos/zodiac/isicp/issues/65","repository_url":"https://api.github.com/repos/zodiac/isicp","labels_url":"https://api.github.com/repos/zodiac/isicp/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/zodiac/isicp/issues/65/comments","events_url":"https://api.github.com/repos/zodiac/isicp/issues/65/events","html_url":"https://github.com/zodiac/isicp/issues/65","id":184641095,"number":65,"title":"Exercise 1.12 gives out an wrong answer","user":{"login":"soulomoon","id":14073857,"avatar_url":"https://avatars.githubusercontent.com/u/14073857?v=3","gravatar_id":"","url":"https://api.github.com/users/soulomoon","html_url":"https://github.com/soulomoon","followers_url":"https://api.github.com/users/soulomoon/followers","following_url":"https://api.github.com/users/soulomoon/following{/other_user}","gists_url":"https://api.github.com/users/soulomoon/gists{/gist_id}","starred_url":"https://api.github.com/users/soulomoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soulomoon/subscriptions","organizations_url":"https://api.github.com/users/soulomoon/orgs","repos_url":"https://api.github.com/users/soulomoon/repos","events_url":"https://api.github.com/users/soulomoon/events{/privacy}","received_events_url":"https://api.github.com/users/soulomoon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-22T16:53:32Z","updated_at":"2016-10-22T17:32:06Z","closed_at":"2016-10-22T17:32:06Z","body":"The quiz is:\r\n> Exercise 1.12. The following pattern of numbers is called Pascal's triangle.\r\n\r\n\r\n>The numbers at the edge of the triangle are all 1, and each number inside the triangle is the sum of the two numbers above it.\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;1\r\n&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;2&nbsp;1\r\n&nbsp;&nbsp;&nbsp;1&nbsp;3&nbsp;3&nbsp;1\r\n&nbsp;&nbsp;1&nbsp;4&nbsp;6&nbsp;4&nbsp;1\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . . .\r\n\r\n>Write a procedure that computes elements of Pascal's triangle by means of a recursive process. If a number lies outside of the triangle, return 0 (this makes sense if we view pascal as the combination > > function ). Start counting rows and columns from 0.\r\n\r\nI did the Exercise, it gave me an unexpected evaluation,so I try to figure it out why.\r\nEnd up copying the answer hided in the html, the site evaluates it to be right,\r\nI check in DrRacket with the folowing code.\r\nThe answer hided in the site is wrong,  #the followings.\r\n ```scheme\r\n; site's answer\r\n(define (pascal row col)\r\n   (cond ( (or (< row col)) 0)\r\n         ((or (= 0 col) (= row col)) 1)\r\n         (else (+ (pascal (- row 1) col)\r\n                  (pascal (- row 1) (- col 1))))))\r\n; the right one\r\n(define (ps row col)\r\n  (cond ((or (< row col)\r\n             (< row 1)\r\n             (< col 1)) 0)\r\n        ((or (= col 1)\r\n             (= col row)) 1)\r\n        (else (+ (ps (- row 1) (- col 1))\r\n                 (ps (- row 1) col)))\r\n  )\r\n)\r\n(define (printPs-iter func row col limit)\r\n  (if (and (= row 1) (= col 1)) (display func))\r\n  (if (< row limit) (display (func row col)))\r\n  (if (= row col) (newline))\r\n  (cond ((> row limit) \"end\")\r\n        ((> row col) (printPs-iter func row (+ col 1) limit))\r\n        ((= row col) (printPs-iter func (+ row 1) 1 limit)))\r\n  )\r\n(define (printPs func limit)\r\n  (printPs-iter func 1 1 limit)\r\n)\r\n(display \"----------------\") (newline)\r\n(printPs pascal 5)\r\n(display \"----------------\") (newline)\r\n\r\n(display \"----------------\") (newline)\r\n(printPs ps 5)\r\n(display \"----------------\") (newline)\r\n```\r\nterminal print out:\r\n```cmd\r\n----------------\r\n#<procedure:pascal>1\r\n21\r\n331\r\n4641\r\n\r\n\"end\"\r\n----------------\r\n----------------\r\n#<procedure:ps>1\r\n11\r\n121\r\n1331\r\n\r\n\"end\"\r\n----------------\r\n> \r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/zodiac/isicp/issues/comments/255542108","html_url":"https://github.com/zodiac/isicp/issues/65#issuecomment-255542108","issue_url":"https://api.github.com/repos/zodiac/isicp/issues/65","id":255542108,"user":{"login":"soulomoon","id":14073857,"avatar_url":"https://avatars.githubusercontent.com/u/14073857?v=3","gravatar_id":"","url":"https://api.github.com/users/soulomoon","html_url":"https://github.com/soulomoon","followers_url":"https://api.github.com/users/soulomoon/followers","following_url":"https://api.github.com/users/soulomoon/following{/other_user}","gists_url":"https://api.github.com/users/soulomoon/gists{/gist_id}","starred_url":"https://api.github.com/users/soulomoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soulomoon/subscriptions","organizations_url":"https://api.github.com/users/soulomoon/orgs","repos_url":"https://api.github.com/users/soulomoon/repos","events_url":"https://api.github.com/users/soulomoon/events{/privacy}","received_events_url":"https://api.github.com/users/soulomoon/received_events","type":"User","site_admin":false},"created_at":"2016-10-22T17:32:06Z","updated_at":"2016-10-22T17:32:06Z","body":"Sorry I think I miss out the fact that col is actually starting from 0 instead of 1 here in the scripts of the site, close the issue"}}
{"actor":{"display_login":"soulomoon"}}