Title: remove unwanted extra interation of loop and saving data in queue in 6_Queue/Exercise/binary_numbers.py · Issue #57 · codebasics/data-structures-algorithms-python · GitHub
Open Graph Title: remove unwanted extra interation of loop and saving data in queue in 6_Queue/Exercise/binary_numbers.py · Issue #57 · codebasics/data-structures-algorithms-python
X Title: remove unwanted extra interation of loop and saving data in queue in 6_Queue/Exercise/binary_numbers.py · Issue #57 · codebasics/data-structures-algorithms-python
Description: https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/binary_numbers.py Issue: def produce_binary_numbers(n): numbers_queue = Queue() numbers_queue.enqueue("1") for i in range(n): fr...
Open Graph Description: https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/binary_numbers.py Issue: def produce_binary_numbers(n): numbers_queue = Queue() numbers_...
X Description: https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/binary_numbers.py Issue: def produce_binary_numbers(n): numbers_queue = Queue() numbers_...
Opengraph URL: https://github.com/codebasics/data-structures-algorithms-python/issues/57
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"remove unwanted extra interation of loop and saving data in queue in 6_Queue/Exercise/binary_numbers.py","articleBody":"https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/binary_numbers.py\r\n\r\n**Issue:**\r\n\r\n```\r\ndef produce_binary_numbers(n):\r\n numbers_queue = Queue()\r\n numbers_queue.enqueue(\"1\")\r\n\r\n for i in range(n):\r\n front = numbers_queue.front()\r\n print(\" \", front)\r\n numbers_queue.enqueue(front + \"0\")\r\n numbers_queue.enqueue(front + \"1\")\r\n\r\n numbers_queue.dequeue()\r\n```\r\n\r\n**Proposed below:**\r\n\r\n```\r\ndef produce_binary_numbers(n):\r\n numbers_queue = Queue()\r\n numbers_queue.enqueue(\"1\")\r\n i = 0\r\n while i \u003c n//2 and not numbers_queue.is_empty():\r\n i+=1\r\n front = numbers_queue.dequeue()\r\n print(front)\r\n numbers_queue.enqueue(front + \"0\")\r\n numbers_queue.enqueue(front + \"1\")\r\n \r\n while not numbers_queue.is_empty() and i\u003cn:\r\n print(numbers_queue.dequeue())\r\n i+=1\r\n```","author":{"url":"https://github.com/udipta","@type":"Person","name":"udipta"},"datePublished":"2022-05-30T18:01:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/57/data-structures-algorithms-python/issues/57"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6f55be11-4a31-4dac-fa3b-b746ca443ed7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8144:2BBCB0:105F610:162742F:696ACE59 |
| html-safe-nonce | bbfbbaab65f1d63b830f74b43af36c4e4c5b0c458ae029c86a13758b0eaa1e8c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTQ0OjJCQkNCMDoxMDVGNjEwOjE2Mjc0MkY6Njk2QUNFNTkiLCJ2aXNpdG9yX2lkIjoiMjUyODExMjIyODU4OTgxNzQzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | adaca76679525fa6daab9570dc437c971efcb1fabb603a23f10ab4003f4ff5d7 |
| hovercard-subject-tag | issue:1253007759 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/codebasics/data-structures-algorithms-python/57/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6385d2504e77ea5923e4ea1fd07270bf5050f40b5d4c0c4ea4c3f0009136a466/codebasics/data-structures-algorithms-python/issues/57 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6385d2504e77ea5923e4ea1fd07270bf5050f40b5d4c0c4ea4c3f0009136a466/codebasics/data-structures-algorithms-python/issues/57 |
| og:image:alt | https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/binary_numbers.py Issue: def produce_binary_numbers(n): numbers_queue = Queue() numbers_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | udipta |
| hostname | github.com |
| expected-hostname | github.com |
| None | c785f4ce187e9e7331257791b36ddee01625bb8e292a9b4fe2c16d4c006abf5d |
| turbo-cache-control | no-preview |
| go-import | github.com/codebasics/data-structures-algorithms-python git https://github.com/codebasics/data-structures-algorithms-python.git |
| octolytics-dimension-user_id | 16063416 |
| octolytics-dimension-user_login | codebasics |
| octolytics-dimension-repository_id | 299539326 |
| octolytics-dimension-repository_nwo | codebasics/data-structures-algorithms-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 299539326 |
| octolytics-dimension-repository_network_root_nwo | codebasics/data-structures-algorithms-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c718a376fcf780eb22089171adb84a543f660bf7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width