Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
073ea31
(miniscoreboard): upgrade to V3 with leaderboard, summary and export
utkuhanakar Apr 20, 2026
0b507c6
Revise prompts and add v3 specifications for miniscoreboard
utkuhanakar Apr 20, 2026
1615f7e
Update SPEC-v3.txt
utkuhanakar Apr 20, 2026
1308eb8
Merge branch 'main' into main
utkuhanakar Apr 20, 2026
f728052
Update problem.json with v3 prompt and spec
utkuhanakar Apr 20, 2026
00f5bea
Add development plan for miniscoreboard project
utkuhanakar Apr 21, 2026
ff560c1
Add walkthrough for V3 implementation details
utkuhanakar Apr 21, 2026
a29129f
Update problem.json
utkuhanakar Apr 21, 2026
dcc9d8d
Update SPEC-v1.txt
utkuhanakar Apr 21, 2026
1adcc6f
Update SPEC-v2.txt
utkuhanakar Apr 21, 2026
8fc12b6
Update test-v1.sh
utkuhanakar Apr 21, 2026
3a9a8f1
Update test-v2.sh
utkuhanakar Apr 21, 2026
42b7cda
Update problem.json
utkuhanakar Apr 21, 2026
20d75ba
Merge branch 'seyyah:main' into main
utkuhanakar Apr 21, 2026
bc38ae3
Delete README.md
utkuhanakar Apr 21, 2026
93ecfa6
Delete plan.md
utkuhanakar Apr 21, 2026
c4bcf8c
Delete walkthrough.md
utkuhanakar Apr 21, 2026
ce5fb6e
Delete test-v3.sh
utkuhanakar Apr 21, 2026
de20321
Delete SPEC-v3.txt
utkuhanakar Apr 21, 2026
ee0778e
Update problem.json
utkuhanakar Apr 21, 2026
acba9b6
Update SPEC-v2.txt
utkuhanakar Apr 21, 2026
d7cfa67
Update test-v1.sh
utkuhanakar Apr 21, 2026
cf83873
Update test-v2.sh
utkuhanakar Apr 21, 2026
84cb4ab
Update test-v2.sh
utkuhanakar Apr 21, 2026
69c59a7
Update test-v1.sh
utkuhanakar Apr 21, 2026
512d8f5
Update test-v1.sh
utkuhanakar Apr 21, 2026
8f00758
Update test-v2.sh
utkuhanakar Apr 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion problems/miniscoreboard/SPEC-v1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ ERROR HANDLING
- Inputs containing '|': print "Error: The '|' character is reserved."
- Non-numeric scores: print "Error: Scores must be positive numbers."
- Empty team names: print "Error: Team names cannot be empty."
- Team playing itself: print "Error: A team cannot play against itself."
- Team playing itself: print "Error: A team cannot play against itself."
57 changes: 22 additions & 35 deletions problems/miniscoreboard/SPEC-v2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,45 @@ OVERVIEW
========================================

miniscoreboard is a command-line sports match management tool.
It stores match records in a plain text file and supports
initializing the system, adding new match results, viewing
historical matches, and filtering by team.

All data is persisted in a directory called .miniscore/
in the current working directory.
This version improves the system by adding data retrieval,
filtering capabilities, and stronger validation rules.

========================================
COMMANDS
NEW FEATURES (V2 IMPROVEMENTS)
========================================

--- init ---
Usage: python miniscore.py init
Creates a .miniscore/ directory and an empty matches.dat file.
If .miniscore/ already exists, prints "Already initialized".
1. Match History Retrieval
2. Team-based Filtering
3. Input Validation Enhancements

--- add-match ---
Usage: python miniscore.py add-match <League> <Week> <Date> <TeamA> <ScoreA> <TeamB> <ScoreB>
Appends a new match to matches.dat.
Each match has: id (auto-increment), league, week, date, teama, scorea, teamb, scoreb.
Prints "Added match #<id>: [<League> - <Week>] <TeamA> <ScoreA> - <ScoreB> <TeamB> on <Date>"
========================================
COMMANDS
========================================

--- history ---
Usage: python miniscore.py history
Reads the .miniscore/matches.dat file and prints all matches.
Format per line: [<ID>] <TeamA> <ScoreA> - <ScoreB> <TeamB> (<Date>)
Lists all matches in the system.
If no matches exist, prints "History is empty."

--- team ---
Usage: python miniscore.py team <TeamName>
Filters matches and prints only the ones where <TeamName> played
(either as TeamA or TeamB).
Format per line: [<League> - <Week>] <TeamA> <ScoreA> - <ScoreB> <TeamB> (<Date>)
If no matches are found, prints "No matches found for <TeamName>."
Filters matches where the given team participated.
If no matches found, prints "No matches found for <TeamName>."

========================================
DATA FORMAT
VALIDATION RULES
========================================

File: .miniscore/matches.dat
Format: One match per line, fields separated by |
Example:
1|SuperLig|W1|2026-04-01|GALATASARAY|2|FENERBAHCE|1
- Input cannot contain '|'
- Scores must be numeric and positive
- Team names cannot be empty
- A team cannot play against itself

========================================
ERROR HANDLING
IMPROVEMENT SUMMARY
========================================

- Running any command before "init": print "Not initialized."
- Invalid command: print "Unknown command: <command>"
- Missing arguments: print "Usage: python miniscore.py <command> [args]"
- Inputs containing '|': print "Error: The '|' character is reserved."
- Non-numeric scores: print "Error: Scores must be positive numbers."
- Empty team names: print "Error: Team names cannot be empty."
- Team playing itself: print "Error: A team cannot play against itself."
Compared to V1:
- System now supports reading stored data
- Users can filter matches by team
- Input errors are handled more strictly
6 changes: 3 additions & 3 deletions problems/miniscoreboard/problem.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"binary_name": "miniscore",
"v1_spec": "SPEC-v1.txt",
"v1_test": "test-v1.sh",
"v1_prompt": "Implement {{binary_name}} as described in SPEC-v1.txt using {{language}}. The executable must be named '{{binary_name}}' and be runnable as ./{{binary_name}}. For compiled languages, include a Makefile or build script. For interpreted languages, ensure the {{binary_name}} file has a proper shebang line and is executable. Handle init and add-match commands. Verify your implementation passes all tests by running: bash test-v1.sh",
"v1_prompt": "Implement {{binary_name}} as described in SPEC-v1.txt. Use standard libraries. Verification: bash test-v1.sh",
"v2_spec": "SPEC-v2.txt",
"v2_test": "test-v2.sh",
"v2_prompt": "Read SPEC-v2.txt and extend the existing {{binary_name}} implementation with the history and team commands. Verify your implementation using bash test-v2.sh."
}
"v2_prompt": "Extend {{binary_name}} to support 'history' and 'team' commands according to SPEC-v2.txt. Verification: bash test-v2.sh"
}
30 changes: 10 additions & 20 deletions problems/miniscoreboard/test-v1.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
#!/bin/bash

# miniscoreboard v1 test script
set -e

rm -rf .miniscore

# Test 1: Init Command
# Test 1: Init
INIT_OUT=$(python3 miniscore.py init)
if [[ "$INIT_OUT" != *"Initialized"* ]]; then
echo "FAIL: Init command did not work."
exit 1
fi
echo "$INIT_OUT" | grep -E "Initialized|Created" >/dev/null || exit 1

# Test 2: Add Match Command
ADD_OUT=$(python3 miniscore.py add-match SuperLig W1 2026-03-31 Galatasaray 2 Fenerbahce 1)
if [[ "$ADD_OUT" != *"Added match #1"* ]]; then
echo "FAIL: Add match command did not work correctly."
exit 1
fi
# Test 2: Add Match
ADD_OUT=$(python3 miniscore.py add-match SuperLig W1 2026-03-31 GS 2 FB 1)
echo "$ADD_OUT" | grep "Added match #1" >/dev/null || exit 1

# Test 3: Validation (Clone Match)
# Test 3: Validation (same team)
CLONE_OUT=$(python3 miniscore.py add-match SuperLig W1 2026-03-31 GS 2 GS 1)
if [[ "$CLONE_OUT" != *"Error"* ]]; then
echo "FAIL: Security validation failed for clone teams."
exit 1
fi
echo "$CLONE_OUT" | grep "Error" >/dev/null || exit 1

echo "All V1 tests passed."
exit 0
echo "All V1 tests passed"
exit 0
78 changes: 39 additions & 39 deletions problems/miniscoreboard/test-v2.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
#!/bin/bash

# miniscoreboard v2 test script (Includes V1 + V2 capabilities)
set -e

rm -rf .miniscore

# --- V1 COMMAND TESTS ---
# --- SETUP ---
python3 miniscore.py init

# Test 1: Init Command
INIT_OUT=$(python3 miniscore.py init)
if [[ "$INIT_OUT" != *"Initialized"* ]]; then
echo "FAIL: Init command did not work."
exit 1
fi
python3 miniscore.py add-match SuperLig W1 2026-04-01 GS 2 FB 1 > /dev/null
python3 miniscore.py add-match SuperLig W2 2026-04-07 BJK 3 TS 0 > /dev/null
python3 miniscore.py add-match SuperLig W3 2026-04-10 FB 1 BJK 1 > /dev/null

# Test 2: Add Match Command
ADD_OUT=$(python3 miniscore.py add-match SuperLig W1 2026-04-01 Galatasaray 2 Fenerbahce 1)
if [[ "$ADD_OUT" != *"Added match #1"* ]]; then
echo "FAIL: Add match command did not work correctly."
exit 1
fi
# --- V1 TESTS ---
ADD_CHECK=$(python3 miniscore.py add-match SuperLig W4 2026-04-11 TS 2 GS 0)
echo "$ADD_CHECK" | grep "Added match #4" >/dev/null || exit 1

# Test 3: Validation (Clone Match)
CLONE_OUT=$(python3 miniscore.py add-match SuperLig W1 2026-04-01 GS 2 GS 1)
if [[ "$CLONE_OUT" != *"Error"* ]]; then
echo "FAIL: Security validation failed for clone teams."
exit 1
fi
# --- V2 TESTS ---

# --- V2 COMMAND TESTS ---
# History
HIST=$(python3 miniscore.py history)
echo "$HIST" | grep "GS" >/dev/null || exit 1
echo "$HIST" | grep "BJK" >/dev/null || exit 1

# Add more data for V2 filtering tests
python3 miniscore.py add-match SuperLig W2 2026-04-07 BJK 3 TS 0 > /dev/null
# Team filter
TEAM=$(python3 miniscore.py team BJK)
echo "$TEAM" | grep "TS" >/dev/null || exit 1

# Validation
INVALID=$(python3 miniscore.py add-match SuperLig W5 2026-04-12 GS 2 GS 1)
echo "$INVALID" | grep "Error" >/dev/null || exit 1

# --- ADVANCED ---

# Leaderboard
LB=$(python3 miniscore.py leaderboard)
echo "$LB" | grep "\[1\]" >/dev/null || exit 1

# Summary
SUM=$(python3 miniscore.py summary)
echo "$SUM" | grep "Total Matches" >/dev/null || exit 1

# Export
EXP=$(python3 miniscore.py export)
echo "$EXP" | grep "Exported" >/dev/null || exit 1

# File check
[ -f ".miniscore/matches.json" ] || exit 1

# Test 4: History Command
HIST_OUT=$(python3 miniscore.py history)
if [[ "$HIST_OUT" != *"Galatasaray"* ]] || [[ "$HIST_OUT" != *"BJK"* ]]; then
echo "FAIL: History command did not list all matches."
exit 1
fi

# Test 5: Team Filter Command
TEAM_OUT=$(python3 miniscore.py team BJK)
if [[ "$TEAM_OUT" != *"TS"* ]] || [[ "$TEAM_OUT" == *"Galatasaray"* ]]; then
echo "FAIL: Team command filtering is broken."
exit 1
fi

echo "All V1 and V2 tests passed."
echo "All V1 + V2 (enhanced) tests passed"
exit 0
Loading