{"id":17909826,"url":"https://github.com/julienschmidt/n-queens","last_synced_at":"2025-04-03T10:44:59.518Z","repository":{"id":5866204,"uuid":"7083375","full_name":"julienschmidt/N-Queens","owner":"julienschmidt","description":"Optimized algorithm to find all solutions for the N-Queens-Problem in Java","archived":false,"fork":false,"pushed_at":"2017-05-03T18:35:57.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T00:23:21.674Z","etag":null,"topics":["challenge","java","n-queens","nqueens","nqueens-problem","nqueens-solution"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/julienschmidt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-09T20:46:30.000Z","updated_at":"2024-05-31T17:40:49.000Z","dependencies_parsed_at":"2022-07-21T12:18:07.777Z","dependency_job_id":null,"html_url":"https://github.com/julienschmidt/N-Queens","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/julienschmidt%2FN-Queens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julienschmidt%2FN-Queens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julienschmidt%2FN-Queens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julienschmidt%2FN-Queens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/julienschmidt","download_url":"https://codeload.github.com/julienschmidt/N-Queens/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246989501,"owners_count":20865306,"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":["challenge","java","n-queens","nqueens","nqueens-problem","nqueens-solution"],"created_at":"2024-10-28T19:28:14.824Z","updated_at":"2025-04-03T10:44:59.498Z","avatar_url":"https://github.com/julienschmidt.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"N-Queens\r\n========\r\n\r\nSubmitted version of my entry to the *N-Queens speed-challenge* as part of the lab class *Fundamentals of Programming* of my first semester at the Technical University of Munich.\r\n\r\nProgress from trivial to fast\r\n-----------------------------\r\nSince this was the winning submission (in the category \"non-threaded\"), I added a [`progress` branch](https://github.com/JulienSchmidt/N-Queens/commits/progress) where you can relive my progress from the trivial algorithm to the optimized (fast) algoritm.\r\n\r\nYou can browse the changes here: [`progress`](https://github.com/JulienSchmidt/N-Queens/commits/progress)\r\n\r\nKnown bugs\r\n----------\r\nMany, many spelling errors :)\r\n\r\nBytecode\r\n--------\r\nI heavily optimized the code so it generates almost optimal byte code for the the chosen algorithmic approach.\r\nHere is the byte code generated from the performance-critical function:\r\n\r\n    private static int findPos(int, int, int, int);\r\n      Code:\r\n         0: iconst_0\r\n         1: istore        4\r\n         3: iload_0\r\n         4: iload_1\r\n         5: iload_2\r\n         6: ior\r\n         7: iload_3\r\n         8: ior\r\n         9: iconst_m1\r\n        10: ixor\r\n        11: iand\r\n        12: istore        7\r\n        14: iload         7\r\n        16: ifle          78\r\n        19: iload         7\r\n        21: ineg\r\n        22: iload         7\r\n        24: iand\r\n        25: istore        5\r\n        27: iload_1\r\n        28: iload         5\r\n        30: ior\r\n        31: istore        6\r\n        33: iload         7\r\n        35: iload         5\r\n        37: ixor\r\n        38: istore        7\r\n        40: iload         6\r\n        42: iload_0\r\n        43: if_icmpge     72\r\n        46: iload         4\r\n        48: iload_0\r\n        49: iload         6\r\n        51: iload_2\r\n        52: iload         5\r\n        54: ior\r\n        55: iconst_1\r\n        56: iushr\r\n        57: iload_3\r\n        58: iload         5\r\n        60: ior\r\n        61: iconst_1\r\n        62: ishl\r\n        63: invokestatic  #31                 // Method findPos:(IIII)I\r\n        66: iadd\r\n        67: istore        4\r\n        69: goto          14\r\n        72: iinc          4, 1\r\n        75: goto          14\r\n        78: iload         4\r\n        80: ireturn\r\n        \r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulienschmidt%2Fn-queens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulienschmidt%2Fn-queens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulienschmidt%2Fn-queens/lists"}