{"id":22696161,"url":"https://github.com/zdimension/stablewall","last_synced_at":"2025-03-29T18:11:39.078Z","repository":{"id":97140956,"uuid":"275546292","full_name":"zdimension/stablewall","owner":"zdimension","description":"Solution to the GKS 2020 Round C problem \"Stable Wall\"","archived":false,"fork":false,"pushed_at":"2020-07-27T02:39:51.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T18:52:14.239Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zdimension.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-28T08:59:49.000Z","updated_at":"2020-07-27T02:39:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a8c4e77-6fb9-4312-ab8b-4978989388e0","html_url":"https://github.com/zdimension/stablewall","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdimension%2Fstablewall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdimension%2Fstablewall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdimension%2Fstablewall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdimension%2Fstablewall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zdimension","download_url":"https://codeload.github.com/zdimension/stablewall/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246223331,"owners_count":20743167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-10T04:14:29.628Z","updated_at":"2025-03-29T18:11:39.073Z","avatar_url":"https://github.com/zdimension.png","language":"Python","readme":"# stablewall\nSolution to the GKS 2020 Round C problem \"Stable Wall\"\n\n## How it works\n\n![](https://i.imgur.com/Oag9yYK.png?1)\n\n### Step 1\n\nLet \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\Sigma=\\{Z,O,M,A\\}\"\u003e be the set of letters and \u003cimg src=\"https://latex.codecogs.com/svg.latex?E=\\{(A,O),(M,O),(O,Z)\\}\"\u003e the set of directed dependencies between letters.\n\nA dependency \u003cimg src=\"https://latex.codecogs.com/svg.latex?d=(a,b)\"\u003e is *redundant* (noted \u003cimg src=\"https://latex.codecogs.com/svg.latex?r(d)\"\u003e) iff \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\{(a,x),(x,b)\\}\\subset{E}\"\u003e.\n\nLet \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\Sigma'=\\Sigma\\cup\\{*\\}\"\u003e where \u003cimg src=\"https://latex.codecogs.com/svg.latex?*\"\u003e refers to the \"ground\".\n\nLet \u003cimg src=\"https://latex.codecogs.com/svg.latex?E'=\\{d\\in{E}\\mid\\lnot{r}(d)\\}\\cup\\{(a,*)\\mid{a}\\in\\Sigma,\\nexists(x,y)\\in{E},x=a\\}\"\u003e. In this case, \u003cimg src=\"https://latex.codecogs.com/svg.latex?E'=\\{(A,O),(M,O),(O,Z),(Z,*)\\}\"\u003e. In this case, there were no *redundant* dependencies. The dependency \u003cimg src=\"https://latex.codecogs.com/svg.latex?(Z,*)\"\u003e was added to allow easier computation of the node degrees.\n\nLet \u003cimg src=\"https://latex.codecogs.com/svg.latex?G\"\u003e denote the directed graph \u003cimg src=\"https://latex.codecogs.com/svg.latex?(\\Sigma',E')\"\u003e.\n\nThe input is valid iff \u003cimg src=\"https://latex.codecogs.com/svg.latex?G\"\u003e is acyclic.\n\n![G](https://i.imgur.com/L2nOmiY.png?1)\n\nThe number of valid solutions is obtained using the expression \u003cimg src=\"https://latex.codecogs.com/svg.latex?n=\\prod_{a\\in\\Sigma'}{d^{-}(a)!}\"\u003e.\n\n### Step 2\n\nLet \u003cimg src=\"https://latex.codecogs.com/svg.latex?R^{+}\"\u003e denote the transitive closure of \u003cimg src=\"https://latex.codecogs.com/svg.latex?E\"\u003e. We have \u003cimg src=\"https://latex.codecogs.com/svg.latex?R^{+}=\\{(A,O),(A,Z),(M,O),(M,Z),(O,Z)\\}\"\u003e. Let \u003cimg src=\"https://latex.codecogs.com/svg.latex?a\\preceq{b}:=(b,a)\\notin{R^{+}}\"\u003e\n\nThe valid solutions \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\Omega\"\u003e are the permutations of \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\Sigma\"\u003e ordered under \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\preceq\"\u003e.\n\nIn other words, we have \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\Omega=\\{(\\sigma_i)_{\\left\\[1,\\left|\\Sigma\\right|\\right\\]}\\in{S}(\\Sigma)\\mid\\forall{i}\\in\\left\\[1,\\left|\\Sigma\\right|-1\\right\\],\\sigma_{i}\\preceq\\sigma_{i+1}\\}\"\u003e (note that here \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\sigma\"\u003e is an ordered tuple and not a set).\n\n### Step 3: Preprocessing\n\nLet \u003cimg src=\"https://latex.codecogs.com/svg.latex?f\\colon\\Sigma\\to\\mathcal{P}(\\Sigma)\"\u003e which returns the set of all nodes reachable from the specified node, i.e. all supporting letters for a specified letter with \u003cimg src=\"https://latex.codecogs.com/svg.latex?f(a)=\\{b\\mid(a,b)\\in{R}^{+}\\}\"\u003e (this can be done using DFS or recursive graph traversal), here we have\n\n| \u003cimg src=\"https://latex.codecogs.com/svg.latex?a\"\u003e  | \u003cimg src=\"https://latex.codecogs.com/svg.latex?f(a)\"\u003e |\n| ------------- | ------------- |\n| \u003cimg src=\"https://latex.codecogs.com/svg.latex?Z\"\u003e  | \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\emptyset\"\u003e  |\n| \u003cimg src=\"https://latex.codecogs.com/svg.latex?O\"\u003e  | \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\{Z\\}\"\u003e |\n| \u003cimg src=\"https://latex.codecogs.com/svg.latex?M\"\u003e  | \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\{O,Z\\}\"\u003e  |\n| \u003cimg src=\"https://latex.codecogs.com/svg.latex?A\"\u003e  | \u003cimg src=\"https://latex.codecogs.com/svg.latex?\\{O,Z\\}\"\u003e  |\n\n### Step 4: Processing\n1. While there are letters yet to be added to the answer:\n   1. Find the first one whose supporting letters are all already present, and add it. \n   2. If no such letter is found, halt. There is a cycle in the directed graph, which means two letters are codependent. Thus, there is no solution.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzdimension%2Fstablewall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzdimension%2Fstablewall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzdimension%2Fstablewall/lists"}