<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>optimize me #4</title>
		<link>http://tibasicdev.wikidot.com/forum/t-104860/optimize-me-4</link>
		<description>Posts in the discussion thread &quot;optimize me #4&quot;</description>
				<copyright></copyright>
		<lastBuildDate>Wed, 11 Mar 2026 16:25:38 +0000</lastBuildDate>
		
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-104860#post-310023</guid>
				<title>Re: optimize me #4</title>
				<link>http://tibasicdev.wikidot.com/forum/t-104860/optimize-me-4#post-310023</link>
				<description></description>
				<pubDate>Sun, 16 Nov 2008 19:04:02 +0000</pubDate>
				<wikidot:authorName>Weregoose</wikidot:authorName>				<wikidot:authorUserId>7090</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Great. The only thing that needs to be changed in my code is to go from <tt><span style="color: #11119c">L<span style="font-size:smaller;">1</span>=94</span></tt> to <tt><span style="color: #11119c">L<span style="font-size:smaller;">3</span>=94</span></tt>.</p> <p>But, I'm a little doubtful that adding a second <tt><span style="color: #11119c">94</span></tt> can't be avoided.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-104860#post-309886</guid>
				<title>Re: optimize me #4</title>
				<link>http://tibasicdev.wikidot.com/forum/t-104860/optimize-me-4#post-309886</link>
				<description></description>
				<pubDate>Sun, 16 Nov 2008 13:58:02 +0000</pubDate>
				<wikidot:authorName>jnesselr</wikidot:authorName>				<wikidot:authorUserId>142001</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Actually, that code has an error that I just noticed. L1 is the coordinates 0 through 62 for the y coordinate. L2 is for the start of the line, and L3 is for the end of it on the x coordinates. On the code above that, the only way it would work would be to have it make two 94's in the list every time it comes across it. That is why the second loop gets rid of one 94 decreasing the list size by one. Which means that when the loop reaches end, A is added to 1 and stored into A causing it to be at the right element. I could fix the problem where it would overflow with this code:</p> <div class="code"> <pre><code>For(A,1,dim(L1)) if dim(L₁)&gt;A:Then If L₃(A)=94:Then augment(seq(L₁(E),E,1,A-1),seq(L₁(E),E,A+1,dim(L₁))→L₁ augment(seq(L₂(E),E,1,A-1),seq(L₂(E),E,A+1,dim(L₂))→L₂ augment(seq(L₃(E),E,1,A-1),seq(L₃(E),E,A+1,dim(L₃))→L₃ End End End</code></pre></div> <br /> As for the rest of the code, it scans the screen.<br /> I have some parts not included, but they didn't need to be optimized.
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-104860#post-309739</guid>
				<title>Re: optimize me #4</title>
				<link>http://tibasicdev.wikidot.com/forum/t-104860/optimize-me-4#post-309739</link>
				<description></description>
				<pubDate>Sun, 16 Nov 2008 04:21:54 +0000</pubDate>
				<wikidot:authorName>Weregoose</wikidot:authorName>				<wikidot:authorUserId>7090</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Faster? That would crash as it is, so let's worry about that first. <tt><span style="color: #11119c">For(A,1,dim(L<span style="font-size:smaller;">1</span>))</span></tt> sets the destination for <tt><span style="color: #11119c">A</span></tt> and doesn't update it, so shrinking the list would mean later trying to access elements that are no longer there. A conditional loop would solve this, but the optimization I've got in the works would remove the need for searching altogether.</p> <p>If you had a strictly-increasing list prepared but with large numbers at every position for which a <tt><span style="color: #11119c">94</span></tt> exists in <tt><span style="color: #11119c">L<span style="font-size:smaller;">1</span></span></tt>, and then sorted lists 1–3 using the fourth list as a seed (so as to push said elements to the right side), and finally cut out those last elements via <tt><span style="color: #11119c">dim(</span></tt>, you would get the same effect as what your <tt><span style="color: #11119c">seq(</span></tt> lines are accomplishing:</p> <p><tt><span style="color: #11119c"><span style="font-family: verdana;"><span style="font-size:smaller;">E</span></span>9(L<span style="font-size:smaller;">1</span>=94)+cumSum(binomcdf(dim(L<span style="font-size:smaller;">1</span>)-1,0→S<br /> SortA(<span style="font-size:smaller;">L</span>S,L<span style="font-size:smaller;">1</span>,L<span style="font-size:smaller;">2</span>,L<span style="font-size:smaller;">3</span><br /> dim(Ans)-sum(Ans&gt;<span style="font-family: verdana;"><span style="font-size:smaller;">E</span></span>9→dim(L<span style="font-size:smaller;">1</span><br /> Ans→dim(L<span style="font-size:smaller;">2</span><br /> Ans→dim(L<span style="font-size:smaller;">3</span></span></tt></p> <p>This is roughly 100 bytes smaller and probably several times faster. I didn't take a crack at the rest of the code, but the <a href="http://tibasicdev.wikidot.com/optimization">optimization</a> articles might give you a good idea on what other things I might be looking for.</p> <p>This code also abolishes the error that comes up when the first or last element is a <tt><span style="color: #11119c">94</span></tt>.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-104860#post-308124</guid>
				<title>optimize me #4</title>
				<link>http://tibasicdev.wikidot.com/forum/t-104860/optimize-me-4#post-308124</link>
				<description></description>
				<pubDate>Fri, 14 Nov 2008 00:06:10 +0000</pubDate>
				<wikidot:authorName>jnesselr</wikidot:authorName>				<wikidot:authorUserId>142001</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>can it go any faster?</p> <div class="code"> <pre><code>0→Xmin 94→Xmax 0→Ymax –62→Ymin DispGraph &quot;:&quot;→Str9 {0}→L₁ L₁→L₂ L₂→L₃ 0→B For(A,0,62 For(B,0,94 0→Z pxl-Test(A,B)→V If V=1:Then B→C Repeat C≥93 or pxl-Test(A,C)=0 If C&lt;94 C+1→C End dim(L₁)→H A→L₁(H) B→L₂(H) C-1+(pxl-Test(A,C)=1→L₃(H) H+1→H H→dim(L₁) H→dim(L₂) H→dim(L₃) C→B End End Pxl-Change(A,0 End H-1→H H→dim(L₁ H→dim(L₂ H→dim(L₃ ClrDraw For(A,1,dim(L₁)) If L₁(A)=94:Then augment(seq(L₁(E),E,1,A-1),seq(L₁(E),E,A+1,dim(L₁))→L₁ augment(seq(L₂(E),E,1,A-1),seq(L₂(E),E,A+1,dim(L₂))→L₂ augment(seq(L₃(E),E,1,A-1),seq(L₃(E),E,A+1,dim(L₃))→L₃ End End</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>