<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Heiko Dudzus</title>
    <description>The latest articles on DEV Community by Heiko Dudzus (@heikodudzus).</description>
    <link>https://dev.to/heikodudzus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F42977%2F63d93767-f26e-4ebf-9074-0ed28d075d73.jpeg</url>
      <title>DEV Community: Heiko Dudzus</title>
      <link>https://dev.to/heikodudzus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/heikodudzus"/>
    <language>en</language>
    <item>
      <title>Write a program or script to find Lucky Numbers</title>
      <dc:creator>Heiko Dudzus</dc:creator>
      <pubDate>Mon, 12 Feb 2018 18:01:43 +0000</pubDate>
      <link>https://dev.to/heikodudzus/write-a-program-or-script-to-find-lucky-numbers--23me</link>
      <guid>https://dev.to/heikodudzus/write-a-program-or-script-to-find-lucky-numbers--23me</guid>
      <description>&lt;h1&gt;
  
  
  Lucky numbers
&lt;/h1&gt;

&lt;p&gt;After the &lt;a href="https://dev.to/peter/write-a-script-to-find-happy-numbers-133b"&gt;"Happy Numbers" challenge&lt;/a&gt;, here are "Lucky Numbers": Some positive integer numbers are lucky, because they pass the sieve of Josephus.&lt;/p&gt;

&lt;p&gt;The 1 is lucky by definition. &lt;/p&gt;

&lt;p&gt;The successor of 1 is 2. So, every second number gets eliminated:&lt;br&gt;
1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, ...&lt;/p&gt;

&lt;p&gt;The next number is 3. Now, every third number gets eliminated:&lt;br&gt;
1, 3, 7, 9, 13, 15, 19, 21, ...&lt;/p&gt;

&lt;p&gt;Number 3 is lucky! It's successor is 7. Now, every seventh number gets eliminated. And so on.&lt;/p&gt;

&lt;p&gt;Read more about it in &lt;a href="https://en.wikipedia.org/wiki/Lucky_number"&gt;this Wikipedia article&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  Challenge
&lt;/h1&gt;

&lt;p&gt;1) Write a program or script in your language of choice, that prints the lucky numbers between 1 and n.&lt;br&gt;
2) Try to make it as fast as possible for sieving lucky numbers between 1 and a million. (Perhaps it is sensible to measure the time without printing the results.)&lt;/p&gt;

&lt;p&gt;Edit: Consider to start with odd numbers.&lt;/p&gt;

&lt;p&gt;I found it especially interesting to make it fast. That seems to primarily depend on the used data structure. It has to meet different requirements that sometimes seemed contradictive. I am really curious, what data structures you use in your implementation.&lt;/p&gt;
&lt;h1&gt;
  
  
  Verification
&lt;/h1&gt;

&lt;p&gt;There are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;23 lucky numbers below 100, &lt;/li&gt;
&lt;li&gt;153 are below 1000, &lt;/li&gt;
&lt;li&gt;1118 are below 10000,&lt;/li&gt;
&lt;li&gt;8772 are below 100000,&lt;/li&gt;
&lt;li&gt;and among the first million positive integers 71918 are lucky.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The lucky numbers between 1 and 300:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[1, 3, 7, 9, 13, 15, 21, 25, 31, 33, 37, 43, 49, 51, 63, 67, 69, 73, 75, 79, 87, 93, 99, 105, 111, 115, 127, 129, 133, 135, 141, 151, 159, 163, 169, 171, 189, 193, 195, 201, 205, 211, 219, 223, 231, 235, 237, 241, 259, 261, 267, 273, 283, 285, 289, 297]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>challenge</category>
    </item>
    <item>
      <title>Challenge - Print Spiral</title>
      <dc:creator>Heiko Dudzus</dc:creator>
      <pubDate>Sat, 18 Nov 2017 18:07:56 +0000</pubDate>
      <link>https://dev.to/heikodudzus/challenge---print-spiral-6kg</link>
      <guid>https://dev.to/heikodudzus/challenge---print-spiral-6kg</guid>
      <description>&lt;h2&gt;
  
  
  Level 1
&lt;/h2&gt;

&lt;p&gt;Write a program in the language of your choice that will display a ”spiral” of n × n numbers. &lt;br&gt;
For example, here’s what the spiral looks like for n = 10:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*Main&amp;gt; printSpiral 10
99 98 97 96 95 94 93 92 91 90
64 63 62 61 60 59 58 57 56 89
65 36 35 34 33 32 31 30 55 88
66 37 16 15 14 13 12 29 54 87
67 38 17  4  3  2 11 28 53 86
68 39 18  5  0  1 10 27 52 85
69 40 19  6  7  8  9 26 51 84
70 41 20 21 22 23 24 25 50 83
71 42 43 44 45 46 47 48 49 82
72 73 74 75 76 77 78 79 80 81
*Main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Level 2
&lt;/h2&gt;

&lt;p&gt;Make sure your program uses constant (or linear) space. This means, it is not allowed to build an array before printing it (or to build another data structure consuming space with O( n^2 ).&lt;/p&gt;

&lt;p&gt;Idea found here: &lt;a href="https://www.quora.com/What-are-some-interesting-puzzles-asked-in-computer-science-programming-technical-interviews"&gt;https://www.quora.com/What-are-some-interesting-puzzles-asked-in-computer-science-programming-technical-interviews&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Post your solution in the comments below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clarification
&lt;/h2&gt;

&lt;p&gt;For a solution in O(n) it is allowed to build a String (or Array,...) for a single line, but still not to build an array containing &lt;em&gt;all&lt;/em&gt; information contained in the spiral. Perhaps this fits better to your language of choice or it is good for building a prototype,... Thanks for asking, Evan Oman.&lt;/p&gt;

</description>
      <category>puzzle</category>
      <category>fun</category>
      <category>challenge</category>
    </item>
  </channel>
</rss>
