Dictionary Challenge

Hard Dictionaries PRO
🔒 Login to Unlock

Problem Statement

Write a Python program that inverts a dictionary (swaps keys and values) and prints the new dictionary sorted by the new keys.

Input Format

Space-separated key-value pairs.

Output Format

Print the inverted and sorted dictionary representation.

Constraints

Unique values

Sample Input

a 1 b 2 c 3

Sample Output

{1: 'a', 2: 'b', 3: 'c'}

Explanation

Iterate through `d.items()` and assign `new_dict[v] = k`, then sort by keys.

Starter Code

def invert_dict(d):
    # Write your code here
    pass

raw = input().split()
d = {raw[i]: int(raw[i+1]) for i in range(0, len(raw), 2)}
print(invert_dict(d))

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