{"id":6536,"date":"2020-12-15T14:35:15","date_gmt":"2020-12-15T14:35:15","guid":{"rendered":"https:\/\/www.dyalog.com\/blog\/?p=6536"},"modified":"2021-04-20T13:38:26","modified_gmt":"2021-04-20T13:38:26","slug":"highlights-of-the-2020-apl-problem-solving-competition-phase-i","status":"publish","type":"post","link":"https:\/\/www.dyalog.com\/blog\/2020\/12\/highlights-of-the-2020-apl-problem-solving-competition-phase-i\/","title":{"rendered":"Highlights of the 2020 APL Problem Solving Competition &#8211; Phase I"},"content":{"rendered":"<p>We received some excellent competition entries this year. Once again, thank you to all those who participated, congratulations to <a href=\"https:\/\/www.dyalog.com\/news\/143\/420\/Meet-The-2020-APL-Problem-Solving-Competition-Winners.htm\" target=\"_blank\" rel=\"noopener noreferrer\">this year&#8217;s winners<\/a>, and thank you to the Grand Prize Winner Andrii Makukha for <a href=\"https:\/\/dyalog.tv\/Dyalog20\/?v=YB5wNW68-lM\" target=\"_blank\" rel=\"noopener noreferrer\">his presentation<\/a> at this year&#8217;s user meeting.<\/p>\n<p>This post contains some suggested Phase I solutions along with some comments from the judges. Before each solution there is a brief summary of the problem and a link to the full problem on the <a href=\"https:\/\/problems.tryapl.org\" target=\"_blank\" rel=\"noopener noreferrer\">practice problems site<\/a>; you can also download the full set of problem descriptions <a href=\"https:\/\/www.dyalog.com\/uploads\/files\/student_competition\/2020_problems_phase1.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">as a PDF<\/a>.<\/p>\n<p>This page contains spoilers. The suggested solutions are not the only correct solutions, and may not necessarily be best practice depending on your application or most optimal in terms of performance, but they do solve the problems in some particularly interesting and elegant ways. If you&#8217;d like to try to solve the problems yourself before looking at these example solutions, you can use <a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html\" target=\"_blank\" rel=\"noopener noreferrer\">problems.tryapl.org<\/a> to check your solutions.<\/p>\n<h2>1: Let&#8217;s Split<\/h2>\n<p>The <a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P1_Lets_Split\" target=\"blank\" rel=\"noopener noreferrer\">first problem<\/a> was to write a function splitting a vector right argument into a nested vector of vectors according to a signed integer left argument. For example:<\/p>\n<pre><code class=\"language-apl\">      \u00af3 (your_function) 'DyalogAPL'\r\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2510\r\n\u2502Dyalog\u2502APL\u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Most entrants successfully solved this problem using dyadic <em>take<\/em> <code class=\"language-apl\">\u2191<\/code> and <em>drop<\/em> <code class=\"language-apl\">\u2193<\/code>.<\/p>\n<pre><code class=\"language-apl\">{c\u2190\u237a+(\u237a&lt;0)\u00d7\u2262\u2375 \u22c4 (c\u2191\u2375)(c\u2193\u2375)}<\/code><\/pre>\n<p>It was common to use the left argument <code class=\"language-apl\">\u237a<\/code> as-is with <code class=\"language-apl\">\u2191<\/code> and <code class=\"language-apl\">\u2193<\/code>, and swap the two parts of the result using <code class=\"language-apl\">\u233d\u2363condition<\/code> or <code class=\"language-apl\">condition\u233darray<\/code>, but the solution above avoids the swap by computing appropriate arguments to <code class=\"language-apl\">\u2191<\/code> and <code class=\"language-apl\">\u2193<\/code>.<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=%C2%AF3%7Bc%E2%86%90%E2%8D%BA%2B(%E2%8D%BA%3C0)%C3%97%E2%89%A2%E2%8D%B5%20%E2%8B%84%20(c%E2%86%91%E2%8D%B5)(c%E2%86%93%E2%8D%B5)%7D%27DyalogAPL%27&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>2: Character Building<\/h2>\n<p>In <a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P2_Characters\" target=\"blank\" rel=\"noopener noreferrer\">problem 2<\/a>, we asked participants to partition a vector of <a href=\"https:\/\/en.wikipedia.org\/wiki\/UTF-8#Encoding\" target=\"blank\" rel=\"noopener noreferrer\">UTF-8 character encodings<\/a>, similarly to <code class=\"language-apl\">'UTF-8'\u2218\u2395UCS\u00a8<\/code>, without using <code class=\"language-apl\">\u2395UCS<\/code>. For example:<\/p>\n<pre><code class=\"language-apl\">      (your_function) 68 194 165 226 141 186 226 140 138 240 159 148 178 57   \r\n\u250c\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2510\r\n\u250268\u2502194 165\u2502226 141 186\u2502226 140 138\u2502240 159 148 178\u250257\u2502\r\n\u2514\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Eight participants submitted this (or a variation thereof):<\/p>\n<pre><code class=\"language-apl\">{\u2375\u2282\u23681\u2260128 192\u2378\u2375}<\/code><\/pre>\n<p>Instead of doing multiple comparisons, this neatly uses <em>interval index<\/em> <code class=\"language-apl\">\u2378<\/code> to check which range the argument is in. It then uses <em>partitioned-enclose<\/em> <code class=\"language-apl\">\u2282<\/code> to create partitions beginning where code points are either below <code class=\"language-apl\">128<\/code> or above <code class=\"language-apl\">192<\/code>.<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=%7B%E2%8D%B5%E2%8A%82%E2%8D%A81%E2%89%A0128%20192%E2%8D%B8%E2%8D%B5%7D%27UTF-8%27%E2%8E%95ucs%20%27D%C2%A5%E2%8D%BA%E2%8C%8A%E2%97%8B9%27%20%E2%8B%84%20%27UTF-8%27%E2%88%98%E2%8E%95UCS%C2%A8%27D%C2%A5%E2%8D%BA%E2%8C%8A%E2%97%8B9%27&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>3: Excel-lent Columns<\/h2>\n<p><a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P3_Columns\" target=\"blank\" rel=\"noopener noreferrer\">Problem 3<\/a> was simply to convert Microsoft Excel-style column letters to an integer. For example:<\/p>\n<pre><code class=\"language-apl\">      (your_function) 'APL'\r\n1104\r\n<\/code><\/pre>\n<p>Thirty-five participants submitted variations on this:<\/p>\n<pre><code class=\"language-apl\">{26\u22a5\u2395A\u2373\u2375}<\/code><\/pre>\n<p>While simple at first glance, it is actually quite involved because <code class=\"language-apl\">\u2395A\u2373\u2375<\/code> can give 26 (for Z) which isn\u2019t a valid digit in base-26. However, <em>decode<\/em> <code class=\"language-apl\">\u22a5<\/code> handles out-of-bounds digits by carrying.<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=%7B26%E2%8A%A5%E2%8E%95A%E2%8D%B3%E2%8D%B5%7D%27APL%27&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>4: Take a Leap<\/h2>\n<p>The task for <a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P4_Take_a_Leap\" target=\"blank\" rel=\"noopener noreferrer\">problem 4<\/a> was to write a function to verify which of an array of integer years are leap years. For example:<\/p>\n<pre><code class=\"language-apl\">      (your_function) 1900+10 10\u2374\u2373100\r\n0 0 0 1 0 0 0 1 0 0\r\n0 1 0 0 0 1 0 0 0 1\r\n0 0 0 1 0 0 0 1 0 0\r\n0 1 0 0 0 1 0 0 0 1\r\n0 0 0 1 0 0 0 1 0 0\r\n0 1 0 0 0 1 0 0 0 1\r\n0 0 0 1 0 0 0 1 0 0\r\n0 1 0 0 0 1 0 0 0 1\r\n0 0 0 1 0 0 0 1 0 0\r\n0 1 0 0 0 1 0 0 0 1\r\n<\/code><\/pre>\n<p>We had eight solutions like this one:<\/p>\n<pre><code class=\"language-apl\">{0\u2260.=4 100 400\u2218.|\u2375}<\/code><\/pre>\n<p>At first, it generates a 3-element vector showing whether the argument is divisible by 4, 100 or 400.<\/p>\n<pre><code class=\"language-apl\">      0=4 100 400\u2218.|1900\r\n1 1 0\r\n<\/code><\/pre>\n<p>The cleverness then is that <code class=\"language-apl\">\u2260\u233f<\/code> is used to express the logic of the leap-year algorithm. From Wikipedia:<\/p>\n<blockquote style=\"margin-bottom: 1.3em;\">\n<p style=\"margin: 0.5em;\">if (year is not divisible by 4) then (it is a common year)<br \/>\nelse if (year is not divisible by 100) then (it is a leap year)<br \/>\nelse if (year is not divisible by 400) then (it is a common year)<br \/>\nelse (it is a leap year)<\/p>\n<\/blockquote>\n<p>We can check this with all possible length-3 boolean arguments:<\/p>\n<pre><code class=\"language-apl\">      2\u22a5\u2363\u00af1\u2373\u00af1+2*3\r\n0 0 0 1 1 1 1\r\n0 1 1 0 0 1 1\r\n1 0 1 0 1 0 1\r\n      \u2260\u233f2\u22a5\u2363\u00af1\u2373\u00af1+2*3\r\n1 1 0 1 0 0 1\r\n<\/code><\/pre>\n<p>Consider each case in turn:<br \/>\n1. Leap year, return 1<br \/>\n2. Can never occur<br \/>\n3. Not a leap year, return 0<br \/>\n4. Can never occur<br \/>\n5. Can never occur<br \/>\n6. Can never occur<br \/>\n7. Leap year, return 1<\/p>\n<p>It is good because it uses no explicit loops and keeps intermediate values flat (no nesting). The solution leverages that each leap year rule is an exception to the previous one, and this particular formulation employs an unusual <em>inner product<\/em> <code class=\"language-apl\">\u2260.=<\/code> (equivalent to <code class=\"language-apl\">{\u2260\/\u237a=\u2375}<\/code> for vector arguments) to compute the parity of the divisibilities.<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=%7B0%E2%89%A0.%3D4%20100%20400%E2%88%98.%7C%E2%8D%B5%7D1900%2B10%2010%E2%8D%B4%E2%8D%B3100&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>5: Stepping in the Proper Direction<\/h2>\n<p><a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P5_Integer_Range\" target=\"blank\" rel=\"noopener noreferrer\">Problem 5<\/a> was to create a list generator somewhat similar to <em>iota<\/em> <code class=\"language-apl\">\u2373<\/code>. However, this list generator takes a 2-element integer right argument and returns a list starting from the first integer and either increasing or decreasing in steps of 1 until the last integer inclusively. For example:<\/p>\n<pre><code class=\"language-apl\">      (your_function) 4 \u00af3\r\n4 3 2 1 0 \u00af1 \u00af2 \u00af3\r\n<\/code><\/pre>\n<p>Only one person had this exact solution, though many solutions were not too far off:<\/p>\n<pre><code class=\"language-apl\">{(\u2283\u2375)-0,(\u00d7\u00d7\u2373\u2218|)-\/\u2375}<\/code><\/pre>\n<p>This <a href=\"https:\/\/aplwiki.com\/wiki\/Dfn\" target=\"_blank\" rel=\"noopener noreferrer\">dfn<\/a> contains a 3-train or <a href=\"https:\/\/aplwiki.com\/wiki\/Tacit_programming#Forks\" target=\"_blank\" rel=\"noopener noreferrer\">fork<\/a>. Having seen contestants use the following format before, we feel compelled to provide you with a commented version of the above:<\/p>\n<pre><code class=\"language-apl\">{\r\n               -\/\u2375   \u235d The length of the result is 1 more than the difference\r\n           \u2373\u2218|)      \u235d Integers up to the absolute difference\r\n          \u00d7          \u235d times\r\n        (\u00d7           \u235d The sign of the difference\r\n      0,             \u235d Make the range inclusive\r\n     -               \u235d Use arithmetic to compute the correct result\r\n (\u2283\u2375)                \u235d From the first value\r\n                  }\r\n<\/code><\/pre>\n<p>Alternatively:<\/p>\n<pre><code class=\"language-apl\">{\r\n (\u2283\u2375)                \u235d From the first value\r\n     -               \u235d to\r\n      0,             \u235d inclusively\r\n        (\u00d7           \u235d The sign of...\r\n          \u00d7          \u235d times\r\n           \u2373\u2218|)      \u235d Integers in the range of...\r\n               -\/\u2375   \u235d The difference\r\n                  }    \r\n<\/code><\/pre>\n<p>This one excels in only computing necessary values once, and cleverly adjusts the generated values to rise or fall as needed, using the sign of the difference between the beginning and end points of the target range.<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=%7B(%E2%8A%83%E2%8D%B5)-0%2C(%C3%97%C3%97%E2%8D%B3%E2%88%98%7C)-%2F%E2%8D%B5%7D%204%20%C2%AF3&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>6: Move to the Front<\/h2>\n<p>The task for <a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P6_Move_To_Front\" target=\"blank\" rel=\"noopener noreferrer\">problem 6<\/a> was to move all elements in the right argument vector equal to the left argument scalar to the start of that vector. For example:<\/p>\n<pre><code class=\"language-apl\">      'a' (your_function) 'dyalog apl for all'\r\naaadylog pl for ll\r\n<\/code><\/pre>\n<p>Only one participant found this train, though two others submitted dfns using the same idea:<\/p>\n<pre><code class=\"language-apl\">\u2229\u2368,~\u2368<\/code><\/pre>\n<p>Instead of computing indices or selecting elements, this simply employs two set functions, <em>intersection<\/em> <code class=\"language-apl\">\u2229<\/code> and <em>without<\/em> <code class=\"language-apl\">~<\/code>. The asymmetry of intersection, namely that it preserves duplicates from its left argument, is here used to great advantage.<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=%27a%27%20(%E2%88%A9%E2%8D%A8%2C~%E2%8D%A8)%20%27dyalog%20apl%20for%20all%27&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>7: See You in a Bit<\/h2>\n<p><a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P7_Bits\" target=\"blank\" rel=\"noopener noreferrer\">Problem 7<\/a> involved writing a function to compare set bits in the base-2 representations of its integer arguments. For example:<\/p>\n<pre><code class=\"language-apl\">      2 (your_function) 7   \u235d is 2 in 7 (1+2+4)?\r\n1\r\n<\/code><\/pre>\n<p>Eleven solutions used this method:<\/p>\n<pre><code class=\"language-apl\">\u2227\/(\u2264\/2\u22a5\u2363\u00af1,)<\/code><\/pre>\n<p>Indeed, the problem is about finding particular set bits in a binary number, hence the <code class=\"language-apl\">2\u22a5\u2363\u00af1<\/code>. The overall function is a 2-train or <a href=\"https:\/\/aplwiki.com\/wiki\/Tacit_programming#Atops\" target=\"_blank\" rel=\"noopener noreferrer\">atop<\/a>, where the right-hand function is itself a 3-train or <a href=\"https:\/\/aplwiki.com\/wiki\/Tacit_programming#Forks\" target=\"_blank\" rel=\"noopener noreferrer\">fork<\/a>.<\/p>\n<p>We can break it down as follows:<\/p>\n<pre><code class=\"language-apl\">\u2227\/             \u235d Are all of (0 if any are *not*)\r\n  (\u2264\/          \u235d Set left bits also set in right\r\n     2\u22a5\u2363\u00af1     \u235d in The base-2 representation of\r\n\t      ,)   \u235d The left and right arguments?\r\n<\/code><\/pre>\n<p>The function <em>less than or equal to<\/em> <code class=\"language-apl\">\u2264<\/code> only returns <code class=\"language-apl\">0<\/code> where a left bit is <em>not found<\/em> in the right argument:<\/p>\n<pre><code class=\"language-apl\">      5((\u22a2,\u2365\u2282\u236a\u2364(\u2264\/))2\u22a5\u2363\u00af1,)9   \u235d Just a fancy way of visualising the intermediate and final result\r\n\u250c\u2500\u2500\u2500\u252c\u2500\u2510\r\n\u25020 1\u25021\u2502\r\n\u25021 0\u25020\u2502\r\n\u25020 0\u25021\u2502\r\n\u25021 1\u25021\u2502\r\n\u2514\u2500\u2500\u2500\u2534\u2500\u2518\r\n<\/code><\/pre>\n<p>This is pretty impressive, as it both demonstrates array orientation (in treating both arguments together) and uses Dyalog APL\u2019s fancy inverse operator <code class=\"language-apl\">\u2363\u00af1<\/code> to use as many bits as necessary, while keeping the two representations aligned.<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=2%20(%E2%88%A7%2F(%E2%89%A4%2F2%E2%8A%A5%E2%8D%A3%C2%AF1%2C))%207%208%209%20%20%E2%8D%9D%20is%202%20in%207%20(1%2B2%2B4)%3F&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>8: Zigzag Numbers<\/h2>\n<p>The solution to <a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P8_Zigzag\" target=\"blank\" rel=\"noopener noreferrer\">problem 8<\/a> returns a <code class=\"language-apl\">1<\/code> if its integer argument&#8217;s digits consecutively rise and fall throughout. For example, <code class=\"language-apl\">12121<\/code> is a zigzag number, but <code class=\"language-apl\">1221<\/code> is not.<\/p>\n<p>We saw a handful of solutions of this type:<\/p>\n<pre><code class=\"language-apl\">\u2227\/0&gt;2\u00d7\/2-\/10\u2218\u22a5\u2363\u00af1<\/code><\/pre>\n<p>We can decompose it like so:<\/p>\n<pre><code class=\"language-apl\">\u2227\/                  \u235d Are all\r\n  0&gt;                \u235d Negative for...\r\n    2\u00d7\/             \u235d Consecutively different signs of...\r\n       2-\/          \u235d The pairwise difference of...\r\n          10\u2218\u22a5\u2363\u00af1   \u235d The digits of the input?\r\n<\/code><\/pre>\n<p>It constitutes a good example of how the pattern in trains often is a natural one (this is actually an 8-train), and also shows off two uses of pairwise application <code class=\"language-apl\">2f\/<\/code> to compute the pairwise difference (the sign of which indicates the direction from digit to digit) and then the pairwise product (which due to the rules for multiplication of signed numbers indicates if a change has happened or not).<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=(%E2%88%A7%2F0%3E2%C3%97%2F2-%2F10%E2%88%98%E2%8A%A5%E2%8D%A3%C2%AF1)%C2%A812121%201221&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>9: Rise and Fall<\/h2>\n<p><a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P9_Rise_and_Fall\" target=\"blank\" rel=\"noopener noreferrer\">Problem 9<\/a> involved writing a function to verify if a numeric vector has two properties:<\/p>\n<ul>\n<li>The elements increase or stay the same until the \u201capex\u201d (highest value) is reached<\/li>\n<li>After the apex, any remaining values decrease or remain the same<\/li>\n<\/ul>\n<p>For example:<\/p>\n<pre><code class=\"language-apl\">      (your_solution)\u00a8(1 2 2 3 1)(1 2 3 2 1)(1 3 2 3 1)\r\n1 1 0\r\n<\/code><\/pre>\n<p>Actually, nobody had this exact solution, however, a handful came very close:<\/p>\n<pre><code class=\"language-apl\">\u22a2\u2261\u2308\\\u230a\u2218\u233d\u2308\\\u2218\u233d<\/code><\/pre>\n<p>Instead of trying to analyse the numbers, it does a running maximum from the left and from the right. If the minimum of those matches the original numbers, then we have exactly one peak.<\/p>\n<pre><code class=\"language-apl\">\u22a2             \u235d The input vector\r\n \u2261            \u235d matches\r\n  \u2308\\          \u235d The max-scan from the left (msl)\r\n    \u230a\u2218\u233d       \u235d The lower of msl and \u233dmsr\r\n       \u2308\\\u2218\u233d   \u235d The max-scan from the right (msr)\r\n<\/code><\/pre>\n<p>We can visualise <code class=\"language-apl\">\u230a\u2218\u233d<\/code> by stacking its arguments on top of one another:<\/p>\n<pre><code class=\"language-apl\">      1 3 5,[0.5]\u233d2 5 4\r\n1 3 5\r\n4 5 2\r\n      \u230a\u233f1 3 5,[0.5]\u233d2 5 4\r\n1 3 2\r\n      1 3 5\u230a\u2218\u233d2 5 4\r\n1 3 2\r\n<\/code><\/pre>\n<p>When used with the two <em>max-scans<\/em>, we can see how this solution works.<\/p>\n<pre><code class=\"language-apl\">      (\u2308\\,[0.5]\u2218\u233d\u2308\\\u2218\u233d)1 3 2  \r\n1 3 3  \r\n3 3 2  \r\n      (\u2308\\,[0.5]\u2218\u233d\u2308\\\u2218\u233d)1 0 2  \r\n1 1 2  \r\n2 2 2\r\n<\/code><\/pre>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=(%E2%8A%A2%E2%89%A1%E2%8C%88%5C%E2%8C%8A%E2%88%98%E2%8C%BD%E2%8C%88%5C%E2%88%98%E2%8C%BD)%C2%A8(1%202%202%203%201)(1%202%203%202%201)(1%203%202%203%201)&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>10: Stacking It Up<\/h2>\n<p>The task for <a href=\"https:\/\/problems.tryapl.org\/psets\/2020.html?goto=P10_Stacking_It_Up\" target=\"blank\" rel=\"noopener noreferrer\">problem 10<\/a> was to format a nested vector of simple arrays as if displayed using <code class=\"language-apl\">{\u2395\u2190\u2375}\u00a8<\/code>, and then to return the formatted character matrix (<code class=\"language-apl\">{\u2395\u2190\u2375}\u00a8<\/code> simply returns its argument). For example:<\/p>\n<pre><code class=\"language-apl\">      (your_function) (3 3\u2374\u23739)(\u2191'Adam' 'Michael')(\u237310) '*'(5 5\u2374\u237325)\r\n1 2 3               \r\n4 5 6               \r\n7 8 9               \r\nAdam                \r\nMichael             \r\n1 2 3 4 5 6 7 8 9 10\r\n*                   \r\n 1  2  3  4  5      \r\n 6  7  8  9 10      \r\n11 12 13 14 15      \r\n16 17 18 19 20      \r\n21 22 23 24 25\r\n<\/code><\/pre>\n<p>We had a couple of entries like this:<\/p>\n<pre><code class=\"language-apl\">{\u00af1\u2193\u220a(\u2355\u00a8\u2375),\u00a8\u2395UCS 13}<\/code><\/pre>\n<p>This was a tricky problem, especially as the automated testing didn\u2019t include the <code class=\"language-apl\">'a'1<\/code> test case, and many didn\u2019t catch that one. Whilst most people wrote complicated code to get matrices for the element arrays, two participants thought outside the box, and simply joined the arrays with newlines after converting them to text.<\/p>\n<p><a href=\"https:\/\/tryapl.org\/?clear&amp;q=%7B%C2%AF1%E2%86%93%E2%88%8A(%E2%8D%95%C2%A8%E2%8D%B5)%2C%C2%A8%E2%8E%95UCS%2013%7D(2%202%E2%8D%B4%E2%8E%95A)(2%205%E2%8D%B45%2F0%201)(1%202%203)&amp;run\" target=\"blank\" rel=\"noopener noreferrer\">Try it now with TryAPL<\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>As always, not only are we deeply impressed by the ingenuity and cleverness of your submissions, but we also continue to be amazed by the number of people successfully solving most, if not all, of the problems in Phase I.<\/p>\n<p>If you&#8217;d like to be notified when next year&#8217;s competition launches, go to <a href=\"https:\/\/dyalogaplcompetition.com\/?goto=welcome\" target=\"_blank\" rel=\"noopener\">dyalogaplcompetition.com<\/a> and submit your email address.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We received some excellent competition entries this year. Once again, thank you to all those who participated, congratulations to this year&#8217;s winners, and thank you to the Grand Prize Winner Andrii Makukha for his presentation at this year&#8217;s user meeting. &hellip; <a href=\"https:\/\/www.dyalog.com\/blog\/2020\/12\/highlights-of-the-2020-apl-problem-solving-competition-phase-i\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-6536","post","type-post","status-publish","format-standard","hentry","category-student-competition"],"_links":{"self":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/6536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/comments?post=6536"}],"version-history":[{"count":43,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/6536\/revisions"}],"predecessor-version":[{"id":6638,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/6536\/revisions\/6638"}],"wp:attachment":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/media?parent=6536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/categories?post=6536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/tags?post=6536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}