diff --git a/articles/about/index.html b/articles/about/index.html deleted file mode 100644 index 1eea27396..000000000 --- a/articles/about/index.html +++ /dev/null @@ -1,803 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -Syllabus & Course Policies | CS 61A Fall 2024 - - - - - - -
- -
-
-
-

Syllabus & Course Policies

-
-

Overview

- - -

The CS 61 series is an introduction to computer science, with particular -emphasis on software and on machines from a programmer's point of view.

- -
    -
  1. CS 61A concentrates on the idea of abstraction, allowing the programmer to - think in terms appropriate to the problem rather than in low-level - operations dictated by the computer hardware.
  2. -
  3. CS 61B deals with the more advanced engineering aspects of software, such as - constructing and analyzing large programs.
  4. -
  5. CS 61C focuses on machines and how they execute programs.
  6. -
- -

In CS 61A, we are interested in teaching you about programming, not about how -to use one particular programming language. We consider a series of techniques -for managing program complexity, such as functional programming and -object-oriented programming.

- -

CS 61A primarily uses the Python 3 programming language. Python is a popular -language in both industry and academia. It is also particularly well-suited to -the task of exploring the topics taught in this course. It is an open-source -language developed by a large volunteer community that prides itself on the -diversity of its contributors.

- -

Mastery of a particular programming language is a very useful side effect of CS -61A. However, our goal is not to dictate what language you use in your future -endeavors. Instead, our hope is that once you have learned the concepts -involved in programming, you will find that picking up a new programming -language is but a few days' work. In fact, you will be asked to learn at least -two other languages, Scheme and SQL, during the course.

- -

A complete list of lecture topics, readings, and assignments appears in the -lecture schedule.

- - -

Prerequisites

- - -

Math 1A is listed as a corequisite for CS 61A. That is, it may be taken -concurrently. Math 10A or Math 16A are also fine. It is possible to take CS 61A -without knowing or learning calculus. Knowledge of calculus concepts will never -be required to complete any assignments. However, taking calculus is a great -way to practice the arithmetic and algebra that appear regularly in CS 61A.

- -

There is no formal programming-related prerequisite for CS 61A because students -without prior experience can succeed in the course, but taking the -course without any prior programming experience is typically quite challenging. -Students who take the course without prior programming experience typically -must spend more time to complete assignments and tend to receive lower -final grades in the course. Most CS 61A students have had significant prior -programming experience. A typical background includes at least one course -equivalent to CS 10 or a score of 3 or above on an AP Computer Science exam.

- -

If you find it challenging to complete all of the required coursework in the -first three weeks, we strongly recommend that you take another course -first. You'll likely have a better experience taking 61A later. Taking CS 61A -one semester later is unlikely to affect your degree progress or otherwise put -you behind, but continuing to struggle in CS 61A despite this recommendation -can lead to difficult academic circumstances that can affect your future -opportunities. It's better to finish CS 61A with strong mastery of the course -material, even if that means delaying by a semester, than to rush through it.

- - -

Alternative Courses

- - -

Here are some alternative UC Berkeley courses that are better suited for -students who do not have prior programming experience.

- - -

CS 10

- - -

CS 10: The Beauty and Joy of Computing is an introductory -computer science course which is similar to CS 61A but moves at a more moderate -pace. CS 10 covers variables, functions, recursion, algorithmic complexity, -object-oriented programming, and many other relevant CS 61A topics, with the -overall content overlap being about 50%. CS 10 starts the semester in Snap!, a -block-based programming language which allows students to focus on conceptual -understanding without worrying about unfamiliar syntax. After the midterm, the -course transitions into Python (the primary language 61A uses). CS 10 also -covers big ideas and social implications that go beyond programming, showing -you the beauty and joy of computing.

- - -

Data 8

- - -

Data 8: The Foundations of Data Science is an introduction -to data science designed to be accessible and useful for all Berkeley students. -This course was built for students without prior programming experience. It -teaches students to program in Python, but covers a much smaller subset of -the language than CS 61A. Most of the course focuses on data processing and -statistical techniques that are central to using computers to answer questions -about the world. Taking Data 8 before 61A is a good way to gain prior -programming experience, but taking CS 10 is a better way.

- - -

Data C88C (formerly CS 88)

- - -

CS 88: Computational Structures in Data -Science is an introduction to programming and -computing that has more than 50% concept overlap with CS 61A. It is designed -for students interested in data science who want to expand their knowledge of -programming and program structures beyond what is covered in Data 8. Students -who complete CS 88 can either proceed directly to CS 61B or subsequently take -CS 61A, a path that offers a substantial amount of review because of the high -topic overlap between the courses.

- - -

Info 206A

- - -

Info 206A: Introduction to Programming and -Computation is a 2-unit -introduction to programming that overlaps with many topics in the first eight -weeks of CS 61A. Professor Hany Farid has placed all of the videos and -exercises for this course -online, and these -are an excellent resource to supplement CS 61A.

- - -

Course Format

- - -

The course includes many events and opportunities for learning: lecture, lab, -discussion, office hours, and more. Try everything out to figure out what -combination of these course components help you the most.

- - -

Lectures & Videos

- - -

There are four 80-minute live lectures per week. In addition, there is a video -playlist for each lecture. Please watch the video playlist before attending -live lecture or section. The videos cover all required content for the course. -Live lecture will not cover all course material and will focus on examples -(so watch the videos).

- - -

Section

- - -

Weekly sections include a programming-based lab assignment and a discussion.

- -

There are 20 lab points. Each lab has an attendance and submission component. Submission of lab 0 is worth 2 points. See the Grading section for more details.

- -

There are 10 discussion points. Receiving credit for any 10 (or more) discussions -will earn a perfect discussion score for the course.

- -

This semester, we are offering two section formats: regular sections -and the mega section. Both are designed to help students learn the course -material equally well. You can choose which format you want. It is possible to -change formats at certain points during the course that will be announced.

- - -

Regular Section

- - -

Regular Sections meet four times a week with their section TA. Labs are Monday & Wednesday and Discussions are Tuesday & Thursday. Each Lab and Discussion section is 80 minutes. Attendance is required for students enrolled in a Regular Section.

- -

To receive credit for lab section, you must attend and get checked off (1 -point), and you must submit the lab assignment (1 point). You will be checked -off at the end of the lab period as long as you have made substantial progress -on the lab assignment. You can also be checked off and leave early if you -finish the lab assignment.

- -

To receive credit for the discussion section, you must attend.

- -

You can earn a maximum of 20 lab points across 12 scored labs (2 points each), -which means that you can miss two required labs and still have a perfect score. -The last lab, Lab 12, during the final week of classes is optional.

- -

You can earn a maximum of 10 discussion points across 12 required discussions, -which means you can miss two and still have a perfect score.

- -

Regular sections will not be webcast and are not recorded.

- - - - -

Mega Section

- - -

Mega section does not meet on a weekly basis. There will be videos released -each week that cover the discussion topics. Mega section may meet -at certain points throughout the semester (on Zoom) but attendance will be -optional.

- -

Students in the mega section must complete and submit the weekly lab -assignment but are not expected to come to lab. You are welcome to ask questions -about lab assignments during course office hours. If you need more support than -that, you should switch to the regular section.

- -

All students in mega will automatically receive full discussion credit. It is -up to the mega section students to keep up with weekly videos and discussion -worksheets as they see fit.

- -

Any Zoom-based mega section meetings will be webcast and recorded.

- - -

Choosing a Section Format

- - -

Mega section is only recommended for students with considerable prior -programming experience who are confident that they can succeed in the course -without the support of in-person section.

- -

Both options are meant to be great. Mega section is designed to appeal to -students who learn well from watching videos, working independently, and -coming to drop-in office hours when they need help. But the smaller format of -regular sections has clear advantages for students who wish to work with others -and get to know the course staff. Most students choose regular section.

- - -

Office Hours

- - -

Office hours are drop-in tutoring sessions in which you can ask questions about -the material, receive guidance on assignments, and work with peers and course -staff in a small group setting. See the office hour schedule -and come by.

- - -

Assignments

- - -

In addition to programming-based lab assignments, there are programming-based -homework assignments and projects.

- - -

Homework

- - -

Weekly homework assignments let you apply the concepts learned in lecture and -section to more challenging problems. Homeworks will typically be released on -Fridays and be due the following Thursday.

- - -

Partial Credit

- - -

Homework is scored out of 2 points, and every incorrect question reduces your -score by 1 point.

- - -

Projects

- - -

Projects are larger assignments intended to combine ideas from the course in -interesting ways.

- -

You are allowed and encouraged to pair program -with a partner. Make sure to alternate roles so that both of you understand the -complete results. You may also work alone on all projects, although partners -are recommended.

- -

Projects are graded on correctness, with points earned for each problem -successfully completed.

- - -

Exams

- - -

There will be two exams:

- -
    -
  • The Midterm will be held 6-8pm on Thursday 7/11
  • -
  • The Final will be held 7-10pm on Thursday 8/8
  • -
- -

Exams will be taken on paper on campus in designated exam rooms. There will be no remote exams this summer.

- - - -

We will post an announcement on Ed ahead of each exam with information for -students who cannot take the exam at the designated times.

- - -

Accommodations

- - - -

Assignment Extensions

- - -

If you need to request an extension, regardless of your DSP status, fill out -this form. Submissions to this form will be -visible only to the course instructors, and certain Student Support staff members.

- -

Any extension request up to 24 hours will be approved. Any extension request -up to 3 days made by a student with a DSP accommodation for assignment -extensions will be approved. Any longer extensions will be considered on a case-by-case basis.

- - -

Joining CS 61A Late

- - -

Work submitted late will not receive credit. However, it is possible to submit assignments if you -are not enrolled. If you would like to take the course but are -having enrollment issues, please submit all assignments by their due date.

- -

To request to be added to course platforms, email -cs61a@berkeley.edu.

- - -

DSP

- - -

We will provide appropriate accommodations to all students enrolled in -Berkeley's Disabled Students Program (DSP). -To ensure that you receive the appropriate accommodations, have your DSP -specialist submit a letter confirming your status and accommodations.

- -

If you're not enrolled in DSP, or are in the process of being onboarded by DSP, -you may still be eligible for accommodations (such as extended time on exams or -extended deadlines). You may also be eligible for accommodations if serious -extenuating circumstances should come up during the semester. If you believe you -may require accommodations, please email cs61a@berkeley.edu.

- - -

Privacy

- - -

All DSP and accommodations-related materials for this course are kept in a -repository separate from the rest of the course materials that is visible only -to the instructors, selected staff, and staff course managers.

- -

For any DSP and accommodations-related communications, please reach out to -cs61a@berkeley.edu, which will put you in touch -with our student support team. This inbox is only visible to staff members marked with -"cs61a@" on the staff page. This inbox will be visible to future -members of course staff, so if you ever have a communication that you wish to -remain private, let us know and we can delete the email exchange once the -conversation is resolved.

- - -

Grading

- - -

Your course grade is computed using a point system with a total of 300 points, -broken down as follows:

- -
    -
  • The Midterm, worth 64 points
  • -
  • The Final, worth 92 points
  • -
  • Four projects, worth 100 points
  • -
  • Homework, worth 14 points
  • -
  • Lab 0 Completion, worth 2 points
  • -
  • Lab (1-11) Attendance, worth 9 points
  • -
  • Lab (1-11) Completion, worth 9 points
  • -
  • Discussion Attendance, worth 10 points
  • -
- -

There are an upwards of 10+ extra credit points available to everyone. These come in the form of early submission of projects, extra credit problems on projects, etc.

- -

Each letter grade for the course corresponds to a range of scores:

- -
A+  ≥ 300    A  ≥ 285    A-  ≥ 270
-B+  ≥ 255    B  ≥ 230    B-  ≥ 210
-C+  ≥ 190    C  ≥ 180    C-  ≥ 175
-D+  ≥ 170    D  ≥ 165    D-  ≥ 160
- -

Your final score will be rounded to the nearest integer before being converted -to a letter grade. 0.5 rounds up to 1, but 0.49 rounds down to 0.

- - - -

There is no curve; your grade will depend only on how well you do, and not on -how well everyone else does. Score thresholds are based on how students -performed in previous semesters. Thresholds are not usually adjusted based -on student performance and never increased.

- -

In a typical semester, 50-60% of students taking the course for a letter grade -will receive a B+ or higher.

- -

Incomplete grades will be granted only for medical or personal emergencies that -cause you to miss the final or last part of the course, only for students who -have completed the majority of the coursework, and only if work up to the point -of the emergency has been satisfactory. If you wish to discuss an incomplete -in the course, please contact cs61a@berkeley.edu.

- - - -

Many students end the course with perfect homework, project, lab, and discussion -scores. These parts of the course are not meant to be evaluations, but instead -learning tools.

- - -

Exam Recovery

- - -

Edit 7/18: Due to the difficult of the midterm exam, we have updated the exam recovery policy to be a full recovery using your final exam score.

- -

It is possible to recover lost points on the Midterm by showing improvement on the final. Your Midterm percentage will be calculated as follows:

- -
mt_percentage = max(mt_percentage, final_percentage)
- - - -

For example, if you score 50% on the Midterm and 80% on the Final, your Midterm score will be recovered to 80%.

- - -

Late Policy

- - -

If you cannot turn in an assignment on time, -you can request an extension. For late work beyond the extended deadline:

- -
    -
  • Labs receive no credit.
  • -
  • Homework receives no credit.
  • -
  • Projects: Submissions within 48 hours after the deadline will receive - 75% of the earned score. Submissions that are 48 hours or more after the - deadline will receive no credit.
  • -
- - -

Citizenship

- - -

It is our expectation that all interactions with course staff and other -students will demonstrate appropriate respect, consideration, and compassion -for others. Please remember to be friendly and thoughtful; our community draws -from a wide spectrum of valuable experiences. For further reading, please -reference the Berkeley Principles of Community and Berkeley Campus Code of -Student Conduct.

- -

For exceptionally rude or disrespectful behavior toward the course staff or -other students, your final grade will be lowered by up to a full letter grade -(e.g., from an A- to a B-) at the discretion of the course instructors. You -don't need to be concerned about this policy if you treat other human beings -with even a bare minimum of respect and consideration and do not engage in -behavior that is actively harmful to others.

- - -

Learning Cooperatively

- - -

With the obvious exception of exams, we encourage you to discuss course -activities with your friends and classmates as you are working on them. You will -learn more in this class if you work with others than if you do not. Ask -questions, answer questions, and share ideas liberally.

- -

Learning cooperatively is different from sharing answers. You shouldn't be -showing your code to other students or looking at others' code, except:

- -
    -
  • During lab, you can share all you want as long as you're all learning.
  • -
  • For a project that allows partners, you can share anything with your partner.
  • -
  • If you've finished a problem already, you can look at others' code to help - them finish.
  • -
- -

If you are helping another student, don't just tell them the answer; they will -learn very little and run into trouble on exams. Instead, try to guide them -toward discovering the solution on their own by thinking through examples. -Problem solving practice is critical to progress in computer science.

- -

Since you're working collaboratively, keep your project partner informed. If -some medical or personal emergency takes you away from the course for an -extended period, or if you decide to drop the course for any reason, please -don't just disappear silently! You should inform your project partner so that -nobody is depending on you to do something you can't finish.

- - -

Academic Misconduct

- - -

Any students caught collaborating on exams will receive an F in the course. -Please don't be one of these students.

- -

Reading others' homework or project solution to a problem before you solve that -problem on your own will incur point penalties. You are free to discuss -the problems with others beforehand, but you must write your own solutions. The -exception to this rule is that you may share code with your project partner.

- -

The following is a list of things you should NOT do. This list is not -exhaustive, but covers most of the big offenses:

- -
    -
  • Do not copy code from any student who is not your partner.
  • -
  • Do not allow any student other than your partner to copy code from you.
  • -
  • Do not copy solutions from online sources such as Stack Overflow, Pastebin, - and public repositories on GitHub.
  • -
  • Do not read others' solutions to an assignment before you have completed the - assignment
  • -
  • Do not post your solutions publicly during or after the semester.
  • -
- -

If you find a solution online, please submit a link to that solution -anonymously. When we find an online -solution, we ask the author to remove it. We also record the solution and use it -to check for copying. By reporting online solutions, you help keep the course -fair for everyone.

- -

In summary, we expect you to hand in your own work, take your own tests, and -complete projects with code written only by you and your partner.

- -

Rather than copying someone else's work, ask for help. You are not alone in -this course! The entire staff is here to help you succeed. If you invest the -time to learn the material and complete the projects, you won't need to copy -any answers.

- - -

A Parting Thought

- - -

Grades and penalties aren't the purpose of this course. We really just want you -to learn. The entire staff is very excited to be teaching CS 61A this semester -and we're looking forward to meeting such a large and enthusiastic group of -students. We want all of you to be successful here. Welcome to CS 61A!

-
- - -
- -
- - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/disc/disc12/index.html b/disc/disc12/index.html deleted file mode 100644 index 3b2682a16..000000000 --- a/disc/disc12/index.html +++ /dev/null @@ -1,708 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Discussion 12 | CS 61A Fall 2024 - - - - - - -
- -
-
-
-

- -Discussion 12: Final Review - - - - - - -

-
- - - - - - -

Reminder: Use Discord for voice chat with the course staff. Write to @discuss in the #discuss-queue channel on Discord at any time, and a member of the course staff will join your group's voice channel.

- -

Pick someone in your group to join Discord. -It's fine if multiple people join, but one is enough.

- -

Now switch to Pensieve:

- -
    -
  • Everyone: Go to discuss.pensieve.co and log in with your @berkeley.edu email, then enter your group number. (Your group number is the number of your Discord channel.)
  • -
- -

Once you're on Pensieve, you don't need to return to this page; Pensieve has all the same content (but more features). If for some reason Penseive doesn't work, return to this page and continue with the discussion.

- -

Post in the #help channel on Discord if you have trouble.

- -

Pro tip: Any of you can type a question into your group's Discord channel's text chat with the @discuss tag, and a member of the course staff will respond.

- - -

Getting Started

- - -

If you have only 1 or 2 people in your group, you can join the other group in -the room with you.

- -

Ice breaker: Everybody say your name and the non-CS/EECS course that you're -most excited about taking next semester.

- - -

Lists

- - - - -
-The two most common mutation operations for lists are item assignment and the -append method. - -
>>> s = [1, 3, 4]
->>> t = s  # A second name for the same list
->>> t[0] = 2  # this changes the first element of the list to 2, affecting both s and t
->>> s
-[2, 3, 4]
->>> s.append(5)  # this adds 5 to the end of the list, affecting both s and t
->>> t
-[2, 3, 4, 5]
- -

There are many other list mutation methods:

- -
    -
  • append(elem): - Add elem to the end of the list. Return None.
  • -
  • extend(s): - Add all elements of iterable s to the end of the list. Return None.
  • -
  • insert(i, elem): - Insert elem at index i. If i is greater than or equal to the length of - the list, then elem is inserted at the end. This does not replace any - existing elements, but only adds the new element elem. Return None.
  • -
  • remove(elem): - Remove the first occurrence of elem in list. Return None. - Errors if elem is not in the list.
  • -
  • pop(i): - Remove and return the element at index i.
  • -
  • pop(): - Remove and return the last element. -
- - - -

Q1: Word Rope

- - -

Definition: A rope in Python is a list containing only one-letter strings -except for the last element, which may either be a one-letter string or a rope.

- -

Implement word_rope, a Python function that takes a non-empty string s -containing only letters and spaces that does not start or end with a space. It -returns a rope containing the letters of s in which each word is in a -separate list.

- -

Important: You may not use slicing or the split, find, or index -methods of a string. Solve the problem using list operations.

- -

Reminder: s[-1] evaluates to the last element of a sequence s.

- - -
- Run in 61A Code - -
- - - - - -
-In this implementation, result is a rope and word is a list within that rope which is still being constructed. When x is a space, add an empty list to the end of word and assign word to this empty list. Otherwise, add x to the end of word. -
- - -

Linked Lists

- - - - -
-A linked list is a Link object or Link.empty. - -

You can mutate a Link object s in two ways:

- -
    -
  • Change the first element with s.first = ...
  • -
  • Change the rest of the elements with s.rest = ...
  • -
- -

You can make a new Link object by calling Link:

- -
    -
  • Link(4) makes a linked list of length 1 containing 4.
  • -
  • Link(4, s) makes a linked list that starts with 4 followed by the elements of linked list s. -
- - - - -
- -
class Link:
-    """A linked list is either a Link object or Link.empty
-
-    >>> s = Link(3, Link(4, Link(5)))
-    >>> s.rest
-    Link(4, Link(5))
-    >>> s.rest.rest.rest is Link.empty
-    True
-    >>> s.rest.first * 2
-    8
-    >>> print(s)
-    <3 4 5>
-    """
-    empty = ()
-
-    def __init__(self, first, rest=empty):
-        assert rest is Link.empty or isinstance(rest, Link)
-        self.first = first
-        self.rest = rest
-
-    def __repr__(self):
-        if self.rest:
-            rest_repr = ', ' + repr(self.rest)
-        else:
-            rest_repr = ''
-        return 'Link(' + repr(self.first) + rest_repr + ')'
-
-    def __str__(self):
-        string = '<'
-        while self.rest is not Link.empty:
-            string += str(self.first) + ' '
-            self = self.rest
-        return string + str(self.first) + '>'
- - - -
- - -

Q2: Linear Sublists

- - -

Definition: A sublist of linked list s is a linked list of some of the -elements of s in order. For example, <3 6 2 5 1 7> has sublists <3 2 1> -and <6 2 7> but not <5 6 7>.

- -

Definition: A linear sublist of a linked list of numbers s is a sublist -in which the difference between adjacent numbers is always the same. For example -<2 4 6 8> is a linear sublist of <1 2 3 4 6 9 1 8 5> because the difference -between each pair of adjacent elements is 2.

- -

Implement linear which takes a linked list of numbers s (either a Link -instance or Link.empty). It returns the longest linear sublist of s. If two -linear sublists are tied for the longest, return either one.

- - -
- Run in 61A Code - -
- - - - - -
-There are three cases: - -
    -
  • If rest is empty, return a one-element list containing just first.
  • -
  • If rest.first is in the linear sublist that starts with first, then build a list that contains first, and rest.first.
  • -
  • Otherwise, complete(first, rest.rest). -
- - - - -
-This while loop is creating a candidate linear sublist for every two possible starting values: s.first and t.first. The rest of the linear sublist must be in t.rest. -
- - -

Scheme

- - - -

Q3: Increasing Rope

- - -

Definition: A rope in Scheme is a non-empty list containing only numbers -except for the last element, which may either be a number or a rope.

- -

Implement up, a Scheme procedure that takes a positive integer n. It returns -a rope containing the digits of n that is the shortest rope in which each pair -of adjacent numbers in the same list are in increasing order.

- -

Reminder: the quotient procedure performs floor division, like // in -Python. The remainder procedure is like % in Python.

- - -
- Run in 61A Code - -
- - - - - -
-Compare first to (car result) to decide whether to cons the value first onto the result or whether to form a new list that contains first and result as elements. -
- - - -
-To correctly call helper from within up, build a rope that only contains the last digit of n: (remainder n 10). -
- - -

SQL

- - - - -
-A SELECT statement describes an output table based on input rows. To write one: - -
    -
  1. Describe the input rows using FROM and WHERE clauses.
  2. -
  3. Group those rows and determine which groups should appear as output rows using GROUP BY and HAVING clauses.
  4. -
  5. Format and order the output rows and columns using SELECT and ORDER BY clauses.
  6. -
- -

SELECT (Step 3) FROM (Step 1) WHERE (Step 1) GROUP BY (Step 2) HAVING (Step 2) ORDER BY (Step 3);

- -

Step 1 may involve joining tables (using commas) to form input rows that consist of two or more rows from existing tables.

- -

The WHERE, GROUP BY, HAVING, and ORDER BY clauses are optional. -

- - -

Q4: A Secret Message

- - -

A substitution cipher replaces each word with another word in a table in order -to encrypt a message. To decode an encrypted message, replace each word x with -its corresponding y in a code table.

- -

Write a select statement to decode the original message It's The End -using the code table.

- - -
- Run in 61A Code - -
- - - - - -
- -

Join the original and code tables and make sure that the joined roles have -the same word and x.

- -
- -

What happens now? Write another select statement to decode this encrypted -message using the same code table.

- - -
- Run in 61A Code - -
- - - - - -
- -

Join original with code AS a and code AS b to create six-column rows like: -2|The|The|Happens|Happens|Go, The Go at the end is part of the decoded message.

- -
- -

Scheduling time: This is the last discussion, but you could schedule a -meeting with your group next week to study for the exam. Your regular discussion -room and time should be available during RRR week if you want to use it.

- - -

Document the Occasion

- - -

Please all fill out the attendance form (one submission per person per week).

- -

Important: Please help put the furniture in the room back where you found it before you leave. Thanks!

- - -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/disc/sol-disc05/index.html b/disc/sol-disc05/index.html index c32ce0218..fc3ce658f 100644 --- a/disc/sol-disc05/index.html +++ b/disc/sol-disc05/index.html @@ -166,24 +166,19 @@

-

Pick someone in your group to join Discord. -It's fine if multiple people join, but one is enough.

- -

Now switch to Pensieve:

+

Switch to Pensieve:

Once you're on Pensieve, you don't need to return to this page; Pensieve has all the same content (but more features). If for some reason Penseive doesn't work, return to this page and continue with the discussion.

-

Post in the #help channel on Discord if you have trouble.

-

Getting Started

-

Everyone go around and say your name, just in case someone forgot.

+

Everyone go around and say your name.

For fun: Think of a big word with at least three syllables, such as "solitary" or "conundrum" or "ominous". Try to use it as many times as you can @@ -192,14 +187,9 @@

Getting Started

uses their big word the most times (and at least twice) without their group guessing it wins. (You win nothing; it's just a game.)

-

To get help from a TA, send a message to the discuss-queue channel with -the @discuss tag and your discussion group number.

+

To get help from a TA, If you do not have an in-person TA, you can reach your TA using this Zoom link.

-

If you have fewer than 4 people in your group, you can merge with another group in the room with you.

- -

The most common suggestion from last discussion was to add some hints, so we have. -The second most common suggestion was to encourage more discussion and collaboration. -Discuss and collaborate!

+

If there are fewer than 3 people in your group, feel free to merge your group with another group in the room.

Trees

@@ -366,7 +356,7 @@

Q2: Has Path

Your Answer -
+
Run in 61A Code -

Discussion Time! Can the else case of has_path be written in just one -line? Why or why not? You can ignore how fast the function will run. -When your group has an answer, send a message to the discuss-queue channel with -the @discuss tag, your discussion group number, and the message "Maybe?" and a -member of the course staff will join your voice channel to hear your answer and -give feedback.

-
+

New Rule: Whoever in your group helped type the answer to the last question should not type the answer to the next one. Instead, just ask questions and give suggestions; give other members of your group a chance to type the answer.

+

Q3: Find Path

@@ -589,9 +579,7 @@

Q3: Find Path

Description Time! When your group has completed this question, it's time to describe why this function does not have a base case that uses is_leaf. Come up with an explanation as a group, pick someone to present your answer, and then -send a message to the discuss-queue channel with the @discuss tag, your -discussion group number, and the message "Found it!" and a member of the course -staff will join your voice channel to hear your description and give feedback.

+tell your TA (on Zoom if your TA is remote).

@@ -603,7 +591,7 @@

Document the Occasion

(from the Getting Started section). The group only gets one guess. After they guess, reveal your big word and how many times you used it during discussion.

-

Please all fill out the attendance form (one submission per person per week).

+

Please all fill out the attendance form (one submission per person per week).

- - - - - - - - - - - - - - - - - - -Discussion 12 | CS 61A Fall 2024 - - - - - - -
- -
-
-
-

- -Discussion 12: Final Review - - - - - - -

-
- - - - - - -

Reminder: Use Discord for voice chat with the course staff. Write to @discuss in the #discuss-queue channel on Discord at any time, and a member of the course staff will join your group's voice channel.

- -

Pick someone in your group to join Discord. -It's fine if multiple people join, but one is enough.

- -

Now switch to Pensieve:

- -
    -
  • Everyone: Go to discuss.pensieve.co and log in with your @berkeley.edu email, then enter your group number. (Your group number is the number of your Discord channel.)
  • -
- -

Once you're on Pensieve, you don't need to return to this page; Pensieve has all the same content (but more features). If for some reason Penseive doesn't work, return to this page and continue with the discussion.

- -

Post in the #help channel on Discord if you have trouble.

- -

Pro tip: Any of you can type a question into your group's Discord channel's text chat with the @discuss tag, and a member of the course staff will respond.

- - -

Getting Started

- - -

If you have only 1 or 2 people in your group, you can join the other group in -the room with you.

- -

Ice breaker: Everybody say your name and the non-CS/EECS course that you're -most excited about taking next semester.

- - -

Lists

- - - - -
-The two most common mutation operations for lists are item assignment and the -append method. - -
>>> s = [1, 3, 4]
->>> t = s  # A second name for the same list
->>> t[0] = 2  # this changes the first element of the list to 2, affecting both s and t
->>> s
-[2, 3, 4]
->>> s.append(5)  # this adds 5 to the end of the list, affecting both s and t
->>> t
-[2, 3, 4, 5]
- -

There are many other list mutation methods:

- -
    -
  • append(elem): - Add elem to the end of the list. Return None.
  • -
  • extend(s): - Add all elements of iterable s to the end of the list. Return None.
  • -
  • insert(i, elem): - Insert elem at index i. If i is greater than or equal to the length of - the list, then elem is inserted at the end. This does not replace any - existing elements, but only adds the new element elem. Return None.
  • -
  • remove(elem): - Remove the first occurrence of elem in list. Return None. - Errors if elem is not in the list.
  • -
  • pop(i): - Remove and return the element at index i.
  • -
  • pop(): - Remove and return the last element. -
- - - -

Q1: Word Rope

- - -

Definition: A rope in Python is a list containing only one-letter strings -except for the last element, which may either be a one-letter string or a rope.

- -

Implement word_rope, a Python function that takes a non-empty string s -containing only letters and spaces that does not start or end with a space. It -returns a rope containing the letters of s in which each word is in a -separate list.

- -

Important: You may not use slicing or the split, find, or index -methods of a string. Solve the problem using list operations.

- -

Reminder: s[-1] evaluates to the last element of a sequence s.

- - - - Your Answer - -
- Run in 61A Code - -
- - -
- Solution - -
def word_rope(s):
-    """Return a rope of the words in string s.
-
-    >>> word_rope('the last week')
-    ['t', 'h', 'e', ['l', 'a', 's', 't', ['w', 'e', 'e', 'k']]]
-    """
-    assert s and s[0] != ' ' and s[-1] != [ ]
-    result = []
-    word = result
-    for x in s:
-        if x == ' ':
-            word.append([])
-            word = word[-1]
-        else:
-            word.append(x)
-    return result
- -
- - - - -
-In this implementation, result is a rope and word is a list within that rope which is still being constructed. When x is a space, add an empty list to the end of word and assign word to this empty list. Otherwise, add x to the end of word. -
- - -

Linked Lists

- - - - -
-A linked list is a Link object or Link.empty. - -

You can mutate a Link object s in two ways:

- -
    -
  • Change the first element with s.first = ...
  • -
  • Change the rest of the elements with s.rest = ...
  • -
- -

You can make a new Link object by calling Link:

- -
    -
  • Link(4) makes a linked list of length 1 containing 4.
  • -
  • Link(4, s) makes a linked list that starts with 4 followed by the elements of linked list s. -
- - - - -
- -
class Link:
-    """A linked list is either a Link object or Link.empty
-
-    >>> s = Link(3, Link(4, Link(5)))
-    >>> s.rest
-    Link(4, Link(5))
-    >>> s.rest.rest.rest is Link.empty
-    True
-    >>> s.rest.first * 2
-    8
-    >>> print(s)
-    <3 4 5>
-    """
-    empty = ()
-
-    def __init__(self, first, rest=empty):
-        assert rest is Link.empty or isinstance(rest, Link)
-        self.first = first
-        self.rest = rest
-
-    def __repr__(self):
-        if self.rest:
-            rest_repr = ', ' + repr(self.rest)
-        else:
-            rest_repr = ''
-        return 'Link(' + repr(self.first) + rest_repr + ')'
-
-    def __str__(self):
-        string = '<'
-        while self.rest is not Link.empty:
-            string += str(self.first) + ' '
-            self = self.rest
-        return string + str(self.first) + '>'
- - - -
- - -

Q2: Linear Sublists

- - -

Definition: A sublist of linked list s is a linked list of some of the -elements of s in order. For example, <3 6 2 5 1 7> has sublists <3 2 1> -and <6 2 7> but not <5 6 7>.

- -

Definition: A linear sublist of a linked list of numbers s is a sublist -in which the difference between adjacent numbers is always the same. For example -<2 4 6 8> is a linear sublist of <1 2 3 4 6 9 1 8 5> because the difference -between each pair of adjacent elements is 2.

- -

Implement linear which takes a linked list of numbers s (either a Link -instance or Link.empty). It returns the longest linear sublist of s. If two -linear sublists are tied for the longest, return either one.

- - - - Your Answer - -
- Run in 61A Code - -
- - -
- Solution - -
def linear(s):
-    """Return the longest linear sublist of a linked list s.
-
-    >>> s = Link(9, Link(4, Link(6, Link(7, Link(8, Link(10))))))
-    >>> linear(s)
-    Link(4, Link(6, Link(8, Link(10))))
-    >>> linear(Link(4, Link(5, s)))
-    Link(4, Link(5, Link(6, Link(7, Link(8)))))
-    >>> linear(Link(4, Link(5, Link(4, Link(7, Link(3, Link(2, Link(8))))))))
-    Link(5, Link(4, Link(3, Link(2))))
-    """
-    def complete(first, rest):
-        "The longest linear sublist of Link(first, rest) with difference d."
-        if rest is Link.empty:
-            return Link(first, rest)
-        elif rest.first - first == d:
-            return Link(first, complete(rest.first, rest.rest))
-        else:
-            return complete(first, rest.rest)
-    if s is Link.empty:
-        return s
-    longest = Link(s.first) # The longest linear sublist found so far
-    while s is not Link.empty:
-        t = s.rest
-        while t is not Link.empty:
-            d = t.first - s.first
-            candidate = Link(s.first, complete(t.first, t.rest))
-            if length(candidate) > length(longest):
-                longest = candidate
-            t = t.rest
-        s = s.rest
-    return longest
-
-def length(s):
-    if s is Link.empty:
-        return 0
-    else:
-        return 1 + length(s.rest)
- -
- - - - -
-There are three cases: - -
    -
  • If rest is empty, return a one-element list containing just first.
  • -
  • If rest.first is in the linear sublist that starts with first, then build a list that contains first, and rest.first.
  • -
  • Otherwise, complete(first, rest.rest). -
- - - - -
-This while loop is creating a candidate linear sublist for every two possible starting values: s.first and t.first. The rest of the linear sublist must be in t.rest. -
- - -

Scheme

- - - -

Q3: Increasing Rope

- - -

Definition: A rope in Scheme is a non-empty list containing only numbers -except for the last element, which may either be a number or a rope.

- -

Implement up, a Scheme procedure that takes a positive integer n. It returns -a rope containing the digits of n that is the shortest rope in which each pair -of adjacent numbers in the same list are in increasing order.

- -

Reminder: the quotient procedure performs floor division, like // in -Python. The remainder procedure is like % in Python.

- - - - Your Answer - -
- Run in 61A Code - -
- - -
- Solution - -
    (define (up n)
-        (define (helper n result)
-            (if (zero? n) result
-                (helper
-                    (quotient n 10)
-                    (let ((first (remainder n 10)))
-                        (if (< first (car result))
-                            (cons first result)
-                            (list first result))
-                        ))))
-        (helper
-          (quotient n 10)
-          (list (remainder n 10))
-        ))
-
-  (expect (up 314152667899) (3 (1 4 (1 5 (2 6 (6 7 8 9 (9)))))))
- -
- - - - -
-Compare first to (car result) to decide whether to cons the value first onto the result or whether to form a new list that contains first and result as elements. -
- - - -
-To correctly call helper from within up, build a rope that only contains the last digit of n: (remainder n 10). -
- - -

SQL

- - - - -
-A SELECT statement describes an output table based on input rows. To write one: - -
    -
  1. Describe the input rows using FROM and WHERE clauses.
  2. -
  3. Group those rows and determine which groups should appear as output rows using GROUP BY and HAVING clauses.
  4. -
  5. Format and order the output rows and columns using SELECT and ORDER BY clauses.
  6. -
- -

SELECT (Step 3) FROM (Step 1) WHERE (Step 1) GROUP BY (Step 2) HAVING (Step 2) ORDER BY (Step 3);

- -

Step 1 may involve joining tables (using commas) to form input rows that consist of two or more rows from existing tables.

- -

The WHERE, GROUP BY, HAVING, and ORDER BY clauses are optional. -

- - -

Q4: A Secret Message

- - -

A substitution cipher replaces each word with another word in a table in order -to encrypt a message. To decode an encrypted message, replace each word x with -its corresponding y in a code table.

- -

Write a select statement to decode the original message It's The End -using the code table.

- - - - Your Answer - -
- Run in 61A Code - -
- - -
- Solution - -
CREATE TABLE original AS
-  SELECT 1 AS n, "It's" AS word UNION
-  SELECT 2     , "The"      UNION
-  SELECT 3     , "End";
-
-CREATE TABLE code AS
-  SELECT "Up" AS x, "Down" AS y UNION
-  SELECT "Now"    , "Home" UNION
-  SELECT "It's"   , "What" UNION
-  SELECT "See"    , "Do" UNION
-  SELECT "Can"    , "See" UNION
-  SELECT "End"    , "Now" UNION
-  SELECT "What"   , "You" UNION
-  SELECT "The"    , "Happens" UNION
-  SELECT "Love"   , "Scheme" UNION
-  SELECT "Not"    , "Mess" UNION
-  SELECT "Happens", "Go";
-
-SELECT y FROM original, code WHERE word=x ORDER BY n;
-
- -
- - - - -
- -

Join the original and code tables and make sure that the joined roles have -the same word and x.

- -
- -

What happens now? Write another select statement to decode this encrypted -message using the same code table.

- - - - Your Answer - -
- Run in 61A Code - -
- - -
- Solution - -
CREATE TABLE original AS
-  SELECT 1 AS n, "It's" AS word UNION
-  SELECT 2     , "The"      UNION
-  SELECT 3     , "End";
-
-CREATE TABLE code AS
-  SELECT "Up" AS x, "Down" AS y UNION
-  SELECT "Now"    , "Home" UNION
-  SELECT "It's"   , "What" UNION
-  SELECT "See"    , "Do" UNION
-  SELECT "Can"    , "See" UNION
-  SELECT "End"    , "Now" UNION
-  SELECT "What"   , "You" UNION
-  SELECT "The"    , "Happens" UNION
-  SELECT "Love"   , "Scheme" UNION
-  SELECT "Not"    , "Mess" UNION
-  SELECT "Happens", "Go";
-
-SELECT b.y
-  FROM original, code AS a, code AS b
-  WHERE word=a.x AND a.y=b.x
-  ORDER BY n;
-
- -
- - - - -
- -

Join original with code AS a and code AS b to create six-column rows like: -2|The|The|Happens|Happens|Go, The Go at the end is part of the decoded message.

- -
- -

Scheduling time: This is the last discussion, but you could schedule a -meeting with your group next week to study for the exam. Your regular discussion -room and time should be available during RRR week if you want to use it.

- - -

Document the Occasion

- - -

Please all fill out the attendance form (one submission per person per week).

- -

Important: Please help put the furniture in the room back where you found it before you leave. Thanks!

- - -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/proj/cats/proj02.ok b/proj/cats/proj02.ok deleted file mode 100644 index eb3b3259f..000000000 --- a/proj/cats/proj02.ok +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "Project 2: Cats", - "endpoint": "cal/cs61a/fa24/proj02", - "src": [ - "utils.py", - "cats.py" - ], - "default_tests": [ - "01", - "02", - "03", - "04", - "05", - "06", - "07", - "08", - "09", - "10", - "11", - "EC" - ], - "tests": { - "tests/01.py": "ok_test", - "tests/02.py": "ok_test", - "tests/03.py": "ok_test", - "tests/04.py": "ok_test", - "tests/05.py": "ok_test", - "tests/06.py": "ok_test", - "tests/07.py": "ok_test", - "tests/08.py": "ok_test", - "tests/09.py": "ok_test", - "tests/10.py": "ok_test", - "tests/11.py": "ok_test", - "tests/EC.py": "ok_test" - }, - "protocols": [ - "restore", - "file_contents", - "unlock", - "grading", - "analytics", - "collaborate", - "backup" - ] -} \ No newline at end of file diff --git a/proj/cats/tests/11.py b/proj/cats/tests/11.py deleted file mode 100644 index e9b2efb3f..000000000 --- a/proj/cats/tests/11.py +++ /dev/null @@ -1,1077 +0,0 @@ -test = { - 'name': 'Problem 11', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> p0 = [2, 2, 3] - >>> p1 = [6, 1, 2] - >>> fastest_words(match(['What', 'great', 'luck'], [p0, p1])) - c32c930f01f8eb69bdbf7fd0aa69abfd - # locked - >>> p0 = [2, 2, 3] - >>> p1 = [6, 1, 3] - >>> fastest_words(match(['What', 'great', 'luck'], [p0, p1])) # with a tie, choose the first player - 16d01ed6b3bcddbf19f54bd51db828e8 - # locked - >>> p2 = [4, 3, 1] - >>> fastest_words(match(['What', 'great', 'luck'], [p0, p1, p2])) - 212b9d436fcf404d25883f3c7b637515 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> p0 = [5, 1, 3] - >>> p1 = [4, 1, 6] - >>> fastest_words(match(['Just', 'have', 'fun'], [p0, p1])) - [['have', 'fun'], ['Just']] - >>> p0 # input lists should not be mutated - [5, 1, 3] - >>> p1 - [4, 1, 6] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3], [5]] - >>> fastest_words(match(['smopple'], p)) - [['smopple'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[]] - >>> fastest_words(match([], p)) - [[]] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5], [2], [4]] - >>> fastest_words(match(['seeingly'], p)) - [[], ['seeingly'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 1, 2, 3, 4], [1, 5, 3, 4, 1], [5, 1, 5, 2, 3]] - >>> fastest_words(match(['reundergo', 'unweld', 'handgun', 'hydrometra', 'recessionary'], p)) - [['unweld', 'handgun'], ['reundergo', 'recessionary'], ['hydrometra']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], [], []] - >>> fastest_words(match([], p)) - [[], [], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 1, 2]] - >>> fastest_words(match(['prebeleve', 'upanishadic', 'ftp'], p)) - [['prebeleve', 'upanishadic', 'ftp']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 3, 5, 2, 4], [2, 4, 5, 1, 2], [1, 5, 2, 1, 3]] - >>> fastest_words(match(['supplies', 'underivedly', 'henter', 'undeserving', 'uncope'], p)) - [['underivedly'], ['undeserving', 'uncope'], ['supplies', 'henter']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], [], []] - >>> fastest_words(match([], p)) - [[], [], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 5, 5, 5, 5]] - >>> fastest_words(match(['pentarch', 'nihilification', 'krieker', 'laureate', 'antechamber'], p)) - [['pentarch', 'nihilification', 'krieker', 'laureate', 'antechamber']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 4, 4, 3, 4]] - >>> fastest_words(match(['urodele', 'sporoid', 'auximone', 'nomenclatural', 'misappreciation'], p)) - [['urodele', 'sporoid', 'auximone', 'nomenclatural', 'misappreciation']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 4, 1, 1, 4, 1], [5, 3, 3, 4, 5, 3], [1, 2, 3, 1, 3, 5]] - >>> fastest_words(match(['isoborneol', 'glabrate', 'excision', 'octobass', 'prevolitional', 'archtreasurership'], p)) - [['excision', 'octobass', 'archtreasurership'], [], ['isoborneol', 'glabrate', 'prevolitional']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 2, 4, 3, 1], [3, 1, 2, 1, 3]] - >>> fastest_words(match(['singletree', 'apocyneous', 'imminution', 'uncensuring', 'fungiform'], p)) - [['fungiform'], ['singletree', 'apocyneous', 'imminution', 'uncensuring']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], []] - >>> fastest_words(match([], p)) - [[], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[]] - >>> fastest_words(match([], p)) - [[]] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 2], [3, 2]] - >>> fastest_words(match(['snideness', 'universalization'], p)) - [['snideness', 'universalization'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1], [3]] - >>> fastest_words(match(['dependably'], p)) - [['dependably'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 2, 1]] - >>> fastest_words(match(['spaceful', 'cautery', 'wiseness'], p)) - [['spaceful', 'cautery', 'wiseness']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 4, 5, 3, 5, 1], [4, 4, 1, 2, 5, 3]] - >>> fastest_words(match(['investigatable', 'quadrigenarious', 'protonemal', 'cardiodysneuria', 'provoker', 'associated'], p)) - [['investigatable', 'quadrigenarious', 'provoker', 'associated'], ['protonemal', 'cardiodysneuria']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 1]] - >>> fastest_words(match(['tubuliporoid', 'malleability'], p)) - [['tubuliporoid', 'malleability']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 1, 2, 4, 4], [3, 4, 3, 3, 5], [1, 2, 5, 1, 2]] - >>> fastest_words(match(['shilling', 'shrubbiness', 'demoded', 'commentary', 'housewright'], p)) - [['shrubbiness', 'demoded'], [], ['shilling', 'commentary', 'housewright']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 3, 3, 4, 1]] - >>> fastest_words(match(['ungraspable', 'owrelay', 'tangleproof', 'musterable', 'multivincular'], p)) - [['ungraspable', 'owrelay', 'tangleproof', 'musterable', 'multivincular']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 1, 4, 3, 1], [5, 5, 1, 2, 3]] - >>> fastest_words(match(['lithosis', 'bogland', 'interclash', 'widespread', 'thumbbird'], p)) - [['lithosis', 'bogland', 'thumbbird'], ['interclash', 'widespread']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 2], [3, 3]] - >>> fastest_words(match(['diplosphenal', 'cholecystogram'], p)) - [['diplosphenal', 'cholecystogram'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 2]] - >>> fastest_words(match(['eugenist', 'karyopyknosis'], p)) - [['eugenist', 'karyopyknosis']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 4, 3]] - >>> fastest_words(match(['cannily', 'lune', 'heathless'], p)) - [['cannily', 'lune', 'heathless']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 4, 3, 3], [2, 1, 3, 4], [2, 2, 4, 4]] - >>> fastest_words(match(['postprandially', 'helicogyrate', 'coccidology', 'circumradius'], p)) - [['coccidology', 'circumradius'], ['postprandially', 'helicogyrate'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 3], [1, 3], [5, 1]] - >>> fastest_words(match(['electrofused', 'incontinent'], p)) - [[], ['electrofused'], ['incontinent']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], []] - >>> fastest_words(match([], p)) - [[], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[]] - >>> fastest_words(match([], p)) - [[]] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], []] - >>> fastest_words(match([], p)) - [[], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 3, 2, 5, 3], [3, 3, 5, 5, 3]] - >>> fastest_words(match(['trigon', 'effluviate', 'unhuman', 'energeia', 'slouch'], p)) - [['trigon', 'effluviate', 'unhuman', 'energeia', 'slouch'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[]] - >>> fastest_words(match([], p)) - [[]] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 1, 1, 1, 2], [1, 1, 5, 3, 4]] - >>> fastest_words(match(['boucherism', 'rutabaga', 'fomentation', 'swampside', 'unpopularness'], p)) - [['rutabaga', 'fomentation', 'swampside', 'unpopularness'], ['boucherism']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 1], [1, 2]] - >>> fastest_words(match(['introspectionist', 'teeting'], p)) - [['teeting'], ['introspectionist']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 3, 1, 2, 3, 3]] - >>> fastest_words(match(['cryptodiran', 'coll', 'staurolatry', 'allthing', 'cheatrie', 'inexpedient'], p)) - [['cryptodiran', 'coll', 'staurolatry', 'allthing', 'cheatrie', 'inexpedient']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 4, 2, 2, 3], [1, 2, 5, 1, 3]] - >>> fastest_words(match(['quodlibetic', 'previdence', 'nonviscous', 'reduplicatively', 'arterioverter'], p)) - [['nonviscous', 'arterioverter'], ['quodlibetic', 'previdence', 'reduplicatively']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 2, 5, 1, 2, 1], [4, 2, 1, 4, 5, 3]] - >>> fastest_words(match(['cactoid', 'quadrialate', 'preflattery', 'emancipation', 'recedent', 'haustement'], p)) - [['cactoid', 'quadrialate', 'emancipation', 'recedent', 'haustement'], ['preflattery']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 1, 5, 4, 4, 4], [5, 2, 1, 1, 2, 3], [4, 5, 4, 2, 3, 2]] - >>> fastest_words(match(['puboprostatic', 'tumescent', 'keraunograph', 'telecaster', 'selenigenous', 'phycomycete'], p)) - [['puboprostatic', 'tumescent'], ['keraunograph', 'telecaster', 'selenigenous'], ['phycomycete']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 4, 2, 4, 2], [1, 5, 1, 4, 5]] - >>> fastest_words(match(['indisputableness', 'breastrope', 'hypocist', 'supersemination', 'ethnographically'], p)) - [['breastrope', 'supersemination', 'ethnographically'], ['indisputableness', 'hypocist']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 4, 3, 3, 5, 4]] - >>> fastest_words(match(['repetitiously', 'lecideiform', 'debtless', 'stream', 'loquent', 'leery'], p)) - [['repetitiously', 'lecideiform', 'debtless', 'stream', 'loquent', 'leery']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 3, 3, 3, 1, 4]] - >>> fastest_words(match(['siscowet', 'nevo', 'driftweed', 'chevronelly', 'victoryless', 'illustrations'], p)) - [['siscowet', 'nevo', 'driftweed', 'chevronelly', 'victoryless', 'illustrations']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 2, 5, 4], [5, 4, 2, 2]] - >>> fastest_words(match(['holland', 'nursedom', 'epidictical', 'defortify'], p)) - [['holland', 'nursedom'], ['epidictical', 'defortify']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 1, 3]] - >>> fastest_words(match(['sunbird', 'renewal', 'predivinable'], p)) - [['sunbird', 'renewal', 'predivinable']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[]] - >>> fastest_words(match([], p)) - [[]] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[]] - >>> fastest_words(match([], p)) - [[]] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 3, 4, 2], [5, 2, 2, 3]] - >>> fastest_words(match(['tillot', 'douser', 'twankingly', 'eccentrate'], p)) - [['tillot', 'eccentrate'], ['douser', 'twankingly']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 4, 5, 3]] - >>> fastest_words(match(['reest', 'predigest', 'adipocellulose', 'warriorwise'], p)) - [['reest', 'predigest', 'adipocellulose', 'warriorwise']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 1, 5, 3, 5]] - >>> fastest_words(match(['standing', 'cameroon', 'unpretendingly', 'puppydom', 'lardworm'], p)) - [['standing', 'cameroon', 'unpretendingly', 'puppydom', 'lardworm']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], []] - >>> fastest_words(match([], p)) - [[], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 4], [5, 5]] - >>> fastest_words(match(['cardioarterial', 'statolatry'], p)) - [['cardioarterial', 'statolatry'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 5, 4, 1]] - >>> fastest_words(match(['whirley', 'coldly', 'compendiary', 'grovel'], p)) - [['whirley', 'coldly', 'compendiary', 'grovel']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 1], [3, 3], [2, 4]] - >>> fastest_words(match(['caducicorn', 'monociliated'], p)) - [['caducicorn', 'monociliated'], [], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], []] - >>> fastest_words(match([], p)) - [[], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 3, 4, 5, 3]] - >>> fastest_words(match(['audibility', 'deuteride', 'mimiambic', 'isoimmunity', 'rhinopharynx'], p)) - [['audibility', 'deuteride', 'mimiambic', 'isoimmunity', 'rhinopharynx']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5], [4], [4]] - >>> fastest_words(match(['millage'], p)) - [[], ['millage'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 1], [5, 4]] - >>> fastest_words(match(['inyoite', 'complications'], p)) - [['inyoite', 'complications'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 2], [2, 2], [4, 1]] - >>> fastest_words(match(['sarcodous', 'microbiological'], p)) - [['sarcodous'], [], ['microbiological']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 4, 1], [2, 2, 3]] - >>> fastest_words(match(['chromophilic', 'brabant', 'detailed'], p)) - [['detailed'], ['chromophilic', 'brabant']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], []] - >>> fastest_words(match([], p)) - [[], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 1, 1, 1], [3, 1, 3, 3]] - >>> fastest_words(match(['allochiral', 'hear', 'snur', 'myosarcomatous'], p)) - [['hear', 'snur', 'myosarcomatous'], ['allochiral']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2], [5]] - >>> fastest_words(match(['studiedly'], p)) - [['studiedly'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 3, 3, 5, 2, 5]] - >>> fastest_words(match(['katatonia', 'myoporaceous', 'tribunitive', 'mungofa', 'demodectic', 'kolobion'], p)) - [['katatonia', 'myoporaceous', 'tribunitive', 'mungofa', 'demodectic', 'kolobion']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], []] - >>> fastest_words(match([], p)) - [[], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 2], [2, 2]] - >>> fastest_words(match(['cheeser', 'cumulation'], p)) - [['cumulation'], ['cheeser']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 2], [1, 3]] - >>> fastest_words(match(['overemphatic', 'telpherway'], p)) - [['telpherway'], ['overemphatic']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 4], [1, 2], [3, 5]] - >>> fastest_words(match(['ultradolichocephalic', 'kinetophone'], p)) - [[], ['ultradolichocephalic', 'kinetophone'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 5, 3]] - >>> fastest_words(match(['protosaurian', 'plumbable', 'siroccoishly'], p)) - [['protosaurian', 'plumbable', 'siroccoishly']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 5, 4, 5, 1, 1]] - >>> fastest_words(match(['hydroidean', 'pesterer', 'seedcase', 'rudder', 'muttering', 'individualize'], p)) - [['hydroidean', 'pesterer', 'seedcase', 'rudder', 'muttering', 'individualize']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 2, 1, 2], [2, 3, 5, 3]] - >>> fastest_words(match(['oleostearin', 'stitching', 'theanthropism', 'blate'], p)) - [['stitching', 'theanthropism', 'blate'], ['oleostearin']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 1], [2, 2]] - >>> fastest_words(match(['oscillatory', 'geophyte'], p)) - [['oscillatory', 'geophyte'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1], [2]] - >>> fastest_words(match(['withsave'], p)) - [['withsave'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 1, 1], [5, 3, 4]] - >>> fastest_words(match(['battlewise', 'dare', 'halibiu'], p)) - [['battlewise', 'dare', 'halibiu'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 1, 4, 2], [4, 3, 5, 5]] - >>> fastest_words(match(['muscoid', 'reliquidation', 'broad', 'tugging'], p)) - [['muscoid', 'reliquidation', 'broad', 'tugging'], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 2, 5]] - >>> fastest_words(match(['trophobiosis', 'parascenium', 'gibbet'], p)) - [['trophobiosis', 'parascenium', 'gibbet']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 1, 4]] - >>> fastest_words(match(['nonsparking', 'calool', 'dorsopleural'], p)) - [['nonsparking', 'calool', 'dorsopleural']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 4], [4, 4], [5, 3]] - >>> fastest_words(match(['unexcusableness', 'bismuthyl'], p)) - [['unexcusableness'], [], ['bismuthyl']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 4, 5, 5, 2], [1, 4, 1, 2, 4]] - >>> fastest_words(match(['evolution', 'intransigency', 'improperly', 'angiophorous', 'urinogenital'], p)) - [['intransigency', 'urinogenital'], ['evolution', 'improperly', 'angiophorous']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 5, 1]] - >>> fastest_words(match(['penceless', 'bromothymol', 'reticuloramose'], p)) - [['penceless', 'bromothymol', 'reticuloramose']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 4, 5, 2, 2, 3]] - >>> fastest_words(match(['monument', 'appressor', 'tutu', 'gentilize', 'trihemimeral', 'bifid'], p)) - [['monument', 'appressor', 'tutu', 'gentilize', 'trihemimeral', 'bifid']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 4, 3, 3, 5, 2]] - >>> fastest_words(match(['uncivilized', 'pairer', 'keratonyxis', 'chemitypy', 'checkroll', 'hymnographer'], p)) - [['uncivilized', 'pairer', 'keratonyxis', 'chemitypy', 'checkroll', 'hymnographer']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2], [4], [3]] - >>> fastest_words(match(['inclementness'], p)) - [['inclementness'], [], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[], []] - >>> fastest_words(match([], p)) - [[], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 1, 3, 1, 2, 4]] - >>> fastest_words(match(['bescorch', 'rodding', 'disawa', 'gastradenitis', 'cottabus', 'prescapularis'], p)) - [['bescorch', 'rodding', 'disawa', 'gastradenitis', 'cottabus', 'prescapularis']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4], [5], [4]] - >>> fastest_words(match(['transmundane'], p)) - [['transmundane'], [], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 3]] - >>> fastest_words(match(['becense', 'hyperingenuity'], p)) - [['becense', 'hyperingenuity']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 3, 4], [5, 5, 3], [3, 2, 3]] - >>> fastest_words(match(['interventional', 'demiditone', 'chrysophilite'], p)) - [[], ['chrysophilite'], ['interventional', 'demiditone']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 5, 3, 5, 1, 3], [1, 4, 3, 1, 3, 4], [1, 3, 1, 4, 4, 5]] - >>> fastest_words(match(['pyritology', 'marbleize', 'blooddrop', 'prickingly', 'ecole', 'capitellar'], p)) - [['ecole', 'capitellar'], ['pyritology', 'prickingly'], ['marbleize', 'blooddrop']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 5, 4, 5, 4, 3], [1, 3, 1, 1, 3, 5]] - >>> fastest_words(match(['epicotyledonary', 'hiro', 'tremolo', 'ringgiving', 'pignoratitious', 'untakableness'], p)) - [['untakableness'], ['epicotyledonary', 'hiro', 'tremolo', 'ringgiving', 'pignoratitious']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 3], [4, 3], [5, 5]] - >>> fastest_words(match(['tutoyer', 'fibrilliferous'], p)) - [['tutoyer', 'fibrilliferous'], [], []] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 2, 2, 1]] - >>> fastest_words(match(['aneuploidy', 'unrubified', 'dynamic', 'twistable'], p)) - [['aneuploidy', 'unrubified', 'dynamic', 'twistable']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 2, 2, 3]] - >>> fastest_words(match(['pholadoid', 'toxicodermatitis', 'gallification', 'survival'], p)) - [['pholadoid', 'toxicodermatitis', 'gallification', 'survival']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[3, 3, 1, 4, 5], [5, 2, 3, 2, 3]] - >>> fastest_words(match(['principiate', 'archinfamy', 'cacomixle', 'endonuclear', 'writer'], p)) - [['principiate', 'cacomixle'], ['archinfamy', 'endonuclear', 'writer']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[5, 5, 2, 4]] - >>> fastest_words(match(['mechanicalist', 'losing', 'emancipation', 'counterquarterly'], p)) - [['mechanicalist', 'losing', 'emancipation', 'counterquarterly']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 5, 1], [2, 1, 3]] - >>> fastest_words(match(['subframe', 'infinitude', 'astrochemist'], p)) - [['astrochemist'], ['subframe', 'infinitude']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2]] - >>> fastest_words(match(['isocheimal'], p)) - [['isocheimal']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 4, 4, 5], [5, 4, 5, 2]] - >>> fastest_words(match(['mistresshood', 'lazzarone', 'define', 'unmudded'], p)) - [['mistresshood', 'lazzarone', 'define'], ['unmudded']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[4, 5, 2, 2, 4], [3, 5, 4, 5, 1]] - >>> fastest_words(match(['either', 'ungenuine', 'dealable', 'pejorism', 'cointersecting'], p)) - [['ungenuine', 'dealable', 'pejorism'], ['either', 'cointersecting']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[2, 1]] - >>> fastest_words(match(['narcoanesthesia', 'tanbur'], p)) - [['narcoanesthesia', 'tanbur']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[]] - >>> fastest_words(match([], p)) - [[]] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> p = [[1, 4]] - >>> fastest_words(match(['overappraise', 'disdiapason'], p)) - [['overappraise', 'disdiapason']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from cats import match, fastest_words - """, - 'teardown': '', - 'type': 'doctest' - }, - { - 'cases': [ - { - 'code': r""" - >>> test.swap_implementations(cats) # Make sure the abstraction barrier isn't crossed! - >>> p0 = [2, 2, 3] - >>> p1 = [6, 1, 2] - >>> cats.fastest_words(cats.match(['What', 'great', 'luck'], [p0, p1])) - [['What'], ['great', 'luck']] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> import cats - >>> import tests.abstraction_check as test # Make sure the abstraction barrier isn't crossed! - """, - 'teardown': r""" - >>> test.restore_implementations(cats) - """, - 'type': 'doctest' - } - ] -} diff --git a/proj/cats/tests/abstraction_check.py b/proj/cats/tests/abstraction_check.py deleted file mode 100644 index 73ef1cf58..000000000 --- a/proj/cats/tests/abstraction_check.py +++ /dev/null @@ -1,79 +0,0 @@ -"""Infrastructure for detecting abstraction barrier violations.""" - -class AbstractionViolation(Exception): - pass - -def datatype(obj): - return type(obj).__name__ - -# Generic abstract data type -class Abstract: - def __add__(self, other): - raise AbstractionViolation("Can't add {} object to {}".format(datatype(self), datatype(other))) - - def __radd__(self, other): - raise AbstractionViolation("Can't add {} object to {}".format(datatype(self), datatype(other))) - - def __eq__(self, other): - if isinstance(other, type(self)): - return other is self - raise AbstractionViolation("Can't use == on {} object and {}".format(datatype(self), datatype(other))) - - def __ne__(self, other): - if isinstance(other, type(self)): - return other is not self - raise AbstractionViolation("Can't use != on {} object and {}".format(datatype(self), datatype(other))) - - def __bool__(self): - raise AbstractionViolation("Can't use {} object as a boolean".format(datatype(self))) - - def __getitem__(self, index): - raise AbstractionViolation("Can't use [] notation on {} object".format(datatype(self))) - - def __contains__(self, other): - raise AbstractionViolation("Can't use contains notation on {} object".format(datatype(self))) - - def __delitem__(self, other): - raise AbstractionViolation("Can't use del notation on {} object".format(datatype(self))) - - def __iter__(self): - raise AbstractionViolation("Can't iterate on {} object".format(datatype(self))) - - def __len__(self): - raise AbstractionViolation("Can't use len notation on {} object".format(datatype(self))) - - def __setitem__(self, key, item): - raise AbstractionViolation("Can't use setitem notation on {} object".format(datatype(self))) - - def __call__(self, *args, **kwargs): - raise AbstractionViolation("Can't call {} object".format(datatype(self))) - - def __hash__(self): - return id(self) - -class Match(Abstract): - def __init__(self, words, timestamps_per_player): - self.a, self.b = words, timestamps_per_player - def __repr__(self): - return ''.format(self.a, self.b) - -match = Match -get_word = lambda u, v: u.a[v] -get_all_words = lambda u: u.a -get_all_times = lambda u: u.b -get_time = lambda u, v, w: u.b[v][w] - -old = {} - -def swap_implementations(impl): - # save other implementations - old['match'] = impl.match, impl.get_word, impl.get_all_words, impl.get_all_times, impl.get_time - - # save our implementations - new_match = match, get_word, get_all_words, get_all_times, get_time - - # replace impl's implementations with ours - impl.match, impl.get_word, impl.get_all_words, impl.get_all_times, impl.get_time = match, get_word, get_all_words, get_all_times, get_time - -def restore_implementations(impl): - impl.match, impl.get_word, impl.get_all_words, impl.get_all_times, impl.get_time = old['match'] \ No newline at end of file