- 682. Baseball Game
- 葉致煜
- Runtime: 40 ms, faster than 52.00% of Python3 online submissions for Baseball Game
- 葉致煜
- Memory Usage: 12.9 MB, less than 5.15% of Python3 online submissions for Baseball Game.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Referenced from Stanford CS193p | |
| #: important | |
| ##: very important | |
| Initialization | |
| - Setting Initial Values for Stored Properties | |
| - ##Customizing Initialization | |
| - Default Initializers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Referenced from Stanford CS193p | |
| #: important | |
| ##: very important | |
| Enumerations | |
| - Enumeration Syntax | |
| - Matching Enumeration Values with a Switch Statement | |
| - #Associated Values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Referenced from Stanford CS193p | |
| #: important | |
| ##: very important | |
| ##Protocols | |
| - Protocol Syntax | |
| - Property Requirements | |
| - Method Requirements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from matplotlib import pyplot as plt | |
| # helper function to check if (x, y) is in red section | |
| # x and y may be a single point or a numpy array | |
| def is_in_quarter_section(x, y): | |
| return x*x + y*y <= 1 | |
| def approximate_pi(sample_size=10000): | |
| # initialization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Twitter: | |
| def __init__(self): | |
| """ | |
| Initialize your data structure here. | |
| """ | |
| self.tweets = [] | |
| self.following_dict = {} | |
| self.followed_dict = {} |
Notes: you need to have the Refactoring: Web Edition account in order to see details of Refactoring Strategies
- Assuming that the tools are widely used, mature, and employed in various technology stacks, there is little reason to doubt the quality. Of course, if the tool is an early release, or used by only a few people worldwide, or a piece of seldom downloaded, version 0.1, open source software, there may be good reason to suspect the software. (Equally, an alpha version of commercial software might be suspect.)
- All the usual debugging advice applies, so isolate the problem, stub out calls, and surround it with tests; check calling conventions, shared libraries, and version numbers; explain it to someone else; look out for stack corrup- tion and variable type mismatches; and try the code on different machines and different build configurations, such as debug and release.
- Question your own assumptions and the assumptions of others.
- Multithreaded problems are another source of bugs that turn hair gray and induce screaming