<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://everything2.com/">
    <title>jliszka's New Writeups</title>
    <link rel="alternate" type="text/html" href="http://everything2.com/index.pl?node=Everything%20User%20Search&amp;usersearch=jliszka" />
    <link rel="self" type="application/atom+xml" href="?node=New%20Writeups%20Atom%20Feed&amp;type=ticker&amp;foruser=jliszka" />
    <id>http://everything2.com/?node=New%20Writeups%20Atom%20Feed&amp;foruser=jliszka</id>
    <updated>2003-08-15T21:53:12Z</updated>
<entry><title>Six toothpicks solution (idea)</title><link rel="alternate" type="text/html" href="http://everything2.com:80/user/jliszka/writeups/Six+toothpicks+solution"/><id>http://everything2.com:80/user/jliszka/writeups/Six+toothpicks+solution</id><author><name>jliszka</name><uri>http://everything2.com:80/user/jliszka</uri></author><published>2003-08-15T21:53:12Z</published><updated>2003-08-15T21:53:12Z</updated>
<content type="html">This is a &lt;a href=&quot;/title/solution&quot;&gt;solution&lt;/a&gt; to &lt;a href=&quot;/title/problem&quot;&gt;problem&lt;/a&gt; 33 on the &lt;b&gt;&lt;a href=&quot;/title/hard+interview+questions&quot;&gt;hard interview questions&lt;/a&gt;&lt;/b&gt; &lt;a href=&quot;/title/node&quot;&gt;node&lt;/a&gt;:
&lt;p&gt;

The problem basically asks you to create &lt;a href=&quot;/title/four&quot;&gt;four&lt;/a&gt; &lt;a href=&quot;/title/equilateral+triangle&quot;&gt;equilateral triangle&lt;/a&gt;s of the &lt;a href=&quot;/title/same&quot;&gt;same&lt;/a&gt; &lt;a href=&quot;/title/size&quot;&gt;size&lt;/a&gt; with &lt;a href=&quot;/title/six&quot;&gt;six&lt;/a&gt; &lt;a href=&quot;/title/toothpick&quot;&gt;toothpick&lt;/a&gt;s.  A bit of &lt;a href=&quot;/title/analysis&quot;&gt;analysis&lt;/a&gt; will tell us that &lt;a href=&quot;/title/four&quot;&gt;four&lt;/a&gt; &lt;a href=&quot;/title/triangle&quot;&gt;triangle&lt;/a&gt;s require &lt;a href=&quot;/title/twelve&quot;&gt;twelve&lt;/a&gt; toothpicks, and since we only have six to &lt;a href=&quot;/title/work&quot;&gt;work&lt;/a&gt; with, that means &lt;a href=&quot;/title/each&quot;&gt;each&lt;/a&gt; toothpick must appear in &lt;a href=&quot;/title/two&quot;&gt;two&lt;/a&gt; triangles.  So every triangle has to &lt;a href=&quot;/title/border&quot;&gt;border&lt;/a&gt; &lt;a href=&quot;/title/three&quot;&gt;three&lt;/a&gt; &lt;a href=&quot;/title/other&quot;&gt;other&lt;/a&gt; triangles (one on each side).  

&lt;p&gt;
&lt;a href=&quot;/title/Think&quot;&gt;Think&lt;/a&gt; &lt;a href=&quot;/title/outside&quot;&gt;outside&lt;/a&gt; of the &lt;a href=&quot;/title/plane&quot;&gt;plane&lt;/a&gt;.  It's a &lt;a href=&quot;/title/tetrahedron&quot;&gt;tetrahedron&lt;/a&gt; (a three-sided &lt;a href=&quot;/title/pyramid&quot;&gt;pyramid&lt;/a&gt;).</content>
</entry><entry><title>Spinning disc solution (idea)</title><link rel="alternate" type="text/html" href="http://everything2.com:80/user/jliszka/writeups/Spinning+disc+solution"/><id>http://everything2.com:80/user/jliszka/writeups/Spinning+disc+solution</id><author><name>jliszka</name><uri>http://everything2.com:80/user/jliszka</uri></author><published>2003-05-29T23:42:04Z</published><updated>2003-05-29T23:42:04Z</updated>
<content type="html">This is a &lt;a href=&quot;/title/solution&quot;&gt;solution&lt;/a&gt; to &lt;a href=&quot;/title/problem&quot;&gt;problem&lt;/a&gt; 32 on the &lt;b&gt;&lt;a href=&quot;/title/hard+interview+questions&quot;&gt;hard interview questions&lt;/a&gt;&lt;/b&gt; &lt;a href=&quot;/title/node&quot;&gt;node&lt;/a&gt;.  If you have not read the &lt;a href=&quot;/title/question&quot;&gt;question&lt;/a&gt;, the &lt;a href=&quot;/title/follow&quot;&gt;follow&lt;/a&gt;ing will make no &lt;a href=&quot;/title/sense&quot;&gt;sense&lt;/a&gt; to you:
&lt;p&gt;
Well, you can do it with &lt;a href=&quot;/title/two&quot;&gt;two&lt;/a&gt; &lt;a href=&quot;/title/cameras&quot;&gt;cameras&lt;/a&gt;:
&lt;p&gt;
If you &lt;a href=&quot;/title/fix&quot;&gt;fix&lt;/a&gt; the two cameras on two &lt;a href=&quot;/title/point&quot;&gt;point&lt;/a&gt;s on the &lt;a href=&quot;/title/disc&quot;&gt;disc&lt;/a&gt; &lt;a href=&quot;/title/right+next+to+each+other&quot;&gt;right next to each other&lt;/a&gt; (but at the same &lt;a href=&quot;/title/distance&quot;&gt;distance&lt;/a&gt; from the &lt;a href=&quot;/title/center&quot;&gt;center&lt;/a&gt; of the disc), then as the disc &lt;a href=&quot;/title/spin&quot;&gt;spin&lt;/a&gt;s, one camera will &lt;a href=&quot;/title/observe&quot;&gt;observe&lt;/a&gt; the &lt;a href=&quot;/title/color&quot;&gt;color&lt;/a&gt; changing just before the other.  From this you can easily &lt;a href=&quot;/title/deduce&quot;&gt;deduce&lt;/a&gt; which &lt;a href=&quot;/title/direction&quot;&gt;direction&lt;/a&gt; the disc is spinning.
&lt;p&gt;
But, you really only need &lt;a href=&quot;/title/one&quot;&gt;one&lt;/a&gt; camera:
&lt;p&gt;
Start by fixing the camera on &lt;a href=&quot;/title/any&quot;&gt;any&lt;/a&gt; point on the disc.  As the disc spins, the camera will observe the color &lt;a href=&quot;/title/alternating+between+black+and+white&quot;&gt;alternating between black and white&lt;/a&gt;.  Now, move the camera around to allow the point the camera is observing to move &lt;a href=&quot;/title/clockwise&quot;&gt;clockwise&lt;/a&gt; with respect to the center of the disc, and note the &lt;a href=&quot;/title/rate&quot;&gt;rate&lt;/a&gt; the color changes.  Move the camera in the other direction, and again note the rate the color changes.  The &lt;a href=&quot;/title/slower&quot;&gt;slower&lt;/a&gt; rate indicates the direction the disc is spinning.
</content>
</entry><entry><title>I didn't say you stole my watch (idea)</title><link rel="alternate" type="text/html" href="http://everything2.com:80/user/jliszka/writeups/I+didn%2527t+say+you+stole+my+watch"/><id>http://everything2.com:80/user/jliszka/writeups/I+didn%2527t+say+you+stole+my+watch</id><author><name>jliszka</name><uri>http://everything2.com:80/user/jliszka</uri></author><published>2003-05-23T22:24:24Z</published><updated>2003-05-23T22:24:24Z</updated>
<content type="html">A good &lt;a href=&quot;/title/illustration&quot;&gt;illustration&lt;/a&gt; of how &lt;a href=&quot;/title/inflection&quot;&gt;inflection&lt;/a&gt; or &lt;a href=&quot;/title/emphasis&quot;&gt;emphasis&lt;/a&gt; can significantly alter the &lt;a href=&quot;/title/meaning&quot;&gt;meaning&lt;/a&gt; of a &lt;a href=&quot;/title/sentence&quot;&gt;sentence&lt;/a&gt;.  Read aloud:
&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;&lt;a href=&quot;/title/I&quot;&gt;I&lt;/a&gt;&lt;/i&gt; didn't say you stole my watch.
&lt;li&gt;I &lt;i&gt;&lt;a href=&quot;/title/didn%2527t&quot;&gt;didn't&lt;/a&gt;&lt;/i&gt; say you stole my watch.
&lt;li&gt;I didn't &lt;i&gt;&lt;a href=&quot;/title/say&quot;&gt;say&lt;/a&gt;&lt;/i&gt; you stole my watch.
&lt;li&gt;I didn't say &lt;i&gt;&lt;a href=&quot;/title/you&quot;&gt;you&lt;/a&gt;&lt;/i&gt; stole my watch.
&lt;li&gt;I didn't say you &lt;i&gt;&lt;a href=&quot;/title/stole&quot;&gt;stole&lt;/a&gt;&lt;/i&gt; my watch.
&lt;li&gt;I didn't say you stole &lt;i&gt;&lt;a href=&quot;/title/my&quot;&gt;my&lt;/a&gt;&lt;/i&gt; watch.
&lt;li&gt;I didn't say you stole my &lt;i&gt;&lt;a href=&quot;/title/watch&quot;&gt;watch&lt;/a&gt;&lt;/i&gt;.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;</content>
</entry><entry><title>Array mode solution (idea)</title><link rel="alternate" type="text/html" href="http://everything2.com:80/user/jliszka/writeups/Array+mode+solution"/><id>http://everything2.com:80/user/jliszka/writeups/Array+mode+solution</id><author><name>jliszka</name><uri>http://everything2.com:80/user/jliszka</uri></author><published>2003-02-13T21:48:07Z</published><updated>2003-02-13T21:48:07Z</updated>
<content type="html">This is a &lt;a href=&quot;/title/solution&quot;&gt;solution&lt;/a&gt; to &lt;a href=&quot;/title/problem&quot;&gt;problem&lt;/a&gt; 31 on the &lt;b&gt;&lt;a href=&quot;/title/hard+interview+questions&quot;&gt;hard interview questions&lt;/a&gt;&lt;/b&gt; &lt;a href=&quot;/title/node&quot;&gt;node&lt;/a&gt;.  If you have not read the &lt;a href=&quot;/title/question&quot;&gt;question&lt;/a&gt;, the &lt;a href=&quot;/title/follow&quot;&gt;follow&lt;/a&gt;ing will make no &lt;a href=&quot;/title/sense&quot;&gt;sense&lt;/a&gt; to you:
&lt;p&gt;
Starting at the &lt;a href=&quot;/title/beginning&quot;&gt;beginning&lt;/a&gt; of the &lt;a href=&quot;/title/array&quot;&gt;array&lt;/a&gt;, &lt;a href=&quot;/title/test&quot;&gt;test&lt;/a&gt; &lt;a href=&quot;/title/consecutive&quot;&gt;consecutive&lt;/a&gt; &lt;a href=&quot;/title/pair&quot;&gt;pair&lt;/a&gt;s for &lt;a href=&quot;/title/equality&quot;&gt;equality&lt;/a&gt;.  If, for &lt;a href=&quot;/title/example&quot;&gt;example&lt;/a&gt;, a(j) == a(j+1), &lt;a href=&quot;/title/continue&quot;&gt;continue&lt;/a&gt; by testing a(j+1) == a(j+2), etc.  As soon as a(j) != a(j+1), r&lt;a href=&quot;/title/emove&quot;&gt;emove&lt;/a&gt; those two elements from the array (suppose it's a &lt;a href=&quot;/title/linked+list&quot;&gt;linked list&lt;/a&gt;) and continue by testing a(j-1) == a(j) (which used to be a(j+2)). Note that removing the two elements maintains the &lt;a href=&quot;/title/invariant&quot;&gt;invariant&lt;/a&gt; that more than &lt;a href=&quot;/title/half&quot;&gt;half&lt;/a&gt; of the elements have the same value.  Once j is &lt;a href=&quot;/title/greater+than&quot;&gt;greater than&lt;/a&gt; half of the &lt;a href=&quot;/title/length&quot;&gt;length&lt;/a&gt; of the remaining list, the &lt;a href=&quot;/title/element&quot;&gt;element&lt;/a&gt; a&lt;a href=&quot;/title/j&quot;&gt;j&lt;/a&gt; is the element we're looking for, since a(0) == a(1) == ... == a(j).  This runs in O(n) since no element a&lt;a href=&quot;/title/ppear&quot;&gt;ppear&lt;/a&gt;s on the &lt;a href=&quot;/title/right+hand+side&quot;&gt;right hand side&lt;/a&gt; of an equality test more than &lt;a href=&quot;/title/once&quot;&gt;once&lt;/a&gt;.
&lt;p&gt;
This &lt;a href=&quot;/title/problem&quot;&gt;problem&lt;/a&gt; is similar to problem 30 on the &lt;a href=&quot;/title/hard+interview+questions&quot;&gt;hard interview questions&lt;/a&gt; &lt;a href=&quot;/title/node&quot;&gt;node&lt;/a&gt;, and so is the &lt;a href=&quot;/title/Good+and+bad+processors+solution&quot;&gt;solution&lt;/a&gt;.
</content>
</entry><entry><title>Good and bad processors solution (idea)</title><link rel="alternate" type="text/html" href="http://everything2.com:80/user/jliszka/writeups/Good+and+bad+processors+solution"/><id>http://everything2.com:80/user/jliszka/writeups/Good+and+bad+processors+solution</id><author><name>jliszka</name><uri>http://everything2.com:80/user/jliszka</uri></author><published>2003-02-13T21:23:30Z</published><updated>2003-02-13T21:23:30Z</updated>
<content type="html">This is a &lt;a href=&quot;/title/solution&quot;&gt;solution&lt;/a&gt; to &lt;a href=&quot;/title/problem&quot;&gt;problem&lt;/a&gt; 30 on the &lt;b&gt;&lt;a href=&quot;/title/hard+interview+questions&quot;&gt;hard interview questions&lt;/a&gt;&lt;/b&gt; &lt;a href=&quot;/title/node&quot;&gt;node&lt;/a&gt;.  If you have not read the &lt;a href=&quot;/title/question&quot;&gt;question&lt;/a&gt;, the &lt;a href=&quot;/title/follow&quot;&gt;follow&lt;/a&gt;ing will make no &lt;a href=&quot;/title/sense&quot;&gt;sense&lt;/a&gt; to you:
&lt;p&gt;
Let the &lt;a href=&quot;/title/processor&quot;&gt;processor&lt;/a&gt;s be &lt;a href=&quot;/title/number&quot;&gt;number&lt;/a&gt;ed 1...n.  &lt;a href=&quot;/title/Begin&quot;&gt;Begin&lt;/a&gt; by asking processor 1 if processor 2 is &lt;a href=&quot;/title/good&quot;&gt;good&lt;/a&gt;.  If the &lt;a href=&quot;/title/answer&quot;&gt;answer&lt;/a&gt; is &quot;&lt;a href=&quot;/title/no&quot;&gt;no&lt;/a&gt;&quot;, &lt;a href=&quot;/title/remove&quot;&gt;remove&lt;/a&gt; these &lt;a href=&quot;/title/two&quot;&gt;two&lt;/a&gt; processors from the &lt;a href=&quot;/title/list&quot;&gt;list&lt;/a&gt; and &lt;a href=&quot;/title/start+over&quot;&gt;start over&lt;/a&gt;.  Note that you removed one good processor and one bad processor from the list, so more than &lt;a href=&quot;/title/half&quot;&gt;half&lt;/a&gt; of the remaining processors are &lt;a href=&quot;/title/still&quot;&gt;still&lt;/a&gt; good.
&lt;p&gt;
If processor 1 says processor 2 is good, &lt;a href=&quot;/title/continue&quot;&gt;continue&lt;/a&gt; by asking processor 2 about processor 3, 3 about 4, &lt;a href=&quot;/title/etc.&quot;&gt;etc.&lt;/a&gt;, until you get a &quot;no&quot; answer.  Suppose it is processor j that says processor j+1 is bad.  Remove both processors j and j+1 from the list (as &lt;a href=&quot;/title/before&quot;&gt;before&lt;/a&gt;, more than half of the remaining processors are still good, since one of the two you removed was good and one was bad), and continue by asking processor j-1 about processor j (the processor that was after j+1 before you removed it and the&amp;hellip;</content>
</entry><entry><title>Pythagorean triples solution (idea)</title><link rel="alternate" type="text/html" href="http://everything2.com:80/user/jliszka/writeups/Pythagorean+triples+solution"/><id>http://everything2.com:80/user/jliszka/writeups/Pythagorean+triples+solution</id><author><name>jliszka</name><uri>http://everything2.com:80/user/jliszka</uri></author><published>2003-02-12T18:54:34Z</published><updated>2003-02-12T18:54:34Z</updated>
<content type="html">This is a &lt;a href=&quot;/title/solution&quot;&gt;solution&lt;/a&gt; to &lt;a href=&quot;/title/problem&quot;&gt;problem&lt;/a&gt; 29 on the &lt;b&gt;&lt;a href=&quot;/title/hard+interview+questions&quot;&gt;hard interview questions&lt;/a&gt;&lt;/b&gt; &lt;a href=&quot;/title/node&quot;&gt;node&lt;/a&gt;.  If you have not read the &lt;a href=&quot;/title/question&quot;&gt;question&lt;/a&gt;, the &lt;a href=&quot;/title/follow&quot;&gt;follow&lt;/a&gt;ing will make no &lt;a href=&quot;/title/sense&quot;&gt;sense&lt;/a&gt; to you:
&lt;p&gt;
First, &lt;a href=&quot;/title/square&quot;&gt;square&lt;/a&gt; each &lt;a href=&quot;/title/element&quot;&gt;element&lt;/a&gt; of the &lt;a href=&quot;/title/array&quot;&gt;array&lt;/a&gt;.  Then &lt;a href=&quot;/title/insert&quot;&gt;insert&lt;/a&gt; every &lt;a href=&quot;/title/pair&quot;&gt;pair&lt;/a&gt; of elements in the array into a &lt;a href=&quot;/title/hash+table&quot;&gt;hash table&lt;/a&gt;, using their &lt;a href=&quot;/title/sum&quot;&gt;sum&lt;/a&gt; as the &lt;a href=&quot;/title/hash+code&quot;&gt;hash code&lt;/a&gt;.  This step is O(&lt;tt&gt;n&lt;/tt&gt;&lt;sup&gt;2&lt;/sup&gt;).  Now, we can easily (O(&lt;tt&gt;n&lt;/tt&gt;) time) test if any element in the array is the sum of a pair of elements by looking up that element in the hash table.  These three elements form a &lt;a href=&quot;/title/Pythagorean+triple&quot;&gt;Pythagorean triple&lt;/a&gt;.</content>
</entry></feed>
