The Hash Code CLI is an interactive terminal application that allows you to explore Google Hash Code challenges from different years, view detailed problem descriptions, understand solution approaches, and run solutions on the provided input files.
- .NET 9.0 SDK (or later)
- Terminal with Unicode support (for best visual experience)
-
Navigate to the CLI directory:
cd src/HashCodeCli -
Run the application:
dotnet run
-
Or build and run the executable:
dotnet build cd bin/Debug/net9.0 ./HashCodeCli
From the main menu, select "View all challenges by year" to:
- See all available years (2014, 2015, etc.)
- Select a year to view all challenges from that year
- Each challenge shows its name and round (Qualification/Final)
Example Navigation:
Main Menu → View all challenges by year → 2015 → Optimize a Data Center
Select "Search challenges" from the main menu to:
- Enter a search term (e.g., "data center", "street", "loon")
- See all matching challenges
- Select one to view details
Search matches against:
- Challenge name
- Short description
- Round name
For each challenge, you can:
- Complete problem statement
- Input format details
- Output requirements
- Scoring information
- Solution approach and strategy
- Key algorithms used
- Code concepts demonstrated
- Implementation highlights
- Execute the solution on the challenge's input file
- See parsed input statistics
- View solution output
Street View Routing
- Problem: Optimize routes for Street View cars to maximize city coverage
- Input: Paris dataset with 54,000 junctions
- Solution: Graph algorithms with greedy route optimization
- Status: ✅ Runnable
Optimize a Data Center
- Problem: Optimize server placement to maximize data center availability
- Input: Data center layout with rows, slots, and servers
- Solution: Greedy placement with pool balancing
- Status: ✅ Runnable
Loon
- Problem: Plan altitude adjustments for Internet-providing balloons
- Input: Wind data and target coverage locations
- Solution: Not yet implemented
- Status:
⚠️ Description only
- Use arrow keys to navigate menu options
- Press Enter to select an option
- Select "Back" to return to the previous menu
- Select "Exit" from the main menu to quit
HashCodeCli/
├── Models/
│ └── Challenge.cs # Data model for challenges
├── Solutions/
│ ├── StreetViewSolution.cs # 2014 solution runner
│ └── DataCenterSolution.cs # 2015 solution runner
├── ChallengeRepository.cs # Challenge database
└── Program.cs # Main CLI application
- .NET 9.0 - Latest .NET runtime
- C# 13 - Latest C# language features
- Spectre.Console - Beautiful terminal UI library
- Interactive prompts
- Colored output
- Panels and formatting
- Spinner animations
Each solution runner:
- Validates the input file exists
- Parses the input file format
- Processes the challenge data
- Returns formatted output with results
For demonstration purposes, the current solutions parse and display input file statistics. Full algorithmic solutions from the original F# code can be ported as needed.
- Open
ChallengeRepository.cs - Add a new
Challengerecord to theGetAllChallenges()method:
new Challenge(
Year: 2016,
Round: "Qualification Round",
Name: "Your Challenge Name",
ShortDescription: "Brief one-line description",
FullDescription: @"Complete problem description...",
SolutionExplanation: @"Solution approach...",
InputFilePath: "path/to/input.txt",
SolutionRunner: YourSolution.Run
)- If the challenge has a runnable solution, create a solution class in
Solutions/:
namespace HashCodeCli.Solutions;
public static class YourSolution
{
public static string Run(string inputFilePath)
{
// Implementation
return "Output";
}
}This error occurs when running in a non-interactive environment (CI/CD, pipes, etc.). The CLI requires an interactive terminal with TTY support.
Solution: Run directly in a terminal, not through pipes or automation tools.
If a solution runner reports "Input file not found":
- Verify the input file exists in the repository
- Check the path in
ChallengeRepository.cs - Ensure the path is relative to the repository root
If you encounter build errors:
cd src/HashCodeCli
dotnet clean
dotnet restore
dotnet buildTo contribute new challenges or improve solutions:
- Add challenge data to the repository
- Update
ChallengeRepository.cswith challenge details - Implement solution runners in the
Solutions/directory - Test thoroughly before submitting
This project follows the repository's MIT License. See the main LICENSE file for details.