{"id":31180,"date":"2023-03-13T09:10:22","date_gmt":"2023-03-13T16:10:22","guid":{"rendered":"https:\/\/coderpad.io\/?p=31180"},"modified":"2023-08-03T14:45:20","modified_gmt":"2023-08-03T21:45:20","slug":"tiny-interview-python-random-list","status":"publish","type":"post","link":"https:\/\/coderpad.io\/blog\/coding-challenges\/tiny-interview-python-random-list\/","title":{"rendered":"Code Challenge: Python Random List"},"content":{"rendered":"\n<p>In this tiny interview, the <code>generate_random_list<\/code> function works as expected, but it\u2019s very slow on large test cases. Can you figure out what\u2019s wrong and fix it without changing its statistical distribution?<\/p>\n\n\n\n<p>Your task for this code challenge is to improve the <code>generate_random_list function<\/code> in the sandbox below to run faster than 100ms for both tests.<\/p>\n\n\n<div\n\tclass=\"sandbox-embed responsive-embed  sandbox-embed--full-width\"\n\tstyle=\"padding-top: 85%\"\ndata-block-name=\"coderpad-sandbox-embed\">\n\t<iframe src=\"https:\/\/embed.coderpad.io\/sandbox?question_id=222148&#038;use_question_button\" width=\"640\" height=\"544\" loading=\"lazy\" aria-label=\"Try out the CoderPad sandbox\"><\/iframe>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">More resources<\/h2>\n\n\n\n<p>We have made available these extra resources to improve your Python coding skills:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/coderpad.io\/interview-questions\/python-interview-questions\/\">25+ interview questions for Python<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"markdown-want-to-conduct-interviews-on-this-platform\">Want to conduct interviews on this platform?<\/h2>\n\n\n\n<p>Check out CoderPad : pick any interview question or create your own, then invite your candidate to a shared live-coding session on an IDE like this one. You even get 2 free interviews per month forever using&nbsp;<a href=\"https:\/\/app.coderpad.io\/register?source=Tiny+Interviews\">this registration link<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Generating a random list can take a lot of time depending on the range of values. Can you improve the function in this code challenge to generate random lists faster? Attempt the solution in this blog post sandbox.<\/p>\n","protected":false},"author":1,"featured_media":31845,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[22],"tags":[],"persona":[29],"blog-programming-language":[37],"keyword-cluster":[],"class_list":["post-31180","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding-challenges"],"acf":[],"_links":{"self":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/31180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/comments?post=31180"}],"version-history":[{"count":13,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/31180\/revisions"}],"predecessor-version":[{"id":35836,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/31180\/revisions\/35836"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/media\/31845"}],"wp:attachment":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/media?parent=31180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/categories?post=31180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/tags?post=31180"},{"taxonomy":"persona","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/persona?post=31180"},{"taxonomy":"blog-programming-language","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/blog-programming-language?post=31180"},{"taxonomy":"keyword-cluster","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/keyword-cluster?post=31180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}