<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Vacuous Virtuoso &#187; challenge</title>
	<link>http://lipidity.com</link>
	<description>Despotic Development</description>
	<pubDate>Tue, 23 Dec 2008 06:24:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Programming Challenge #3</title>
		<link>http://lipidity.com/development/programming-challenge-3/</link>
		<comments>http://lipidity.com/development/programming-challenge-3/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 05:40:59 +0000</pubDate>
		<dc:creator>Ankur</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[challenge]]></category>

		<guid isPermaLink="false">http://dev.lipidity.com/general/programming-challenge-3</guid>
		<description><![CDATA[Another little puzzle to keep you thinking. I saw this problem during the reign of the dinosaurs, and thought it was pretty clever.



El problemo

Write some code that prints 543210012345.

You code must meet the following conditions:


You must use single a loop (eg. for or while) and each iteration of your loop may only print one character [...]]]></description>
			<content:encoded><![CDATA[<p>Another little puzzle to keep you thinking. I saw this problem during the reign of the dinosaurs, and thought it was pretty clever.</p>

<!--more-->

<h3>El problemo</h3>

<p>Write some code that prints <code>543210012345</code>.</p>

<p>You code must meet the following conditions:</p>

<ul>
<li>You must use <ins>single</ins> a loop (eg. <code>for</code> or <code>while</code>) and each iteration of your loop may only print one <del datetime="2007-07-13T07:05:59+00:00">character</del> <ins>digit</ins>.</li>
<li>No <code>if</code> statements, no ternary operators.</li>
<li>No strings, no arrays. Numbers only.</li>
<li>You may only use at most one variable.</li>
<li>You may use language-specific functions / methods (but it&#8217;s not necessary).</li>
</ul>

<hr />

<p>As always, use any programming language you like and post up your answers in the comments. Once there have been several attempts, I&#8217;ll post up my suggested answers. It&#8217;ll be interesting to see the different ways people do this, and the various optimization techniques that are utilized.</p>

<p>Good luck!</p>

<p><strong>Note:</strong> When leaving a comment, indent your code blocks by four space or one tab so the formatting is saved and you don&#8217;t have to escape characters. For inline code, wrap it in backticks, eg. <code>`This is some code`</code></p>
]]></content:encoded>
			<wfw:commentRss>http://lipidity.com/development/programming-challenge-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Programming challenge #2</title>
		<link>http://lipidity.com/development/programming-challenge-2/</link>
		<comments>http://lipidity.com/development/programming-challenge-2/#comments</comments>
		<pubDate>Tue, 08 May 2007 10:53:19 +0000</pubDate>
		<dc:creator>Ankur</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[challenge]]></category>

		<guid isPermaLink="false">http://dev.lipidity.com/dev/programming-challenge-2</guid>
		<description><![CDATA[Another little mini-question to keep you thinking. The <a href="http://dev.lipidity.com/dev/programming-challenge-1">first one</a> was definitely too easy, so we'll slowly increase the degree of difficulty as we go along.

No more trigonometric functions this time; we're going to Cartesian coordinates. This is a re-adapted version of a sample problem from Google Code Jam. Here it is.]]></description>
			<content:encoded><![CDATA[<h2>Part A</h2>

<p>The new iFone<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> mobile needs to be able to find and connect to the nearest phone tower. Each phone is fed a list of Cartesian coordinates of the towers within range, and a coordinate of the phone&#8217;s current position.</p>

<p>The coordinates and IDs of the phone towers are passed to the phone as soon as they are within range.</p>

<p>Write a function that takes parameters of the ID, x and y coordinates of a phone tower and if it&#8217;s closer than the current connected tower, calls the <code>connectToTower()</code> function passing the ID of the tower.</p>

<p>The phone&#8217;s coordinates are two global variables, <code>phoneX</code> and <code>phoneY</code>, while the currently connected tower has coordinates stored in <code>cTowerX</code> and <code>cTowerY</code>.</p>

<p>A little pseudo-code to help you along the way:</p>

<pre><code>function checkTower(towerID, towerX, towerY){
    // phoneX, phoneY, cTowerX and cTowerY are available...
    find distance to currently connected tower
    find distance to passed tower
    if( passed tower is closer than currently connected tower ){
        connectToTower( towerID );
    }
}
</code></pre>

<!--
ANS:
function checkTower(towerID, towerX, towerY){
distToCurrent = ( (phoneX-cTowerX)^2 + (phoneY-cTowerY)^2 )^0.5;
distToThis = ( (phoneX-towerX)^2 + (phoneY-towerY)^2 )^0.5;
if( distToThis < distToCurrent ){
connectToTower(towerID);
}
}
-->

<p>This should be fairly straightforward. As usual, post up the answers in the comments using any programming language you like. Good luck!</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>Don&#8217;t sue me Apple!&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://lipidity.com/development/programming-challenge-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Programming challenge #1</title>
		<link>http://lipidity.com/development/programming-challenge-1/</link>
		<comments>http://lipidity.com/development/programming-challenge-1/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 09:32:52 +0000</pubDate>
		<dc:creator>Ankur</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[challenge]]></category>

		<guid isPermaLink="false">http://dev.lipidity.com/dev/programming-challenge-1</guid>
		<description><![CDATA[Programming is more than simply remembering a few functions and properties and calling them. It's about thinking, processing, ordering, planning and implementing. Programming, real programming, requires a keen understanding of what you want to do, what you're doing, and what needs to be done. Sound complicated? It's not. Here's the first of a few questions that you as a programmer should be able to do in your sleep. You can leave answers in the comments. The programming language you use doesn't matter.]]></description>
			<content:encoded><![CDATA[<h2>Part A</h2>

<p>Write a function that returns the height of a bouncing ball above ground in metres after specified time (in seconds) if the ball is taking five seconds to complete each bounce (up and back down) and reaches a maximum height of 3 metres at the peak of each bounce. The initial position of the ball (after 0 seconds) is at ground level (0 metres).</p>

<p>Your function should take as a parameter the time elapsed in seconds (<code>t</code>) and return a numerical value of the height of the ball after that many seconds. Any approximations should be to at least four decimal places.
<!--
ANS:
`function height(t){ return ((3*sin(2*3.1416*t/10))^2)^(0.5); }`
--></p>

<p>Bonus points earned if your function uses only one line of code.</p>

<p>Hint: Think periodic / cyclic function and half your work is done.
Duoble Hint: You could use Grapher.app to check your answer&#8230;</p>

<h2>Part B</h2>

<p>Expand your function from Part A so that every time the ball hits the ground, the <code>boink()</code> function is called. (Assume <code>boink()</code> is already defined)</p>

<hr />

<p>Easy? I&#8217;m sure many people wouldn&#8217;t bother reading past the first sentence, but it just shows how important it is as a programmer to be familiar with math and physics, and to be able to apply your skills. Those application tasks that you hated at school were good for you.</p>

<p>While a lot of this could be done through using or examining readily available source code or libraries, it&#8217;s beneficial to be familiar with the basic concepts. Quoting <a href="http://howstuffworks.com">howstuffworks</a>, &#8220;it&#8217;s good to know&#8221;.</p>

<p><strong><a href="http://dev.lipidity.com/dev/programming-challenge-2">Continue to challenge #2</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://lipidity.com/development/programming-challenge-1/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
