Bidirectional Association

Medium Composition & Aggregation PRO
🔒 Login to Unlock

Problem Statement

Create `Author` and `Book` classes. When `Author.write(book)` is called, it should set `self.book = book` AND `book.author = self`. Print ‘[Author] wrote [Book]’ and then on a new line ‘[Book] written by [Author]’ by accessing the properties backwards from the Book object.

Input Format

Two lines: Author name then Book title.

Output Format

Print the bidirectional link messages on two lines.

Constraints

None

Sample Input

Tolkien
Hobbit

Sample Output

Tolkien wrote Hobbit
Hobbit written by Tolkien

Explanation

In a bidirectional association, both objects maintain a reference to each other, allowing traversal in either direction.

Starter Code

class Book:
    pass

class Author:
    pass

if __name__ == '__main__':
    auth = input().strip()
    title = input().strip()
    # Establish bidirectional link and print
    pass

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used