<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: CS50 Week 2: Walkthroughs	</title>
	<atom:link href="https://johnyzaguirre.com/2018/08/14/cs50-week-2-walkthroughs/feed/" rel="self" type="application/rss+xml" />
	<link>https://johnyzaguirre.com/2018/08/14/cs50-week-2-walkthroughs/</link>
	<description>Projects i&#039;ve worked on, articles i&#039;ve written, and tutorials i&#039;ve recorded</description>
	<lastBuildDate>Mon, 27 Apr 2020 12:33:14 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.6.8</generator>
	<item>
		<title>
		By: Johnny		</title>
		<link>https://johnyzaguirre.com/2018/08/14/cs50-week-2-walkthroughs/#comment-17</link>

		<dc:creator><![CDATA[Johnny]]></dc:creator>
		<pubDate>Fri, 28 Dec 2018 01:06:37 +0000</pubDate>
		<guid isPermaLink="false">http://johnyzaguirre.com/?p=654#comment-17</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://johnyzaguirre.com/2018/08/14/cs50-week-2-walkthroughs/#comment-16&quot;&gt;Vladimir&lt;/a&gt;.

Thank you! That is a good point. I hope this article was helpful. Your comment helped me understand a better way to solve this problem set, and i&#039;m sure it will help other programmers who read the comments. Happy new year to you!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://johnyzaguirre.com/2018/08/14/cs50-week-2-walkthroughs/#comment-16">Vladimir</a>.</p>
<p>Thank you! That is a good point. I hope this article was helpful. Your comment helped me understand a better way to solve this problem set, and i&#8217;m sure it will help other programmers who read the comments. Happy new year to you!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Vladimir		</title>
		<link>https://johnyzaguirre.com/2018/08/14/cs50-week-2-walkthroughs/#comment-16</link>

		<dc:creator><![CDATA[Vladimir]]></dc:creator>
		<pubDate>Wed, 26 Dec 2018 19:59:33 +0000</pubDate>
		<guid isPermaLink="false">http://johnyzaguirre.com/?p=654#comment-16</guid>

					<description><![CDATA[Great job!  Please note that there are at least two unnecessary &quot;if&quot; loops:

1) this segment: 


given_octave = atof(&#038;note[octave_pos]);
    exponent = fabs(given_octave - STANDARD_OCTAVE);
    
    if ( given_octave &#062; STANDARD_OCTAVE)
        frequency = STANDARD_HZ * pow(2, exponent);
    
    if ( given_octave &#060;= STANDARD_OCTAVE)
        frequency = STANDARD_HZ / pow(2, exponent);

is absolutely fine without the &#034;if&#034; loop because there is absolutely no need to calculate the absolute value of the exponent. You are fine like this:

 given_octave = atof(&#038;note[octave_pos]);
    exponent = (given_octave - 4);
    frequency = 440.00 * pow(2, exponent);

2) The following segment 

 int semitones = 0;
    char given_letter = note[0];
    char white_keys[] = {&#039;C&#039;, &#039;#&#039;, &#039;D&#039;, &#039;#&#039;, &#039;E&#039;, &#039;F&#039;, &#039;#&#039;, &#039;G&#039;, &#039;#&#039;, &#039;A&#039;, &#039;#&#039;, &#039;B&#039;};
    int a_index = 9;
    if (given_letter != &#039;B&#039;)
    {
        while(white_keys[a_index] != given_letter)
        {
            semitones--;
            a_index--;
        }
    }
    else
    {
        while(white_keys[a_index] != given_letter)
        {
            semitones++;
            a_index++;
        }
    }

could obviously be simplified a little bit to exclude the &#039;if&#039; loop

int semitones = 2;
    char given_letter = note[0];
    char white_keys[] = {&#039;C&#039;, &#039;#&#039;, &#039;D&#039;, &#039;#&#039;, &#039;E&#039;, &#039;F&#039;, &#039;#&#039;, &#039;G&#039;, &#039;#&#039;, &#039;A&#039;, &#039;#&#039;, &#039;B&#039;};
    int a_index = 11;

        while(white_keys[a_index] != given_letter)
        {
            semitones--;
            a_index--;
        }]]></description>
			<content:encoded><![CDATA[<p>Great job!  Please note that there are at least two unnecessary &#8220;if&#8221; loops:</p>
<p>1) this segment: </p>
<p>given_octave = atof(&amp;note[octave_pos]);<br />
    exponent = fabs(given_octave &#8211; STANDARD_OCTAVE);</p>
<p>    if ( given_octave &gt; STANDARD_OCTAVE)<br />
        frequency = STANDARD_HZ * pow(2, exponent);</p>
<p>    if ( given_octave &lt;= STANDARD_OCTAVE)<br />
        frequency = STANDARD_HZ / pow(2, exponent);</p>
<p>is absolutely fine without the &quot;if&quot; loop because there is absolutely no need to calculate the absolute value of the exponent. You are fine like this:</p>
<p> given_octave = atof(&amp;note[octave_pos]);<br />
    exponent = (given_octave &#8211; 4);<br />
    frequency = 440.00 * pow(2, exponent);</p>
<p>2) The following segment </p>
<p> int semitones = 0;<br />
    char given_letter = note[0];<br />
    char white_keys[] = {&#039;C&#039;, &#039;#&#039;, &#039;D&#039;, &#039;#&#039;, &#039;E&#039;, &#039;F&#039;, &#039;#&#039;, &#039;G&#039;, &#039;#&#039;, &#039;A&#039;, &#039;#&#039;, &#039;B&#039;};<br />
    int a_index = 9;<br />
    if (given_letter != &#039;B&#039;)<br />
    {<br />
        while(white_keys[a_index] != given_letter)<br />
        {<br />
            semitones&#8211;;<br />
            a_index&#8211;;<br />
        }<br />
    }<br />
    else<br />
    {<br />
        while(white_keys[a_index] != given_letter)<br />
        {<br />
            semitones++;<br />
            a_index++;<br />
        }<br />
    }</p>
<p>could obviously be simplified a little bit to exclude the &#039;if&#039; loop</p>
<p>int semitones = 2;<br />
    char given_letter = note[0];<br />
    char white_keys[] = {&#039;C&#039;, &#039;#&#039;, &#039;D&#039;, &#039;#&#039;, &#039;E&#039;, &#039;F&#039;, &#039;#&#039;, &#039;G&#039;, &#039;#&#039;, &#039;A&#039;, &#039;#&#039;, &#039;B&#039;};<br />
    int a_index = 11;</p>
<p>        while(white_keys[a_index] != given_letter)<br />
        {<br />
            semitones&#8211;;<br />
            a_index&#8211;;<br />
        }</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
