{"id":140,"date":"2010-03-04T18:06:59","date_gmt":"2010-03-04T18:06:59","guid":{"rendered":"http:\/\/psyphi.net\/blog\/?p=140"},"modified":"2010-03-04T20:14:33","modified_gmt":"2010-03-04T20:14:33","slug":"an-interview-question","status":"publish","type":"post","link":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/","title":{"rendered":"An Interview Question"},"content":{"rendered":"<p>I&#8217;d like to share a basic interview question I&#8217;ve used in the past. I&#8217;ve used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves as senior developers on their CVs and demand \u00c2\u00a335k+ salaries.<\/p>\n<p>You have a list of characters.<\/p>\n<ol>\n<li>Remove duplicates<\/li>\n<\/ol>\n<p>The time taken for the interviewee to scratch their head determines whether they&#8217;re a Perl programmer, or at least think like one &#8211; this is an idomatic question in Perl. It&#8217;s a fairly standard solution to anyone who uses hashes, maps or associative arrays in any language. It&#8217;s certainly a lot harder without them.<\/p>\n<p>The answer I would expect to see would run something like this:<\/p>\n<pre><code>#########\r\n# pass in an array ref of characters, e.g.\r\n# remove_dupes([qw(a e r o i g n o s e w f e r g e r i g e o n k)]);\r\n#\r\nsub remove_dupes {\r\n  my $chars_in  = shift;\r\n  my $seen      = {};\r\n  my $chars_out = [];\r\n\r\n  for my $char (@{$chars_in}) {\r\n    if(!$seen-&gt;{$char}++) {\r\n      push @{$chars_out}, $char;\r\n    }\r\n  }\r\n\r\n  return $chars_out;\r\n}<\/code><\/pre>\n<p>Or for the more adventurous, using a string rather than an array:<\/p>\n<pre><code>#########\r\n# pass in a string of characters, e.g.\r\n# remove_dupes(q[uyavubnopwemgnisudhjopwenfbuihrpgbwogpnskbjugisjb]);\r\n#\r\nsub remove_dupes {\r\n  my $str  = shift;\r\n  my $seen = {};\r\n  $str     =~ s\/(.)\/( !$seen-&gt;{$1}++ ) ? $1 : q[]\/smegx;\r\n  return $str;\r\n}<\/code><\/pre>\n<p>The natural progression from Q1 then follows. It should be immediately obvious to the interviewee if they answered Q1 inappropriately.<\/p>\n<ol start=\"2\">\n<li>List duplicates<\/li>\n<\/ol>\n<pre><code>#########\r\n# pass in an array ref of characters, e.g.\r\n# list_dupes([qw(a e r o i g n o s e w f e r g e r i g e o n k)]);\r\n#\r\nsub list_dupes {\r\n  my $chars_in  = shift;\r\n  my $seen      = {};\r\n<del datetime=\"2010-03-04T20:12:13+00:00\">  my $chars_out = [];<\/del>\r\n\r\n  for my $char (@{$chars_in}) {\r\n    $seen-&gt;{$char}++;\r\n  }\r\n\r\n  return [ grep { $seen-&gt;{$_} &gt; 1 } keys %{$seen} ];\r\n}<\/code><\/pre>\n<p>and with a string<\/p>\n<pre><code>#########\r\n# pass in a string of characters, e.g.\r\n# list_dupes(q[uyavubnopwemgnisudhjopwenfbuihrpgbwogpnskbjugisjb]);\r\n#\r\nsub list_dupes {\r\n  my $str  = shift;\r\n  my $seen = {};\r\n  $str     =~ s\/(.)\/( $seen-&gt;{$1}++ &gt; 1) ? $1 : q[]\/smegx;\r\n  return $str;\r\n}<\/code><\/pre>\n<p>The standard follow-up is then &#8220;Given more time, what would you do to improve this?&#8221;. Well? What would <em>you<\/em> do? I know what I would do before I even started &#8211; <strong>WRITE SOME TESTS<\/strong>!<\/p>\n<p>It&#8217;s pretty safe to assume that any communicative, personable candidate who starts off writing a test on the board will probably be head and shoulders above any other.<\/p>\n<p>If I&#8217;m interviewing you tomorrow and you&#8217;re reading this now, it&#8217;s also safe to mention it. Interest in the subject and a working knowledge of the intertubes generally comes in handy for a web developer. I&#8217;m hiring you as an independent thinker!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;d like to share a basic interview question I&#8217;ve used in the past. I&#8217;ve used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves &hellip; <a href=\"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;An Interview Question&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[11],"tags":[13,227,21,229,228],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-programming","tag-code","tag-interviews","tag-perl","tag-simple","tag-tests"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"I&#039;d like to share a basic interview question I&#039;ve used in the past. I&#039;ve used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Roger Pettett\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"psyphi.net blog - Another collection of braingunk and technolint\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"An Interview Question - psyphi.net blog\" \/>\n\t\t<meta property=\"og:description\" content=\"I&#039;d like to share a basic interview question I&#039;ve used in the past. I&#039;ve used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2010-03-04T18:06:59+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2010-03-04T20:14:33+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"An Interview Question - psyphi.net blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I&#039;d like to share a basic interview question I&#039;ve used in the past. I&#039;ve used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#blogposting\",\"name\":\"An Interview Question - psyphi.net blog\",\"headline\":\"An Interview Question\",\"author\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#organization\"},\"datePublished\":\"2010-03-04T18:06:59+00:00\",\"dateModified\":\"2010-03-04T20:14:33+00:00\",\"inLanguage\":\"en-US\",\"commentCount\":6,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#webpage\"},\"articleSection\":\"programming, code, interviews, perl, simple, tests\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/psyphi.net\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/category\\\/programming\\\/#listItem\",\"name\":\"programming\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/category\\\/programming\\\/#listItem\",\"position\":2,\"name\":\"programming\",\"item\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/category\\\/programming\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#listItem\",\"name\":\"An Interview Question\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#listItem\",\"position\":3,\"name\":\"An Interview Question\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/category\\\/programming\\\/#listItem\",\"name\":\"programming\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#organization\",\"name\":\"psyphi.net blog\",\"description\":\"Another collection of braingunk and technolint\",\"url\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/#author\",\"url\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/\",\"name\":\"Roger Pettett\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f715f8335258578c567eb8c22335f1cee22c971c2aff8be27c4d8d934c436503?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Roger Pettett\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#webpage\",\"url\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/\",\"name\":\"An Interview Question - psyphi.net blog\",\"description\":\"I'd like to share a basic interview question I've used in the past. I've used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2010\\\/03\\\/an-interview-question\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/#author\"},\"datePublished\":\"2010-03-04T18:06:59+00:00\",\"dateModified\":\"2010-03-04T20:14:33+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/\",\"name\":\"psyphi.net blog\",\"description\":\"Another collection of braingunk and technolint\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"An Interview Question - psyphi.net blog","description":"I'd like to share a basic interview question I've used in the past. I've used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves","canonical_url":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#blogposting","name":"An Interview Question - psyphi.net blog","headline":"An Interview Question","author":{"@id":"https:\/\/psyphi.net\/blog\/author\/rmp\/#author"},"publisher":{"@id":"https:\/\/psyphi.net\/blog\/#organization"},"datePublished":"2010-03-04T18:06:59+00:00","dateModified":"2010-03-04T20:14:33+00:00","inLanguage":"en-US","commentCount":6,"mainEntityOfPage":{"@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#webpage"},"isPartOf":{"@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#webpage"},"articleSection":"programming, code, interviews, perl, simple, tests"},{"@type":"BreadcrumbList","@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog#listItem","position":1,"name":"Home","item":"https:\/\/psyphi.net\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/category\/programming\/#listItem","name":"programming"}},{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/category\/programming\/#listItem","position":2,"name":"programming","item":"https:\/\/psyphi.net\/blog\/category\/programming\/","nextItem":{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#listItem","name":"An Interview Question"},"previousItem":{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#listItem","position":3,"name":"An Interview Question","previousItem":{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/category\/programming\/#listItem","name":"programming"}}]},{"@type":"Organization","@id":"https:\/\/psyphi.net\/blog\/#organization","name":"psyphi.net blog","description":"Another collection of braingunk and technolint","url":"https:\/\/psyphi.net\/blog\/"},{"@type":"Person","@id":"https:\/\/psyphi.net\/blog\/author\/rmp\/#author","url":"https:\/\/psyphi.net\/blog\/author\/rmp\/","name":"Roger Pettett","image":{"@type":"ImageObject","@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/f715f8335258578c567eb8c22335f1cee22c971c2aff8be27c4d8d934c436503?s=96&d=mm&r=g","width":96,"height":96,"caption":"Roger Pettett"}},{"@type":"WebPage","@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#webpage","url":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/","name":"An Interview Question - psyphi.net blog","description":"I'd like to share a basic interview question I've used in the past. I've used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/psyphi.net\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/#breadcrumblist"},"author":{"@id":"https:\/\/psyphi.net\/blog\/author\/rmp\/#author"},"creator":{"@id":"https:\/\/psyphi.net\/blog\/author\/rmp\/#author"},"datePublished":"2010-03-04T18:06:59+00:00","dateModified":"2010-03-04T20:14:33+00:00"},{"@type":"WebSite","@id":"https:\/\/psyphi.net\/blog\/#website","url":"https:\/\/psyphi.net\/blog\/","name":"psyphi.net blog","description":"Another collection of braingunk and technolint","inLanguage":"en-US","publisher":{"@id":"https:\/\/psyphi.net\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"psyphi.net blog - Another collection of braingunk and technolint","og:type":"article","og:title":"An Interview Question - psyphi.net blog","og:description":"I'd like to share a basic interview question I've used in the past. I've used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves","og:url":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/","article:published_time":"2010-03-04T18:06:59+00:00","article:modified_time":"2010-03-04T20:14:33+00:00","twitter:card":"summary_large_image","twitter:title":"An Interview Question - psyphi.net blog","twitter:description":"I'd like to share a basic interview question I've used in the past. I've used this in a number of different guises over the years, both at Sanger and at ONT but the (very small!) core remains the same. It still seems to be able to trip up a lot of people who sell themselves"},"aioseo_meta_data":{"post_id":"140","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2024-05-16 13:02:10","updated":"2025-08-15 17:24:03","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/psyphi.net\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/psyphi.net\/blog\/category\/programming\/\" title=\"programming\">programming<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tAn Interview Question\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/psyphi.net\/blog"},{"label":"programming","link":"https:\/\/psyphi.net\/blog\/category\/programming\/"},{"label":"An Interview Question","link":"https:\/\/psyphi.net\/blog\/2010\/03\/an-interview-question\/"}],"_links":{"self":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":17,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":157,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions\/157"}],"wp:attachment":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}