From 7f4baecbdf39585f401eafed8a9ce9354cd8c8a0 Mon Sep 17 00:00:00 2001 From: devo1ution Date: Tue, 19 Dec 2023 09:31:15 -0800 Subject: [PATCH] add all old problems --- content/extraProblems.json | 559 +++++++++++++++++++++++++++++++++++++ port_problems.mjs | 65 +++++ 2 files changed, 624 insertions(+) create mode 100644 port_problems.mjs diff --git a/content/extraProblems.json b/content/extraProblems.json index 58bac4edbe..4e5a1aaa13 100644 --- a/content/extraProblems.json +++ b/content/extraProblems.json @@ -1188,6 +1188,305 @@ "usacoId": "1305" } }, + { + "uniqueId": "usaco-641", + "name": "Field Reduction", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=641", + "source": "Bronze", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "641" + } + }, + { + "uniqueId": "usaco-1035", + "name": "Social Distancing I", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1035", + "source": "Bronze", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1035" + } + }, + { + "uniqueId": "usaco-1036", + "name": "Social Distancing II", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1036", + "source": "Bronze", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1036" + } + }, + { + "uniqueId": "usaco-1132", + "name": "Acowdemia II", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1132", + "source": "Bronze", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1132" + } + }, + { + "uniqueId": "usaco-1275", + "name": "Leaders", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1275", + "source": "Bronze", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1275" + } + }, + { + "uniqueId": "usaco-1299", + "name": "Hungry Cow", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1299", + "source": "Bronze", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1299" + } + }, + { + "uniqueId": "usaco-1300", + "name": "Stamp Grid", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1300", + "source": "Bronze", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1300" + } + }, + { + "uniqueId": "usaco-1325", + "name": "Rotate and Shift", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1325", + "source": "Bronze", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1325" + } + }, + { + "uniqueId": "usaco-618", + "name": "Circular Barn", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=618", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "618" + } + }, + { + "uniqueId": "usaco-942", + "name": "Left Out", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=942", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "942" + } + }, + { + "uniqueId": "usaco-1039", + "name": "Cereal", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1039", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1039" + } + }, + { + "uniqueId": "usaco-1278", + "name": "Find and Replace", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1278", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1278" + } + }, + { + "uniqueId": "usaco-1279", + "name": "Following Directions", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1279", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1279" + } + }, + { + "uniqueId": "usaco-1280", + "name": "Moo Route", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1280", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1280" + } + }, + { + "uniqueId": "usaco-1303", + "name": "Cow-libi", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1303", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1303" + } + }, + { + "uniqueId": "usaco-1304", + "name": "Moo Route II", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1304", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1304" + } + }, + { + "uniqueId": "usaco-1326", + "name": "Milk Sum", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1326", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1326" + } + }, + { + "uniqueId": "usaco-1328", + "name": "Pareidolia", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1328", + "source": "Silver", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1328" + } + }, + { + "uniqueId": "usaco-621", + "name": "Circular Barn", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=621", + "source": "Gold", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "621" + } + }, + { + "uniqueId": "usaco-837", + "name": "Out of Sorts", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=837", + "source": "Gold", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "837" + } + }, + { + "uniqueId": "usaco-947", + "name": "Balancing Inversions", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=947", + "source": "Gold", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "947" + } + }, + { + "uniqueId": "usaco-1067", + "name": "Square Pasture", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1067", + "source": "Gold", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1067" + } + }, + { + "uniqueId": "usaco-1163", + "name": "Bracelet Crossings", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1163", + "source": "Gold", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1163" + } + }, { "uniqueId": "usaco-1306", "name": "Fertilizing Pastures", @@ -1200,6 +1499,266 @@ "kind": "USACO", "usacoId": "1306" } + }, + { + "uniqueId": "usaco-1329", + "name": "Custodial Cleanup", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1329", + "source": "Gold", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1329" + } + }, + { + "uniqueId": "usaco-1330", + "name": "Pareidolia", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1330", + "source": "Gold", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1330" + } + }, + { + "uniqueId": "usaco-1331", + "name": "Tree Merging", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1331", + "source": "Gold", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1331" + } + }, + { + "uniqueId": "usaco-649", + "name": "Bull in a China Shop", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=649", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "649" + } + }, + { + "uniqueId": "usaco-745", + "name": "Switch Grass", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=745", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "745" + } + }, + { + "uniqueId": "usaco-818", + "name": "Cow Gymnasts", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=818", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "818" + } + }, + { + "uniqueId": "usaco-840", + "name": "Out of Sorts", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=840", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "840" + } + }, + { + "uniqueId": "usaco-902", + "name": "Train Tracking 2", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=902", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "902" + } + }, + { + "uniqueId": "usaco-924", + "name": "Cow Dating", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=924", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "924" + } + }, + { + "uniqueId": "usaco-1070", + "name": "Cowmistry", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1070", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1070" + } + }, + { + "uniqueId": "usaco-1236", + "name": "262144 Revisited", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1236", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1236" + } + }, + { + "uniqueId": "usaco-1237", + "name": "Hoof and Brain", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1237", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1237" + } + }, + { + "uniqueId": "usaco-1238", + "name": "Up Down Subsequence", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1238", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1238" + } + }, + { + "uniqueId": "usaco-1284", + "name": "Tractor Paths", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1284", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1284" + } + }, + { + "uniqueId": "usaco-1285", + "name": "Mana Collection", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1285", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1285" + } + }, + { + "uniqueId": "usaco-1286", + "name": "Subtree Activation", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1286", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1286" + } + }, + { + "uniqueId": "usaco-1308", + "name": "Hungry Cow", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1308", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1308" + } + }, + { + "uniqueId": "usaco-1310", + "name": "Watching Cowflix", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1310", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1310" + } + }, + { + "uniqueId": "usaco-1333", + "name": "Good Bitstrings", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1333", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1333" + } + }, + { + "uniqueId": "usaco-1334", + "name": "Triples of Cows", + "url": "http://usaco.org/index.php?page=viewproblem2&cpid=1334", + "source": "Platinum", + "difficulty": "Easy", + "isStarred": false, + "tags": [], + "solutionMetadata": { + "kind": "USACO", + "usacoId": "1334" + } } ] } diff --git a/port_problems.mjs b/port_problems.mjs new file mode 100644 index 0000000000..3948bf0668 --- /dev/null +++ b/port_problems.mjs @@ -0,0 +1,65 @@ +// run `node usaco_util.mjs` +import { writeFileSync } from 'fs'; +import * as readline from 'readline'; +import axios from 'axios'; +import extraProblems from './content/extraProblems.json' assert { type: 'json' }; +import div_to_probs from './src/components/markdown/ProblemsList/DivisionList/div_to_probs.json' assert { type: 'json' }; +import id_to_sol from './src/components/markdown/ProblemsList/DivisionList/id_to_sol.json' assert { type: 'json' }; +import * as prettier from 'prettier'; +import { config } from 'dotenv'; +import algoliasearch from 'algoliasearch'; +config({ + path: '.env.production', +}); + +const client = algoliasearch( + process.env.ALGOLIA_APP_ID, + process.env.ALGOLIA_API_KEY +); +const index = client.initIndex('dev_problems'); + +const objects = [ + { + objectID: 'usaco-1307', + }, +]; + +index.search('', { filters: `objectID: usaco-1306` }).then(({ hits }) => { + console.log('here'); + console.log(hits); + console.log(!hits.length); +}); + +const { hits } = await index.search('', { filters: `objectID: usaco-1305` }); +console.log(hits); + +for (const division in div_to_probs) { + for (const [id, contest, title] of div_to_probs[division]) { + const { hits } = await index.search('', { + filters: `objectID: usaco-${id}`, + }); + if (!hits.length) { + console.log(`adding problem ${id}`); + extraProblems.EXTRA_PROBLEMS.push({ + uniqueId: `usaco-${id}`, + name: title, + url: `http://usaco.org/index.php?page=viewproblem2&cpid=${id}`, + source: division, + difficulty: 'Easy', + isStarred: false, + tags: [], + solutionMetadata: { + kind: 'USACO', + usacoId: id, + }, + }); + } + } +} +writeFileSync( + './content/extraProblems.json', + await prettier.format(JSON.stringify(extraProblems, null, '\t'), { + parser: 'json', + }), + 'utf8' +);