GithubHelp home page GithubHelp logo

czahie / cs61a Goto Github PK

View Code? Open in Web Editor NEW
317.0 317.0 107.0 61.56 MB

Structure and Interpretation of Computer Programs

Home Page: http://inst.eecs.berkeley.edu/~cs61a/fa17/

Python 69.65% HTML 0.62% JavaScript 22.23% CSS 1.80% Scheme 5.69%
data-structure python scheme sqlite ucb

cs61a's People

Contributors

czahie avatar kamransadique avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cs61a's Issues

Bug: announce_highest in hog project can't pass all tests

Hi, @czahie. Thank you for sharing solution of hog project! It helps me a lot. But it seems that announce_highest function in phase2 can not pass the test. Here is the trace back.

>>> # The following function call checks if the behavior of f1 changes,
>>> # perhaps due to a side effect other than printing. The only side
>>> # effect of a commentary function should be to print.
>>> f2_again = f1(11, 1)

# Error: expected
#     1 point! That's the biggest gain yet for Player 1
# but got


Run only this test case with "python3 ok -q 07 --suite 1 --case 1"
---------------------------------------------------------------------
Test summary
    0 test cases passed before encountering first failed test case

The bug confused me for hours. I've written the function in another way and it passed the test.

def announce_highest(who, previous_high=0, previous_score=0):
    assert who == 0 or who == 1, 'The who argument should indicate a player.'
    # BEGIN PROBLEM 7
    def say(score0, score1):
        nonlocal previous_high, previous_score
        if who == 0:
            score = score0
        elif who == 1:
            score = score1
        current_score = score - previous_score
        if current_score > previous_high:
            if current_score == 1:
                print("1 point! That's the biggest gain yet for Player", who)
            else:
                print(current_score, "points! That's the biggest gain yet for Player", who)
            return announce_highest(who, current_score, score)
        return announce_highest(who, previous_high, score)
    return say
    # END PROBLEM 7

But I still can't figure out why the first implementation is wrong. I will appreciate it if you can help me.

So much bug in hug item!

I think you should check your code in hog item .So much bug in it.Your code can't pass the official test.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.