---
Submission Notes
This single solution contains written answers for all problems (A–E).
Programming problems (B and D) include clear algorithm descriptions and commented Python
3.9 source code inline.
Stand-alone code files for B and D are provided separately (same code as inline).
---
Problem A — Neural Network Components
We identify standard components in a two-layer (one hidden layer) multi-layer perceptron.
w(1)₂₁: Weight connecting input feature x₁ to hidden neuron h₂.
Σ: Weighted sum inside a neuron (∑ w·x + b).
f: Non-linear activation (ReLU, sigmoid, …).
Box A: Hidden layer (vector of hidden units).
Box B: Output neuron/layer before applying final activation.
ŷ: Model prediction (e.g., probability of customer satisfaction).
---
Problem B — Cake Calculator
We need maximum cakes given flour and sugar. Each cake: 100 flour + 50 sugar.
Formula:
cakes = min(flour // 100, sugar // 50)
remaining_flour = flour − 100*cakes
remaining_sugar = sugar − 50*cakes
Python 3.9 reference solution:
# Problem B — Python 3.9 reference solution
from typing import List, Tuple
def cake_calculator(flour: int, sugar: int) -> Tuple[int, int, int]:
"""
Returns (cakes, remaining_flour, remaining_sugar).
Each cake needs 100 flour and 50 sugar.
Preconditions: flour > 0, sugar > 0 (integers).
"""
if not isinstance(flour, int) or not isinstance(sugar, int):
raise TypeError("flour and sugar must be integers")
if flour <= 0 or sugar <= 0:
raise ValueError("flour and sugar must be > 0")
cakes = min(flour // 100, sugar // 50)
remaining_flour = flour - 100 * cakes
remaining_sugar = sugar - 50 * cakes
return cakes, remaining_flour, remaining_sugar
# Example:
# print(cake_calculator(550, 330)) # -> (5, 50, 80)
---
Problem C — School Messaging App (Entropy & Coding)
Q1. Variable-length codes: short codewords for frequent characters reduce average
length → more efficiency. Example: A (70%) → 0, B (30%) → 1 uses 1 bit/char; fixed
2-bit wastes ~1 bit/char.
Q2. Entropy calculation:
bits/char.
This is the theoretical lower bound.
Q3. Given Fano code average length:
bits/char.
Redundancy = 0.145 bits/char (~4.1% overhead).
Efficiency ≈ 95.9% (close to optimal).
---
Problem D — Word Search Puzzle Generator
We must place given words in a 10×10 grid in all directions
(horizontal/vertical/diagonal, forward/backward). Random placement until fit. Empty
cells → random letters.
Python 3.9 reference solution:
# Problem D — Python 3.9 reference solution
from typing import List, Tuple
import random
import string
def create_crossword(words: List[str]) -> List[List[str]]:
"""
Creates a 10x10 word search puzzle containing the given words.
Words are placed horizontally/vertically/diagonally, forward or backward.
Returns a 2D list of single-character strings.
"""
size = 10
grid = [['' for _ in range(size)] for _ in range(size)]
directions = [
(0, 1), (0, -1), (1, 0), (-1, 0),
(1, 1), (1, -1), (-1, 1), (-1, -1)
]
def can_place(word: str, r: int, c: int, dr: int, dc: int) -> bool:
for i, ch in enumerate(word):
rr, cc = r + dr*i, c + dc*i
if not (0 <= rr < size and 0 <= cc < size):
return False
cell = grid[rr][cc]
if cell not in ('', ch):
return False
return True
def place(word: str, r: int, c: int, dr: int, dc: int):
for i, ch in enumerate(word):
rr, cc = r + dr*i, c + dc*i
grid[rr][cc] = ch
words_norm = [w.strip().upper().replace(' ', '') for w in words if w.strip()]
random.shuffle(words_norm)
for word in words_norm:
placed = False
for _ in range(500):
dr, dc = random.choice(directions)
r = random.randrange(0, 10)
c = random.randrange(0, 10)
if can_place(word, r, c, dr, dc):
place(word, r, c, dr, dc)
placed = True
break
if not placed:
raise RuntimeError(f"Could not place word: {word}")
for r in range(10):
for c in range(10):
if grid[r][c] == '':
grid[r][c] = random.choice(string.ascii_uppercase)
return grid
# Example:
# puzzle = create_crossword(["learning", "science", "fun"])
# for row in puzzle:
# print(' '.join(row))
---
Problem E — Functional Completeness of NAND
Define .
NOT: ¬x = x ↑ x
AND: x ∧ y = (x ↑ y) ↑ (x ↑ y)
OR: x ∨ y = (x ↑ x) ↑ (y ↑ y)
Since {NOT, AND, OR} is universal, NAND alone is functionally complete.
---
End of Solutions
---
Standalone Code Files
Problem B — problem_b_cake_calculator.py
# ICSC Qualification Round 2025 — Problem B: Cake Calculator
from typing import Tuple
def cake_calculator(flour: int, sugar: int) -> Tuple[int, int, int]:
"""Return (cakes, remaining_flour, remaining_sugar)."""
if not isinstance(flour, int) or not isinstance(sugar, int):
raise TypeError("flour and sugar must be integers")
if flour <= 0 or sugar <= 0:
raise ValueError("flour and sugar must be > 0")
cakes = min(flour // 100, sugar // 50)
remaining_flour = flour - 100 * cakes
remaining_sugar = sugar - 50 * cakes
return cakes, remaining_flour, remaining_sugar
if __name__ == "__main__":
example = (550, 330)
result = cake_calculator(*example)
print(f"Input flour={example[0]}, sugar={example[1]} -> cakes={result[0]}, flour_left={result[1]},
sugar_left={result[2]}")
---
Problem D — problem_d_word_search.py
# ICSC Qualification Round 2025 — Problem D: Word Search Puzzle
from typing import List
import random
import string
def create_crossword(words: List[str]) -> List[List[str]]:
"""Creates a 10x10 word search puzzle containing the given words."""
size = 10
grid = [['' for _ in range(size)] for _ in range(size)]
directions = [
(0, 1), (0, -1), (1, 0), (-1, 0),
(1, 1), (1, -1), (-1, 1), (-1, -1)
]
def can_place(word: str, r: int, c: int, dr: int, dc: int) -> bool:
for i, ch in enumerate(word):
rr, cc = r + dr*i, c + dc*i
if not (0 <= rr < size and 0 <= cc < size):
return False
cell = grid[rr][cc]
if cell not in ('', ch):
return False
return True
def place(word: str, r: int, c: int, dr: int, dc: int):
for i, ch in enumerate(word):
rr, cc = r + dr*i, c + dc*i
grid[rr][cc] = ch
words_norm = [w.strip().upper().replace(' ', '') for w in words if w.strip()]
random.shuffle(words_norm)
for word in words_norm:
placed = False
for _ in range(500):
dr, dc = random.choice(directions)
r = random.randrange(0, 10)
c = random.randrange(0, 10)
if can_place(word, r, c, dr, dc):
place(word, r, c, dr, dc)
placed = True
break
if not placed:
raise RuntimeError(f"Could not place word: {word}")
for r in range(10):
for c in range(10):
if grid[r][c] == '':
grid[r][c] = random.choice(string.ascii_uppercase)
return grid
if __name__ == "__main__":
random.seed(42)
puzzle = create_crossword(["learning", "science", "fun"])
for row in puzzle:
print(' '.join(row))
---