{"id":17189832,"url":"https://github.com/mycaule/oberwolfach-problem","last_synced_at":"2025-03-25T04:55:19.691Z","repository":{"id":88620057,"uuid":"89704662","full_name":"mycaule/oberwolfach-problem","owner":"mycaule","description":"Experimenting on the Oberwolfach problem","archived":false,"fork":false,"pushed_at":"2017-04-28T16:33:34.000Z","size":2,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T05:14:48.928Z","etag":null,"topics":["combinatorics","oberwolfach","permutations"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/watch?v=roRqvhWLbXY\u0026t=8m52s","language":"Scala","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/mycaule.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":"2017-04-28T12:36:47.000Z","updated_at":"2017-04-28T15:07:48.000Z","dependencies_parsed_at":"2023-07-03T22:32:35.118Z","dependency_job_id":null,"html_url":"https://github.com/mycaule/oberwolfach-problem","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/mycaule%2Foberwolfach-problem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mycaule%2Foberwolfach-problem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mycaule%2Foberwolfach-problem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mycaule%2Foberwolfach-problem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mycaule","download_url":"https://codeload.github.com/mycaule/oberwolfach-problem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245401397,"owners_count":20609167,"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":["combinatorics","oberwolfach","permutations"],"created_at":"2024-10-15T01:12:38.397Z","updated_at":"2025-03-25T04:55:19.668Z","avatar_url":"https://github.com/mycaule.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Oberwolfach problem experiments\nExperimenting on the Oberwolfach problem\n\n#### If `N=10` people are in a ballroom are inviting each other `K=2` to dance, how many rounds `R` will they need to dance with everyone ?\n\nGiven people in the `List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)`. We pair them together for several rounds so that everybody meets everyone in the list.\n\n```scala\nval l0 = List.range(0,10)\n\u003e List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)\n\nval l1 = l0.filter(_ % 2 == 0) // even numbers\nval l2 = l0.filter(_ % 2 == 1) // odd numbers\nl1.zip(l2)\n\n\u003e List((0,1), (2,3), (4,5), (6,7), (8,9))\n```\n\nSwitching element at index 1 with index 2\n```scala\nval people = l0.updated(1,l0(2)).updated(2,l0(1))\n\nval males = l0p.zipWithIndex.filter(_._2 % 2 == 0).map(_._1)\nval females = l0p.zipWithIndex.filter(_._2 % 2 == 1).map(_._1)\nl1p.zip(l2p)\n\n\u003e List((0,2), (1,3), (4,5), (6,7), (8,9),)\n```\n\nWe then generalize on element #0 and considering the pairs as sets working on the sequence `x_i,0 = swap(1, i, people)`\n\n```scala\nhttps://scalafiddle.io/sf/EeY4Ujr/0\nval people = List.range(0,10)\n\ndef swap(i: Int, j: Int, l: Seq[Int]) = {  \n  l.updated(i,l(j)).updated(j,l(i))\n}\n\ndef moduloIndex(p: Int, i: Int, l: Seq[Int]) = {\n  l.zipWithIndex.filter(_._2 % p == i).map(_._1)\n}\n\ndef pairUp(l: Seq[Int]) = {\n  moduloIndex(2, 0, l).zip(moduloIndex(2, 1, l))\n  .map {\n    x =\u003e if (x._1 \u003c x._2) (x._1, x._2) else (x._2, x._1)\n  }\n}\n\nfor(i\u003c-people.tail) println(pairUp(swap(1, i, people)))\n\n\u003e List((0,1), (2,3), (4,5), (6,7), (8,9))\n\u003e List((0,2), (1,3), (4,5), (6,7), (8,9))\n\u003e List((0,3), (1,2), (4,5), (6,7), (8,9))\n\u003e List((0,4), (2,3), (1,5), (6,7), (8,9))\n\u003e List((0,5), (2,3), (1,4), (6,7), (8,9))\n\u003e List((0,6), (2,3), (4,5), (1,7), (8,9))\n\u003e List((0,7), (2,3), (4,5), (1,6), (8,9))\n\u003e List((0,8), (2,3), (4,5), (6,7), (1,9))\n\u003e List((0,9), (2,3), (4,5), (6,7), (1,8))\n```\n\nAt this point `R` is at least `N`, #1 has already danced with #0, #2, sometimes couple of times, but still we have to enlist all remaining choices for element #1. Working on `x_i,1 = swap(1, i, people.drop(1))` now gives\n```scala\nhttps://scalafiddle.io/sf/EeY4Ujr/2\n\nfor(i\u003c-people.drop(2)) println(pairUp(swap(1, i, people.drop(1))))\n\u003e List((1,3), (2,4), (5,6), (7,8))  // ++ (0,9)\n\u003e List((1,4), (2,3), (5,6), (7,8))  // ++ (0,9)\n\u003e List((1,5), (3,4), (2,6), (7,8))  // ++ (0,9)\n\u003e List((1,6), (3,4), (2,5), (7,8))  // ++ (0,9)\n\u003e List((1,7), (3,4), (5,6), (2,8))  // ++ (0,9)\n\u003e List((1,8), (3,4), (5,6), (2,7))  // ++ (0,9)\n\u003e List((1,9), (3,4), (5,6), (7,8))  // ++ (0,2)\n```\n\nConsidering then `x_i\u003cj = swap(i, j, people)`\n\nHow do we know we don't have duplicates ? Verify this computationally!\n\n#### General formula for number of rounds `R = f(N, K)`\n\n```\nR \u003c= card(x_i,0) + card(x_i,1) + ... + card(x_i,N-1)\n  \u003c=    (N-1)    +     (N-2)   + ... + 0\n  \u003c=  N x (N-1)/2\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmycaule%2Foberwolfach-problem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmycaule%2Foberwolfach-problem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmycaule%2Foberwolfach-problem/lists"}