-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from ProvideQ/feat/Knapsack-Problem
Added Knapsack problem interface
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Heading, Link, Text } from "@chakra-ui/react"; | ||
import { NextPage } from "next"; | ||
import { useState } from "react"; | ||
import { Layout } from "../../components/layout/Layout"; | ||
import { SolverConfiguration } from "../../components/solvers/SolverConfiguration"; | ||
import { TextInputMask } from "../../components/solvers/TextInputMask"; | ||
|
||
const Knapsack: NextPage = () => { | ||
const [knapsackProblem, setKnapsackProblem] = useState(""); | ||
|
||
return ( | ||
<Layout> | ||
<Heading as="h1">Knapsack Solver</Heading> | ||
|
||
<Text color="text" align="justify"> | ||
In the 0-1 knapsack problem, we are given a list of items, each with a | ||
weight and a value, and the maximum weight that the knapsack can hold. | ||
The goal is to find the subset of items that maximizes the total value | ||
while keeping the total weight below the maximum weight. Example | ||
problems and an explanation of the input format can be found{" "} | ||
<Link | ||
href="https://github.com/ProvideQ/knapsack-problems" | ||
color={"blue.400"} | ||
> | ||
here | ||
</Link> | ||
. | ||
</Text> | ||
|
||
<TextInputMask | ||
problemTypeId="knapsack" | ||
text={knapsackProblem} | ||
setText={setKnapsackProblem} | ||
textPlaceholder="Enter your knapsack problem" | ||
/> | ||
|
||
<SolverConfiguration | ||
problemTypeId="knapsack" | ||
problemInput={knapsackProblem} | ||
/> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default Knapsack; |