tag:blogger.com,1999:blog-58726238382950779862024-03-15T18:09:28.367-07:00JavaProblems.com - Free coding problems and exercisesOne of the largest java programming blogs in Lebanon, use the search box to find any problems you desire. More than 800 java problems and solutions.Unknownnoreply@blogger.comBlogger863125tag:blogger.com,1999:blog-5872623838295077986.post-76457879924534136632016-09-28T01:50:00.000-07:002016-09-28T01:50:20.943-07:00Beginners - 1 Basics<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
Here are some little things you should keep in mind after first installing Eclipse and making your first file.</div>
<h2>
Identifiers></h2>
<div>
In your code, you must have seen a lot of bold colored words(for ex: <b><span style="color: purple;">public static void</span></b> main). Those words (like public, class, static, etc.) are called 'Identifiers'. Basically, they are Java's vocab words which you cannot use as your own or in different ways.</div>
<h2>
Comments</h2>
<div>
Let's say that the only reason why you are making this Lincoln file is to show display the sentence 'A quote by Abe Lincoln: I am Abraham Lincoln'. You never write code without a purpose/requirement/function. So, to make sure you remember why we're writing this file, type the following:</div>
<pre class="brush:java;"> //display something about Abe </pre>
<br />
And press enter. Did you notice that the color has changed? This is called a comment. We use comments to "explain the purpose of the program and describe processing steps". They don't effect our code so we can write as many comments as we want as long as we always start them off with a // for each line of code.<br />
An alternative is to type to close it off. Try it out for yourself<br />
<pre class="brush:java;"> /* and write as many lines as you want (or just one)
and then type */ </pre>
<br />
<h2>
White Space</h2>
When coding, Java doesn't give a shit about the white space or new lines you have in your code. Meaning, you can put hundreds of spaces and tabs between <b>System.out.println("bla");</b><b> </b>(i.e. <b>System . out.println ( "bla" );</b>), and Java will interpret this the same as <b>System.out.println("bla")</b>. The only time a space will make a difference is when it's inside the <b>"" </b> of the <b>println("') </b>statement. But, even though spaces mean nothing, you should always try to limit your spaces and maintain the same tabs that Java automatically generates (such as between <b>{ }</b>) so that your code is readable and not annoying to the people who didn't write it.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7KQEe_rmlTlpBC3qqdDKj0TUcj1_DzFxmg06HBDPmuriK_rCn_98voh8s6rk_qHbH6KY7AatgCp75G6j1LU76fIdaA04b98IWq5o-IASs4uuKI8GEqlH8dzwU5e7cikLSGhDLRGvvEW0K/s1600/run.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7KQEe_rmlTlpBC3qqdDKj0TUcj1_DzFxmg06HBDPmuriK_rCn_98voh8s6rk_qHbH6KY7AatgCp75G6j1LU76fIdaA04b98IWq5o-IASs4uuKI8GEqlH8dzwU5e7cikLSGhDLRGvvEW0K/s1600/run.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
More to come soon...</div>
<table style="text-align: right;">
<tbody>
<tr>
<th scope="col"><pre> </pre>
</th>
<th scope="col"></th>
<th scope="col"><pre> </pre>
</th>
<th scope="col"></th>
</tr>
</tbody></table>
</div>
uhttp://www.blogger.com/profile/16734963091895533988noreply@blogger.com39tag:blogger.com,1999:blog-5872623838295077986.post-58216373168289313822015-09-20T03:28:00.001-07:002015-09-20T03:28:32.154-07:00Compiling a arithmetic code in C Using Registers<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Problem:</b> The compiler has a bug inside and it is not working. You have to its job to associate program variables with registers:<br />
<br />
<b>Solution:</b><br />
<span style="font-family: Courier New, Courier, monospace;">f = (g + h) - (i + j)</span><br />
<span style="font-family: Courier New, Courier, monospace;">add $t0, $s1, $s2 #gets g + h</span><br />
<span style="font-family: Courier New, Courier, monospace;">add $t1 ,$s3, $s4 #gets i + j</span><br />
<span style="font-family: Courier New, Courier, monospace;">sub $s0, $t0 , $t1 # gets (g + h) - (i +j)</span></div>
Unknownnoreply@blogger.com39tag:blogger.com,1999:blog-5872623838295077986.post-84309267071020776242015-09-20T03:24:00.000-07:002015-09-20T03:24:27.747-07:00Convert this C code into Assembly (MIPS)<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Problem: </b>Hello there, I am an old guy who understands only low level languages and my son showed me this C code: <i>f = (g + h) - (i + j);</i><br />
Would you help convert this to assembly?<br />
<br />
<b>Solution:</b><br />
<span style="font-family: Courier New, Courier, monospace;">#Remember that arithmetic operations can have at most three operands.</span><br />
<span style="font-family: Courier New, Courier, monospace;">sum x, g, h #Puts the <i>addition</i> of g and h in x</span><br />
<span style="font-family: Courier New, Courier, monospace;">sum y, i, j </span><span style="font-family: 'Courier New', Courier, monospace;">#Puts the </span><span style="font-family: 'Courier New', Courier, monospace;"><i>addition</i></span><span style="font-family: 'Courier New', Courier, monospace;"> of i and j in y</span><br />
<span style="font-family: Courier New, Courier, monospace;">sub f, x, y #Puts the <i>subtraction</i> of x and y into f</span></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5872623838295077986.post-21687354886413643902015-09-20T02:35:00.000-07:002015-09-20T02:35:30.964-07:00Put the sum of variables b, c, d, and e into variable a in assembly (MIPS)<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Problem: </b>Create an assembly sequence (or code) that places the sum of variables b, c, d, and e into variable a.<br />
<br />
<b>Solution: </b><br />
<b><br /></b>
<span style="font-family: Courier New, Courier, monospace;">add a, b, c #Puts the sum of b and c into variable a</span><br />
<span style="font-family: Courier New, Courier, monospace;">add a, a, d #Puts the sum of a and d into a new variable a</span><br />
<span style="font-family: Courier New, Courier, monospace;">add a, a, e #Puts the sum of a and e into a new variable a</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">#Now you have the sum of b, c, d and e into a.</span></div>
Unknownnoreply@blogger.com7tag:blogger.com,1999:blog-5872623838295077986.post-12871806785634042122015-06-09T06:17:00.000-07:002015-07-21T04:15:30.307-07:00Regular Expressions: Match a or b (a|b) example<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Make a regular expression that matches <b>I love cats</b> and <b>I love dogs </b>but not <b>I love logs</b>.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZGcDYVBVk_7kglW-f3LhRE3kAX9XqVhXceLZKRMGcY0q8otkjYhka7DHFTwgNKkuwW5KHviE37RaF1tmRfLrd9wJRJQZT6OYsTrnptdVgc8IHh2Zw5OQCpEalBaNmG1mkGI9K4DKZ_HeO/s1600/Screen+Shot+2015-06-09+at+4.14.57+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="94" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZGcDYVBVk_7kglW-f3LhRE3kAX9XqVhXceLZKRMGcY0q8otkjYhka7DHFTwgNKkuwW5KHviE37RaF1tmRfLrd9wJRJQZT6OYsTrnptdVgc8IHh2Zw5OQCpEalBaNmG1mkGI9K4DKZ_HeO/s640/Screen+Shot+2015-06-09+at+4.14.57+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;">I love (cats|dogs)
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-5872623838295077986.post-85377391559980930422015-06-09T06:13:00.000-07:002015-07-21T04:15:35.789-07:00Regular Expressions: Capturating dimensions of a screen<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Using regular expressions, capture the dimensions of a video or a screen.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizssSb8805VQ2iEeEXXGRzGBk0exEhtvrOvQA8hldjAXUlzRVXw8USMS7zGBEPA6fhQ3gF-XnepeBWEQ0qrZ-1TO1xhe0i3t8trzTz7FVFDG0Q25171XTpFdXdXC-txX0n7WxcEjG8LbE_/s1600/Screen+Shot+2015-06-09+at+4.09.21+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="94" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizssSb8805VQ2iEeEXXGRzGBk0exEhtvrOvQA8hldjAXUlzRVXw8USMS7zGBEPA6fhQ3gF-XnepeBWEQ0qrZ-1TO1xhe0i3t8trzTz7FVFDG0Q25171XTpFdXdXC-txX0n7WxcEjG8LbE_/s640/Screen+Shot+2015-06-09+at+4.09.21+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: inherit; font-size: x-large;"><b>Solution:</b></span></h2>
<div>
<span style="font-family: Courier New, Courier, monospace;">Since we don't if the dimension will be three or four dimensions. Using the "+" sounds appropriate here.</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br />So:<b> \d+x\d+</b></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Capturing what you need: <span style="color: red;"><b>(</b></span></span><b style="font-family: 'Courier New', Courier, monospace;">\d+<span style="color: red;">)</span>x<span style="color: red;">(</span>\d+<span style="color: red;">)</span></b></div>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;">
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5872623838295077986.post-78830486509599410072015-06-09T06:01:00.001-07:002015-07-21T04:15:41.413-07:00Regular Expressions: Capturing the date<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Using regular expressions, first detect the text; then capture the date according to the output.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGxjGDdJ6hzQIqcXWx_mHjVJW6IH05Ia3338CuSPIUNyoIUJ9qrwIgaqQDUFPFGloUW37qz_02SlADGSYOiWETWDcFCSts6TfsDUO-T88p31I7AdtTcRTf6eJWZJUgnI0jDZlMXpPYapuV/s1600/Screen+Shot+2015-06-09+at+3.46.34+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="140" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGxjGDdJ6hzQIqcXWx_mHjVJW6IH05Ia3338CuSPIUNyoIUJ9qrwIgaqQDUFPFGloUW37qz_02SlADGSYOiWETWDcFCSts6TfsDUO-T88p31I7AdtTcRTf6eJWZJUgnI0jDZlMXpPYapuV/s640/Screen+Shot+2015-06-09+at+3.46.34+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;"><b>Part A:</b> Detects the text</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><i><b>\w:</b></i> designates a string</span><br />
<span style="font-family: Courier New, Courier, monospace;"><i><b>\d:</b></i> designates a number</span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>\s:</b> designates a whitespace</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><b>\w{1,3}:</b> designates three characters.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>\d{1,4}: </b>designates a four numbers<b>.</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>\s: </b>designates a white space.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Merging: <b>\w{1,3}\s\d{1,4}</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">That would detect the text perfectly but not capture what is demanded, look:</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-IPDlUlms7yypK40CdxBm4gP6Mx70uQES6IOCWs8rti-t4vOU3povFMWvIIyu4d7YzYW-3ycf6QSKtplRCBjw6v8Rw5rvhBnAhoHbEIMsAx1VtOLi4ySutIDdNhtECXvORHO5JUVyLp13/s1600/Screen+Shot+2015-06-09+at+3.54.59+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="184" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-IPDlUlms7yypK40CdxBm4gP6Mx70uQES6IOCWs8rti-t4vOU3povFMWvIIyu4d7YzYW-3ycf6QSKtplRCBjw6v8Rw5rvhBnAhoHbEIMsAx1VtOLi4ySutIDdNhtECXvORHO5JUVyLp13/s640/Screen+Shot+2015-06-09+at+3.54.59+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<b style="font-family: 'Courier New', Courier, monospace;">Part B:</b><span style="font-family: 'Courier New', Courier, monospace;"> Captures the date</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">We have:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b>\w{1,3}\s\d{1,4}</b></span></div>
</div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">To capture what you want, simple add parentheses.</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">First the date:</span></div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b>\w{1,3}\s<span style="color: red;">(</span>\d{1,4}<span style="color: red;">)</span></b></span></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Then the whole expression:</span></div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b><span style="color: red;">(</span>\w{1,3}\s\d{1,4}<span style="color: red;">)</span></b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b><span style="color: red;"><br /></span></b></span>
<span style="font-family: Courier New, Courier, monospace;">Now, you have to merge both:</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b><span style="color: red;">(</span>\w{1,3}\s<span style="color: red;">(</span>\d{1,4}<span style="color: red;">))</span></b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b><span style="color: red;"><br /></span></b></span>
<span style="font-family: Courier New, Courier, monospace;">Works:</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b><span style="color: red;"><br /></span></b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb8YAp8pk8VhBPBCErxhXqtm8YXfhWNortgNavovGp8myYBFflJIAFS_jKZArraLo9mimIj6mn5j_HLgAdWSINHVLpJOwSgBWz6K9RxO4DbEJBUKhJTSRXxzQj39yDK772pj8R5SOXxcXt/s1600/Screen+Shot+2015-06-09+at+3.59.24+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="184" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb8YAp8pk8VhBPBCErxhXqtm8YXfhWNortgNavovGp8myYBFflJIAFS_jKZArraLo9mimIj6mn5j_HLgAdWSINHVLpJOwSgBWz6K9RxO4DbEJBUKhJTSRXxzQj39yDK772pj8R5SOXxcXt/s640/Screen+Shot+2015-06-09+at+3.59.24+PM.png" width="640" /></a></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b><span style="color: red;"><br /></span></b></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b>Alternative solution:</b></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">(\w+ (\d+))</span></div>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5872623838295077986.post-16916167464255499032015-06-09T05:44:00.000-07:002015-07-21T04:15:46.384-07:00Regular Expressions: Match the documents ending with .pdf<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Create a regex expression that matches only documents ending with .pdf.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjZ6w2l6x3BBmb6C4sDYYh_AkcL1tRucAGFSuN38u99QhOxW19qsGiywtSqMt2Ltb0zU2w2ywXOk-cFYdGRSHcgbvvwkD1n3xuh3GQDrL64Gs2Wz4c7CUR3K6BN9Nbs3Ta_wikxHwqMDNP/s1600/Screen+Shot+2015-06-09+at+3.21.03+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="98" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjZ6w2l6x3BBmb6C4sDYYh_AkcL1tRucAGFSuN38u99QhOxW19qsGiywtSqMt2Ltb0zU2w2ywXOk-cFYdGRSHcgbvvwkD1n3xuh3GQDrL64Gs2Wz4c7CUR3K6BN9Nbs3Ta_wikxHwqMDNP/s640/Screen+Shot+2015-06-09+at+3.21.03+PM.png" width="640" /></a><span style="font-family: Courier New, Courier, monospace;"><br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;">I can't see an example importanter than this.
</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b>Step 1:</b> Start with the ending. Tell the regex you want your the file to end with <b>.pdf</b>. To do that just type: <b>\.pdf$ </b>(<b>^</b> indicates the beginning of the file, <b>$</b> indicates the ending of the file).</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b>Step 2: </b>You don't care how the string begins and how many characters it will contain. So, you look for the regex note that indicates any regular character; it is already known <b>\w</b>.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b>Step 3:</b> You don't know how many characters there are; it should be at least one character; the file cannot be ".pdf"; so for that you add <b>+</b> to the <b>\w: \w+.</b></span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><b>Step 4: </b>Merge everything: <b>\w+\.pdf$</b></span><br />
<span style="font-family: Courier New, Courier, monospace;">That would capture for example: <b>file_a_record_file.pdf</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;"><b>Step 5:</b> The question is asking for <b>file_a_record_file</b> only! Not the <b>pdf</b> extension</span><span style="font-family: 'Courier New', Courier, monospace;">. No problem. Just do this: <b>(\w+\)\.pdf$.</b></span><br />
<span style="font-family: Courier New, Courier, monospace;">The paranthenties indicate that you're not interested in the .pdf thingy.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Final Answer: </span><b style="font-family: 'Courier New', Courier, monospace;">(\w+\)\.pdf$.</b></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5872623838295077986.post-28523026516832830382015-06-09T05:04:00.000-07:002015-07-21T04:15:49.648-07:00Regular Expressions: Successful vs. Unsuccessful<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Match exactly the phrase "Mission: Successful" according to the output using regular expressions.<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1DN0Ig9KW63FuMAVZU0p7j_JWkE65NBHb9ihxy3QKMJPhLETZ0lzAy7gF4jmWs3YOMra3KHw3ImhuPaWPdxgEEDgJdXrdngf9NIJspCQFhdCAyyc24u_QWoRxRLup2MMrEP2OE9KR8zt9/s1600/Screen+Shot+2015-06-09+at+3.02.59+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="136" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1DN0Ig9KW63FuMAVZU0p7j_JWkE65NBHb9ihxy3QKMJPhLETZ0lzAy7gF4jmWs3YOMra3KHw3ImhuPaWPdxgEEDgJdXrdngf9NIJspCQFhdCAyyc24u_QWoRxRLup2MMrEP2OE9KR8zt9/s640/Screen+Shot+2015-06-09+at+3.02.59+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;">^Mission: Successful$
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-5872623838295077986.post-85503668628210336082015-06-09T04:49:00.002-07:002015-07-21T04:15:54.449-07:00Regular Expressions: Whitespace Exercise<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Validate those texts "<b>1. abc</b>" , "<b>2. abc</b>" and "<b>3. abc</b>" and skip this text "4.abc" in this regular expression problem.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNXgBE4iM2inGtLbPNeMdl6lXgNC1pho2SxCbLikC01joWA17rv_eUV_ieMGpgOtFd3CpEAWxqbJSKa7wFEOZkjMg2y8ojoUnzGdW_QbbpFQkxD6ZT3ncytkEtgr5XaUOItKBSXH2aRDkG/s1600/Screen+Shot+2015-06-09+at+2.36.29+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="118" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNXgBE4iM2inGtLbPNeMdl6lXgNC1pho2SxCbLikC01joWA17rv_eUV_ieMGpgOtFd3CpEAWxqbJSKa7wFEOZkjMg2y8ojoUnzGdW_QbbpFQkxD6ZT3ncytkEtgr5XaUOItKBSXH2aRDkG/s640/Screen+Shot+2015-06-09+at+2.36.29+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;">
Let's solve this step-by-step; as you know to solve this regular expression; you have to take it character-by-character:</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b>Step 1:</b> The first character is integer (or number)! This means that you need to tell the regular expression that the first character is a digit (number). To do that you have to add: <b>\d </b>- which designates a digit.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b>Step 2:</b> You add the dot "." and you escape it: <b>\.</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span>
<span style="font-family: Courier New, Courier, monospace;"><b>Step 3: </b>This is the trickiest part. First the white space could be normal space or a tab! To designate a tab you need to add <b>\t</b> and a normal space you add a <b>_</b>; since you might have both. You add <b>\s</b> which designates both tabs and normal spaces! Now <b>\s</b> designates one whitespace only; so you have to tell you the regular expression you might have more whitespaces which you indicate <b>\s* </b>but wait a second! The star means you might have at least zero whitespace and it goes into skip text; you have to tell the regular expression that you can't have zero whitespaces; one and more only! This is the where the Kleene "+" comes into place. To indicate one and more whitespace you add <b>\s+</b>.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b>Step 4:</b> Really as easy as counting <b>abc</b> now ;) </span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">So, at the end: <b>\d\.\s+abc</b></span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5872623838295077986.post-81604529773697328202015-06-09T03:47:00.003-07:002015-07-21T04:15:59.811-07:00Regular Expressions: Interrogation Mark<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Match the following expressions "<b>1 file found?</b>", "<b>2 files found?</b>" and "<b>x files found?</b>" using the interrogation mark.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLHENJHVIWpZXokHtppZQQxWDx4V5W6nH9jgEJjxLX7OdrmCHUkHA5v09rMhomeztouMWqL1ddE3YIOBJ1bwAFVNCVuxehtjSCC_ZB8mOlESE7YcQIxQpsoiQ6FcKzwTTPanPhvotsuo4S/s1600/Screen+Shot+2015-06-09+at+1.43.31+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLHENJHVIWpZXokHtppZQQxWDx4V5W6nH9jgEJjxLX7OdrmCHUkHA5v09rMhomeztouMWqL1ddE3YIOBJ1bwAFVNCVuxehtjSCC_ZB8mOlESE7YcQIxQpsoiQ6FcKzwTTPanPhvotsuo4S/s640/Screen+Shot+2015-06-09+at+1.43.31+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;">You could be doing this: <b>1?2?x? files? found\?
</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span>
<span style="font-family: Courier New, Courier, monospace;">Or</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">This: <b>\w files? found\?</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span>
<span style="font-family: Courier New, Courier, monospace;">\w indicates that it could be any character, I assume.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Alternatively, you can use: .</span><b style="font-family: 'Courier New', Courier, monospace;"> files? found\?</b></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-5872623838295077986.post-73674961138821080762015-06-09T03:38:00.000-07:002015-06-09T03:38:15.696-07:00Regular Expressions: Match those texts using Kleene<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Match "<b>aaaabcc</b>", "<b>aabbbbc</b>", "<b>aacc</b>" using a regular expression. Note: Using a Kleene Plus or Kleene Star is a must.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUvWCFaEUheh8z38Xz-l010vSTng1j0jFmcWD0tZWmcLBq_ZxIzkNyPCsdGxzCXLOOqsRD2irQC_yUZl5aYTudf9H9IdOJxlLfWUpdJDy7kDAXo_MR0TntjwCRsnvotjG9dAHASfh6Ch7F/s1600/Screen+Shot+2015-06-09+at+1.35.08+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUvWCFaEUheh8z38Xz-l010vSTng1j0jFmcWD0tZWmcLBq_ZxIzkNyPCsdGxzCXLOOqsRD2irQC_yUZl5aYTudf9H9IdOJxlLfWUpdJDy7kDAXo_MR0TntjwCRsnvotjG9dAHASfh6Ch7F/s640/Screen+Shot+2015-06-09+at+1.35.08+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;">The ideal laziest solution would be <b>a*b*c*</b>.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Using <b>aaaabcc|aabbbbc|aacc</b> is wrong since you're not using Kleenee.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-5872623838295077986.post-63225955297237466562015-06-09T03:18:00.001-07:002015-07-21T04:16:13.319-07:00Regular Expressions: Catching some zzz's<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Using regular expressions, catch the expressions "<b>wazzzzup</b>" and "<b>wazzzup</b>". Catching "wazup " is not allowed. Remember that you are forced to catch all the z's in the expressions!<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBAmzMQRWPq0sLYLf_o71UUfoEVJFhJk49643cHIHoKJ9LdHUos5bWxHBVr3h6jmJ4xPccmAebW8pIhz75wTFb1NktUQwQcDf_S_iYXCTBj9vPYZDyNPHGur2w7a9XThDs7DkIl5WLZDee/s1600/Screen+Shot+2015-06-09+at+1.17.17+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="94" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBAmzMQRWPq0sLYLf_o71UUfoEVJFhJk49643cHIHoKJ9LdHUos5bWxHBVr3h6jmJ4xPccmAebW8pIhz75wTFb1NktUQwQcDf_S_iYXCTBj9vPYZDyNPHGur2w7a9XThDs7DkIl5WLZDee/s640/Screen+Shot+2015-06-09+at+1.17.17+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">z{3,4}
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-5872623838295077986.post-72898542586358520392015-06-09T03:11:00.003-07:002015-07-21T04:16:09.965-07:00Regular Expressions: Character Ranges <div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Using character ranges of regular expressions, create a regular expression that matches: <b>Ana</b> <b>Bob</b> <b>Cpc</b> but does not match <b>aax</b> <b>bby</b> <b>ccz</b>.<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisSmJYAjFaMrmtAbfn68UCZ6F-psCfmznAbBBaPQPpnX7387oCv2A-YmNJqBb-r6SvKbKpNCclhOVYKfMS1DkrE0NDsZzDuHjidTH1F1IS3tpgOa8NmQefROjBiwKMmWFuCihqmeEgBadj/s1600/Screen+Shot+2015-06-09+at+1.10.59+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisSmJYAjFaMrmtAbfn68UCZ6F-psCfmznAbBBaPQPpnX7387oCv2A-YmNJqBb-r6SvKbKpNCclhOVYKfMS1DkrE0NDsZzDuHjidTH1F1IS3tpgOa8NmQefROjBiwKMmWFuCihqmeEgBadj/s640/Screen+Shot+2015-06-09+at+1.10.59+PM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<span style="font-family: Courier New, Courier, monospace;">[A-C][n-p][a-c]
This would be the solution. It's an easy problem!
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5872623838295077986.post-79206476221636590132015-06-09T01:38:00.001-07:002015-06-09T03:14:50.032-07:00Regular Expressions: Excluding specific characters<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Using regular expressions, match the words <b>hog</b> and <b>dog</b> with but not <b>bog</b>.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyvSDNmKw9vjekCqdTzQjo8TujMJ0Bw3dqwtk2MkkrJhK-ohZfNtoX7d-DZHwOflY2Lbqi-C6zZ9QMRQy2vq3L1cSC6TpptnWnDb1-BxwG9T4SSGJ2RBT7TpuWY3YoVy20sFV_N4zZmLSX/s1600/Screen+Shot+2015-06-09+at+11.36.29+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="92" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyvSDNmKw9vjekCqdTzQjo8TujMJ0Bw3dqwtk2MkkrJhK-ohZfNtoX7d-DZHwOflY2Lbqi-C6zZ9QMRQy2vq3L1cSC6TpptnWnDb1-BxwG9T4SSGJ2RBT7TpuWY3YoVy20sFV_N4zZmLSX/s640/Screen+Shot+2015-06-09+at+11.36.29+AM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">The simplest solution to match any line that ends in 'og' but is not 'bog' would be the expression '[^b]og'. Alternatively, you could use what we learned from the previous lesson and use '[hd]og' to match 'hog' and 'dog' but not 'bog'. Note that is is slightly more restrictive expression because it limits the strings it can match.
</span></pre>
<span style="font-family: Courier New, Courier, monospace;">
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5872623838295077986.post-33646119520319958002015-06-09T01:33:00.001-07:002015-07-21T04:16:29.536-07:00Regular Expressions: Matching specific characters<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Create a regular expression that matches the following words "can" , "man" , "fan" ; those words shouldn't be followed "dan" , "ran" , "pan".<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif51DlJ2rXbGc7YZOYtnERjLPsRXkGN5h4tgKBmL58qZjWEv3z2R2XjO9oSmAdt6AA32lgIuccINcweiBD166QJitOq7uZtvt47ppHPIfATIAq-dkTADaRU4sCHC-VP2FVFz11deB4cycA/s1600/Screen+Shot+2015-06-09+at+11.26.46+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="168" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif51DlJ2rXbGc7YZOYtnERjLPsRXkGN5h4tgKBmL58qZjWEv3z2R2XjO9oSmAdt6AA32lgIuccINcweiBD166QJitOq7uZtvt47ppHPIfATIAq-dkTADaRU4sCHC-VP2FVFz11deB4cycA/s640/Screen+Shot+2015-06-09+at+11.26.46+AM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">Now this could be solved in many ways; the easiest and laziest way to solve this regular expression would be simply using this:
</span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;"><b>can|man|fan</b></span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;"><b>
</b></span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">Now, this sounds too mediocre; at least for me! I would prefer to solve it like this:</span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;"><b>[cmf]an</b></span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;"><b>
</b></span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">As you see, regular expressions analyzes stuff character-by-character. So first you tell the regular expression to only match either 'c', 'm' or 'f' as a first character. Then add 'an' to the rest; which works.</span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">
</span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">Alternatively, you could use:</span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;"><b>[^drp]an</b></span></pre>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<span style="font-family: Courier New, Courier, monospace;">
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5872623838295077986.post-84764430170743610572015-06-09T01:20:00.005-07:002015-07-21T04:16:34.065-07:00Regular Expressions: Matching Dots only<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Match only dots in the following expressions in the output. Any character matched other than dot is illegal and won't make your regular expressions correct.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiti_GAKMaMkA9W0gWsoI8TFcOaqCI2dfCTkXxS9TVUtO1GT0JGxnZMKUlvHx7bWKaJuyF4xHCiO0qWSNrP1TRE5hukoEb7yUUH45dPWoF0iJhCwEFDdyb9jikAApnrs5UTHlmGgVWKsBB4/s1600/Screen+Shot+2015-06-09+at+11.17.41+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="118" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiti_GAKMaMkA9W0gWsoI8TFcOaqCI2dfCTkXxS9TVUtO1GT0JGxnZMKUlvHx7bWKaJuyF4xHCiO0qWSNrP1TRE5hukoEb7yUUH45dPWoF0iJhCwEFDdyb9jikAApnrs5UTHlmGgVWKsBB4/s640/Screen+Shot+2015-06-09+at+11.17.41+AM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<br />
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">\.
</span></pre>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">Side comments: Yes, simply. This is the solution. There is the concept of a <b>wildcard</b>, which is represented by the <b>.</b> (dot) metacharacter, and can <b>match any single character</b> (letter, digit, whitespace, everything). You may notice that this actually overrides the matching of the period, so in order to specifically match a period, you need to escape the dot by using a slash <b>\.</b> accordingly.</span></pre>
<span style="font-family: Courier New, Courier, monospace;">
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5872623838295077986.post-7208182271098749962015-06-09T01:05:00.000-07:002015-07-21T04:16:39.236-07:00Regular Expressions: Matching three simple words<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Create a regular expression that matches three words: <b>abcdefg</b> - <b>abcde</b> - <b>abc</b>.<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJcxJtHSI1Ash_fuu2iuFkoLfKtLoyZ8OnEyga49Jc4mD-uPFoRV8hegcBk9oIJgDERvVUyokhXrKWmYm_evEl0MVEpSa6TsON6MzXzrdwXDC3dJ9rNVcvtQX2kbx-C7jRY_zEsDQcXAEX/s1600/Screen+Shot+2015-06-09+at+11.03.19+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="92" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJcxJtHSI1Ash_fuu2iuFkoLfKtLoyZ8OnEyga49Jc4mD-uPFoRV8hegcBk9oIJgDERvVUyokhXrKWmYm_evEl0MVEpSa6TsON6MzXzrdwXDC3dJ9rNVcvtQX2kbx-C7jRY_zEsDQcXAEX/s640/Screen+Shot+2015-06-09+at+11.03.19+AM.png" width="640" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
</span><br />
<h2 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">
<span style="font-size: x-large;"><b>Solution:</b></span></span></h2>
<span style="font-family: Courier New, Courier, monospace;">
</span>
<pre class="brush:pl;"><span style="font-family: Courier New, Courier, monospace;">(abcdefg|abcde|abc)
</span></pre>
<span style="font-family: Courier New, Courier, monospace;">
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5872623838295077986.post-50199996319076828652015-06-04T23:23:00.000-07:002015-07-21T04:16:44.020-07:00How to make "Hello World" program in perl<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-size: x-large;">Problem:</span></h2>
<div>
Create a program in Perl where you print "Hello, world."<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Output:</b></span></h2>
<div>
<span style="font-family: Courier New, Courier, monospace;">Hello, world. <br />
<br />
</span><br />
<center>
<span style="font-family: Courier New, Courier, monospace;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></span></center>
<span style="font-family: Courier New, Courier, monospace;">
<br />
<br />
<h2 style="text-align: left;">
<span style="font-size: x-large;"><b>Solution:</b></span></h2>
<pre class="brush:pl;">#!/usr/bin/perl
use warnings;
print "Hello, world.\n";
</pre>
</span></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5872623838295077986.post-78982038976989891402014-12-01T23:58:00.000-08:002014-12-01T23:58:52.539-08:00Simple examples of memory leaks in java<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn5ypBVotF3NARSK9QoMqstCSDEW9xJK284iti_yTaONoEAo1KxwPV3wuP75Y3XFDQedjrStU4QKGmfGUAJ0pS_9DN6mAyl2M1ZvfMHzIQBNwSEpIUkotGbYMXlam_vmlvw2gIXupl1njl/s1600/where-is-memory-leak-650x400.jpeg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn5ypBVotF3NARSK9QoMqstCSDEW9xJK284iti_yTaONoEAo1KxwPV3wuP75Y3XFDQedjrStU4QKGmfGUAJ0pS_9DN6mAyl2M1ZvfMHzIQBNwSEpIUkotGbYMXlam_vmlvw2gIXupl1njl/s320/where-is-memory-leak-650x400.jpeg" /></a></div>
Giving examples of memory leaks in Java is one the most frequent questions in job interviews. Below is a huge list of simple memory leaks examples, some are collected from my previous class notes, some are collected from the internet. <br />
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
<b>Example 1: Unclosed connections</b></div>
<pre class="brush:java;">
try {
Connection connection = ConnectionFactory.getConnection();
//Code your stuff
} catch (Exception e) {
//Print the exception
}</pre>
<b>Example 2: Unclosed streams</b>
<br />
<pre class="brush:java;">
try {
//Have an input file "inputFile"
Filereader filereader = new FileReader(inputFile);
BufferedReader bufferedreader = new BufferedReader(filereader);
//Code you stuff
} catch (Exception e) {
//Print the exception
}</pre>
<b>Example 3: Unreachable code from JVM garbage collector </b>
<br />
<pre class="brush:java;"> This doesn't need any code to explain, any memory created through native methods could work. </pre>
<b>Example 4: The implementation of ArrayList.remove()</b>
<br />
<pre class="brush:java;"> public E remove(int index) {
RangeCheck(index);
modCount++;
E oldValue = (E) elementData[index];
int numMoved = size - index - 1;
if (numMoved > 0)
System.arraycopy(elementData, index + 1, elementData, index,
numMoved);
elementData[--size] = null;
return oldValue;
}</pre>
<b>Example 5: A cool example from <a href="http://wiki.eclipse.org/Performance_Bloopers#String.substring.28.29">Eclipse</a>. </b>
<br />
<pre class="brush:java;" >public class StringLeaker
{
private final String muchSmallerString;
public StringLeaker()
{
// Imagine the whole Declaration of Independence here
String veryLongString = "We hold these truths to be self-evident...";
// The substring here maintains a reference to the internal char[]
// representation of the original string.
this.muchSmallerString = veryLongString.substring(0, 1);
}
}</pre >
<b>Example 6: Using the java method <b>intern()</b> on a large java String </b>
<br />
<pre class="brush:java;" >String str="A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string. A very large string."
//Calling intern
str.intern();
</pre>
<b>Example 7: Using a final static to hold an object reference! </b>
<br />
<pre>class JavaProblemsClass {
static final ArrayList arrayList = new ArrayList (959);
}
</pre>
<b>Example 8: Using a HashSet with an incorrect hashCode() or equals() [<a href="http://stackoverflow.com/a/6470695">src</a>]
</b>
<br />
<pre class="brush:java;">class BadKey {
// no hashCode or equals();
public final String key;
public BadKey(String key) { this.key = key; }
}
Map map = System.getProperties();
map.put(new BadKey("key"), "value"); // Memory leak even if your threads die.
</pre>
</div>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-5872623838295077986.post-78619738182134345462014-05-15T04:03:00.000-07:002014-05-15T04:20:07.443-07:00I've been cheated: Xperia Z1 is not water resistant<div dir="ltr" style="text-align: left;" trbidi="on">
You may have seen, heard, bought, or thinking of buying of the new, stylish, Xperia Z1 water-resistant phone with the slogan of "All the power and smartness of Sony in a premium smartphone". Don't invest your money on this mobile.<br />
<br />
Let's start with the hypocrite <a href="http://www.sonymobile.com/global-en/legal/testresults/durability/">description</a>:<br />
<div style="background-color: white; border: 0px; color: #444444; font-family: 'Helvetica neue', Helvetica, Arial, Tahoma, Verdana, sans-serif; font-size: 14px; line-height: 20px; margin-bottom: 22px; margin-top: 10px; padding: 0px 15px; vertical-align: baseline;">
The same quality and performance as our compact digital cameras. The same screen technology as our high-end BRAVIA® TVs. Crafted into an elegant and waterproof* smartphone. With Xperia Z1, you truly get to discover the best of Sony for the best of you.</div>
Apparently, their dishonest marketing policy promoting a water-resistant mobile has some rules, they start with adding (*), as known as conditions apply. Note the small font, and blurry color (they don't want to attract your attention). Let's go through their dishonest <a href="http://www.sonymobile.com/global-en/legal/testresults/durability/">terms</a>:<br />
<h3>
<span style="color: red;">#DISHONEST TERMS 1#</span></h3>
<span style="background-color: white; color: #444444; font-family: 'Helvetica neue', Helvetica, Arial, Tahoma, Verdana, sans-serif; font-size: 10px; line-height: 16px;">*Covers must be shut. Only in fresh water up to 1.5 m for 30 minutes.</span><br />
<br />Covers must be shut, if you're charging your phone and a cut of water falls accidentally, your phone will get damaged. In addition, pools do not have fresh water, it's full of Chlore (to kill the bacteria).<br />
<br />
<h3>
<span style="color: red;">#DISHONEST TERMS 2#</span></h3>
<h3>
<span style="background-color: white; color: #444444; font-family: 'Helvetica neue', Helvetica, Arial, Tahoma, Verdana, sans-serif; font-size: 10px; font-weight: normal; line-height: 16px;">*Provided that all ports and covers are firmly closed, the phone or tablet is (i) protected against low pressure jets of water from all practicable directions in compliance with IP55; and/or (ii) can be kept under 1 m of freshwater for up to 30 minutes in compliance with IP57; and/or (iii) can be kept under 1.5 m of freshwater for up to 30 minutes in compliance with IP58.</span></h3>
If we look further, more hypocrisy. The use of a small font is necessary to make less users read the condition. They're saying: you shouldn't put your mobile phone underwater unless it has met some conditions you have never heard of (IP55 and IP58 conditions). You need to be an experienced engineer to determine the correct, but weak conditions to put your phone underwater.<br />
<br />
<br />
<h3>
<span style="color: red;">#DISHONEST TERMS 3#</span></h3>
<h3>
<span style="background-color: white; color: #444444; font-family: 'Helvetica neue', Helvetica, Arial, Tahoma, Verdana, sans-serif; font-size: 10px; font-weight: normal; line-height: 16px;">*The phone or tablet is not designed to float or work when submerged underwater outside its classification range and should not be exposed to any liquid chemicals. If liquid detection is triggered on the handset or battery, your warranty will be void.</span></h3>
<br />
Do not make this phone float unless you have determined the classification rage.<br />
<br />
<br />
<br />
Meanwhile the sick twisted video advertisement, but why promote in such dishonest way? The answer is simple: there is too much competition and Sony is desperate.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUwjZK-I4yQYOPEBPRLxFZGVAV73yCzfIacLu5TbepZ2QOL9gk8AJ-OvkOTfwfaRSQLf9Iw7oXIavx4Mi3fU-8Arpf3D40Ka6FPnYbkmtWIy997jP1J2NDdggztftrvJe2jWeeTKxXkfEJ/s1600/hiiii.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUwjZK-I4yQYOPEBPRLxFZGVAV73yCzfIacLu5TbepZ2QOL9gk8AJ-OvkOTfwfaRSQLf9Iw7oXIavx4Mi3fU-8Arpf3D40Ka6FPnYbkmtWIy997jP1J2NDdggztftrvJe2jWeeTKxXkfEJ/s1600/hiiii.png" height="355" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<i>You shouldn't put your phone under water, but in the advertisement, they encourage you to do so. PS: The touch doesn't work underwater, press the button thrice or more to work. </i></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h2 style="text-align: left;">
Gathering evidence:</h2>
<h3 style="text-align: left;">
<span style="color: red;">#EVIDENCE 1#</span></h3>
Personal experience: Touch didn't work underwater at all! I've tested it and it froze after 10 minutes. When I got out of the pool, the phone turned off and I saw water inside the lens. I was just minutes.<br />
<br />
All my data, pictures, videos, messages, passwords, applications got permanently lost with the phone damage. Not only Sony wouldn't pay for the repair, they couldn't repair it neither recover my information.<br />
<br />
So as testing the phone personally, my Xperia was not resistant! The weak cover of Z1 is almost water-resistant but the phone isn't, actually there isn't any true water resistant phone, it's all a cheating marketing policy. You can barely take pictures underwater (pressing the button 10 times to shoot one blurry picture), you shouldn't put more than 30 minutes or more than 1.5 meters (although mined got water penetrated after 10 minutes) and I got no warranty what-so-ever.<br />
<br />
So, a phone you can't use in water is not practically water-resistant.<br />
<br />
<br />
<h3>
<span style="color: red;">#EVIDENCE 2#</span></h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://static.thefullsignal.com/sites/knowyourcell/files/styles/insert_main_wide_image/public/xperia_z_flaw.jpg?itok=k-cvexgo" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://static.thefullsignal.com/sites/knowyourcell/files/styles/insert_main_wide_image/public/xperia_z_flaw.jpg?itok=k-cvexgo" height="239" width="320" /></a></div>
After digging, according to the Xperia Blog, the glue that keeps the back panel together can potentially separate under extreme heat. The device can easily reach such high temperatures through prolonged use, as it takes a huge toll on the processor. When this happens, the heat may melt the glue and cause the back panel to slightly separate from the rest of the device’s casing, creating the ideal entryway for water to seep into places it shouldn’t.<br />
<div>
<br /></div>
<br />
Cool, right?<br />
<div>
<br /></div>
<br />
<br />
<br />
<div class="separator" style="-webkit-text-stroke-width: 0px; clear: both; color: black; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0px; orphans: auto; text-align: center; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
</div>
<br />
<h3>
<span style="color: red;">#EVIDENCE 3#</span></h3>
Here is the evidence (a clip of a private video) that shows the phone suddenly becoming water damaged, even though the phone was fine under water.<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="270" src="//www.youtube.com/embed/01-VfQgTlRQ" width="480"></iframe>
<br />
<br />
<br />
<h3>
<span style="color: red;">#EVIDENCE 4#</span></h3>
<i style="font-family: Georgia, 'Times New Roman', serif;">The other night at a friends new years party, my phone was wet a couple of times after it was placed on top of a sticky mess left by a rather drunk friend after she spilt an RTD on the counter. I thought nothing of it, because I was sober enough to make sure I closed all the flaps first. - </i><b>http://talk.sonymobile.com/t5/Xperia-Z1-Z1s/Water-Damage-to-Xperia-Z1-Under-Repair/td-p/532765</b><br />
<div>
<b><br /></b></div>
<br />
<br />
<br />
<i>I tried to switch the phone off to prevent damage, but whenever I tried, it would turn back on, regardless of how i turned it off (3rd party app or power button).</i><br />
<i>Basically, I want peoples input as to whats causing the bizarre issue, and what should I do about getting it fixed because I can't go to sony due to aftermarket service, and I know the other company will blame me. Im stuffed. - </i><b>http://talk.sonymobile.com/t5/Xperia-Z1-Z1s/Water-Damage-to-Xperia-Z1-Under-Repair/td-p/532765</b><br />
<div>
<b><br /></b></div>
<br />
<br />
<i>Indeed... As much as I have been excited with the performance of the phone in the beggining... camera quality... use in the water... As much I am now frustrated and disappointed for mainly two reasons: </i><i>1. Battery performence... Had to charge 3 times a day... this has loosened the little thing that protects the charging entry... which caused the next disaster...</i><br />
<i>2. HEART BRAKING... WATER has damaged my phone after only 4 months of use... and my phone is not usable anymore... NOw... what ads insult to injury... Warranty does not cover water </i><br />
<i>damage... </i><b>http://www.geekzone.co.nz/forums.asp?forumid=97&topicid=138407</b><br />
<div>
<b><br /></b></div>
<br />
<br />
And so on...<br />
<br />
On it's shame. I'm going to move to an iPhone 5. Better battery performance, faster mobile, and honest company.</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5872623838295077986.post-34261981002545697382014-04-07T01:36:00.000-07:002014-04-07T01:36:34.092-07:00Solving "Private loads are not supported for this card" payoneer problem<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
A question I often get is "When can I start using the Private Loading Service?" In order to more easily address this question, I decided to create a blog post.</div>
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
<br /></div>
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
The main use of your Payoneer account is to receive payments using our US Payment Service, or from any of their partners (which are companies/sites that pay with Payoneer). For accounts that are active in receiving payments via those methods, you will have the additional option of receiving private loads.</div>
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
<br /></div>
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
If you are not yet eligible to use the private loading service, you will see an error "<span style="font-weight: 600;">Private loads are not supported for this card</span>." In this case you will need to receive additional payments from either of the sources mentioned above, and then try again. </div>
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
<br /></div>
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
Once you are active in receiving payments from any of our official partners, or the US Payment Service, you will see the Private Loading Service become available to you.</div>
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
<br /></div>
<div style="background-color: white; color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px; padding: 0px;">
Unfortunately, they cannot do this for you and they won't be able to open the feature without sufficient payouts. If the amount of your payment was not high enough to qualify you to use the Private Loading Service. Continue receiving payments, once you reach a high enough activity you will see the service become available.</div>
<div>
<br /></div>
<div style="background-color: white; padding: 0px;">
<b><span style="color: #282828; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px;">So to sum up, you need to make </span><span style="color: red; font-family: Helvetica, helvetica, arial, sans-serif; font-size: 14px; line-height: 22.399999618530273px;">serious</span><span style="color: #282828;"><span style="font-family: Helvetica, helvetica, arial, sans-serif;"><span style="font-size: 14px; line-height: 22.399999618530273px;"> money, not just 100$, and receive it via one of their companies to your payoneer US virtual account. In that way, they'll gain Payoneer's trust you and you'll be able to enable private loads.</span></span></span></b></div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5872623838295077986.post-26936040457706545542014-04-07T01:22:00.001-07:002014-04-07T01:27:49.122-07:00What happened to ijava2.com? <div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<b>iJava2.com</b> creators were a team that loved Java, both the coffee and the programming language. Hence, they featured a website dedicated to the Java programming language. Smart, right?<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFUPBM2EwClTfeG9Fme04ZVofobpD8ntQTXPhjzHHrV2LISDvKk12a3xTYiIIr4Bfv3RxUbIS7YmgbPbCXoDl_o-blQI9Fdpz-M4YB_itfb_QwzY5NdfP2-_VBWcA8LLNd-3eULBkkwA4C/s3200/Screen+Shot+2014-04-07+at+11.13.41+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="jiava2.com" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFUPBM2EwClTfeG9Fme04ZVofobpD8ntQTXPhjzHHrV2LISDvKk12a3xTYiIIr4Bfv3RxUbIS7YmgbPbCXoDl_o-blQI9Fdpz-M4YB_itfb_QwzY5NdfP2-_VBWcA8LLNd-3eULBkkwA4C/s3200/Screen+Shot+2014-04-07+at+11.13.41+AM.png" height="337" title="ijava2.com hompage" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 13px;"><br /></td></tr>
</tbody></table>
Their website moto was "<span style="color: #666666; font-family: Georgia, 'Bitstream Charter', serif; font-size: 12px; font-style: italic; line-height: 18px;">Love Java–coffee and Java programming.".</span><br />
<span style="color: #666666; font-family: Georgia, 'Bitstream Charter', serif; font-size: 12px; font-style: italic; line-height: 18px;"><br /></span>
<b>iJava2.com</b> was one of the best java programming websites that existed on the web. You could find all solutions related to Java and Java programming at <b>iJava2.com, </b><b> iJava2.com</b> was a cutting-edge Java blog updated daily both in content and coding to reflect the latest trends in Java, and related industries.<br />
<br />
Not mention that <b>iJava2.com</b> existed since January 2000. For almost 14 years!<br />
<br />
<b>iJava2.com </b>featured content-rich posts, solved Java problems, and awesome tutorials that will surely be of benefit to the Java programmer from novice to intermediate, and even expert-level Java programmers.<br />
<br />
<div style="text-align: center;">
Today, <b>iJava2.com</b> isn't accessible. </div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdLmznQS5X6n1F5BXR9E1Ut-fXlvbIec39BGvo_aOk7W5aOltFvK3EnMhdqd-MksazFajYr1FHG_Si1iH7YIONyMLwlHeGhsqxAnwfwdY-sI3g41ob7-wDCFF6TqKujDrWf35yVjy4GYnA/s3200/Screen+Shot+2014-04-07+at+10.48.51+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdLmznQS5X6n1F5BXR9E1Ut-fXlvbIec39BGvo_aOk7W5aOltFvK3EnMhdqd-MksazFajYr1FHG_Si1iH7YIONyMLwlHeGhsqxAnwfwdY-sI3g41ob7-wDCFF6TqKujDrWf35yVjy4GYnA/s3200/Screen+Shot+2014-04-07+at+10.48.51+AM.png" height="147" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
Occasionally,<b> iJava2.com</b> coded some random stuff using other programming languages, they got down with xhtml, CSS3, C++ or whatever tickles they fancy.<br />
<div>
<br /></div>
<div>
The good thing about iJava2.com that the team behind it was generally responsible for everything that gets posted on this website. Yes! They generally accepted responsibility for what gets posted on their website, which is something that<b> JavaProblems.com</b> doesn't do. Shocking, right?</div>
<div>
<br /></div>
<div>
<b>iJava2.com</b> was hosted on Wordpress - on the contrary of our website which is hosted on Blogger.</div>
<div>
<br /></div>
<b>iJava2.com </b>may have took the website for financial reasons for it didn't contain any advertisements - as you already know, Wordpress charges > 100$ for domain and bandwidth costs, not forgetting their annoying message "<a href="http://www.wordpress.org/" style="background-color: white; background-image: url(http://web.archive.org/web/20130426141125/http://www.ijava2.com/wp-content/themes/twentyten/images/wordpress.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; border: 0px; color: #666666; display: inline-block; font-family: Georgia, 'Bitstream Charter', serif; font-size: 12px; font-style: italic; line-height: 16px; margin: 0px; padding: 0px 0px 0px 20px; text-decoration: none; vertical-align: baseline;" title="Semantic Personal Publishing Platform">Proudly powered by WordPress.</a>"<br />
<br />
<b>iJava2.com</b> has obviously lost its index on Google webmasters. It's really sad to have such original site gone.<br />
<div>
<br /></div>
R.I.P <b>iJava2.com</b><br />
<b><br /></b>
<b><br /></b></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5872623838295077986.post-69917917080876256502014-03-23T06:35:00.001-07:002014-03-23T06:35:43.431-07:00Grouping Symbol Matching in java<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><h2 style="text-align: left;"><span style="font-size: x-large;">Problem:</span></h2><div>Create a Grouping Symbol Matching app in java.<br /><br /><h2 style="text-align: left;"><span style="font-size: x-large;"><b>Output:</b></span></h2><div><span style="font-family: Courier New, Courier, monospace;">Enter arithmetic expression: <br />(6+5) + {3 - 4} * <br />Stack is full<br />Expression is valid<br /></span></div><br /><center><script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></center><br /><br /><h2 style="text-align: left;"><span style="font-size: x-large;"><b>Solution:</b></span></h2><pre class="brush:java;">//ArrayBasedStack.java<br />import java.util.Arrays;<br /><br />public class ArrayBasedStack implements Stack{<br /><br /> private Object[] arr;<br /> private int top;<br /><br /> public ArrayBasedStack(int capacity) {<br /> arr = new Object[capacity];<br /> top = -1;<br /> Arrays.fill(arr, null);<br /> }<br /><br /> @Override<br /> public int size() {<br /> return top+1;<br /> }<br /><br /> @Override<br /> public boolean isEmpty() {<br /> return top==-1;<br /> }<br /><br /> @Override<br /> public void push(Object element) throws StackException {<br /> if(size() == arr.length)<br /> throw new StackException("Stack is full");<br /> ++top;<br /> arr[top] = element;<br /> }<br /><br /> @Override<br /> public Object pop() throws StackException {<br /> if(isEmpty())<br /> throw new StackException("Stack is Empty");<br /> Object toReturn = arr[top];<br /> arr[top] = null;<br /> top--;<br /> return toReturn;<br /> }<br /><br /> @Override<br /> public Object top() throws StackException {<br /> if(isEmpty())<br /> throw new StackException("Stack is Empty");<br /> return arr[top];<br /> }<br />}<br />//GroupingSymbol.java<br />import java.util.Scanner;<br /><br />public class GroupingSymbol {<br /><br /> private static String opening = "([{";<br /> private static String closing = ")]}";<br /><br /> public static void main(String[] args) {<br /> String expression;<br /> Scanner scan = new Scanner(System.in);<br /><br /> System.out.println("Enter arithmetic expression: ");<br /> expression = scan.nextLine();<br /><br /> boolean valid = validate(expression);<br /><br /> if(valid) System.out.println("Expression is valid");<br /> else System.out.println("Expression is valid");<br /> }<br /><br /> private static boolean validate(String expression) {<br /> int index = 0;<br /> boolean valid = true;<br /> char current, top;<br /> ArrayBasedStack temp = new ArrayBasedStack(expression.length());<br /><br /> while(valid && index < expression.length()) {<br /> current = expression.charAt(index);<br /> if (opening.indexOf(current) != -1) {<br /> try {<br /> temp.push(current);<br /> } catch (StackException e) {<br /> System.out.println(e.getMessage());<br /> return false;<br /> }<br /> } else if(closing.indexOf(current) != -1) {<br /> try {<br /> top = (Character) temp.pop();<br /> } catch (StackException e) {<br /> System.out.println(e.getMessage());<br /> return false;<br /> }<br /> <br /> if(opening.indexOf(top) != closing.indexOf(current)) <br /> valid = false;<br /> <br /> <br /> }<br /> <br /> }<br /> <br /> if (!temp.isEmpty()) valid = false;<br /><br /><br /><br /><br /><br /> return valid;<br /> }<br />}<br />//Stack.java<br />package com.ikallassi.groupingsymbolmatching;<br /><br />public interface Stack {<br /><br /> public int size();<br /> public boolean isEmpty();<br /> public void push(Object elemnt) throws StackException;<br /> public Object pop() throws StackException;<br /> public Object top() throws StackException;<br /><br /><br /><br />}<br />//StackException.java<br />package com.ikallassi.groupingsymbolmatching;<br /><br />public class StackException extends Exception {<br /><br /> private static final long serialVersionUID = -5592227328424820584L;<br /><br /> public StackException(String msg) {<br /> super(msg);<br /> }<br />}<br /></pre></div></div></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5872623838295077986.post-69064872140897767762014-03-23T05:54:00.001-07:002014-03-23T05:54:33.393-07:00Create a bouncing face in java<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><h2 style="text-align: left;"><span style="font-size: x-large;">Problem:</span></h2><div>Create a bouncing face.<br /><br /><h2 style="text-align: left;"><span style="font-size: x-large;"><b>Output:</b></span></h2><div><span style="font-family: Courier New, Courier, monospace;"></span></div><br /> <br /> <center><img alt="Prompt Picture Description"src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw7k-JGli817AbDTdk8aUo2KHKmhSqQTExfwve0E6dIPmgaMq9hr7HzOLq9sE0ztv7tpLjC9z3U7VxXTLHT2T7VAMlnuocZrFnzEz-XXxVP_JlMCrOFVuM4j34Q-SRlIjzXnXGwxy-CdTT/"></div></center><br /><br /><center><script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Big Middle Rectangle Ad --><ins class="adsbygoogle" data-ad-client="ca-pub-6821598292691760" data-ad-slot="5354028732" style="display: inline-block; height: 280px; width: 336px;"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></center><br /><br /><h2 style="text-align: left;"><span style="font-size: x-large;"><b>Solution:</b></span></h2><pre class="brush:java;">//****************BouncingFaceFrame.java******************/<br />import javax.swing.JFrame;<br /><br />public class BouncingFaceFrame {<br /><br /> <br /> public static void main(String[] args) {<br /> <br /> JFrame frame = new JFrame("Happy Face");<br /><br /> frame.getContentPane().add(new BouncingFacePanel());<br /> frame.pack();<br /> frame.setVisible(true);<br /> <br /> }<br /><br />}<br />//****************BouncingFacePanel.java******************.<br />import java.awt.Color;<br />import java.awt.Dimension;<br />import java.awt.Graphics;<br />import java.awt.event.ActionEvent;<br />import java.awt.event.ActionListener;<br /><br />import javax.swing.ImageIcon;<br />import javax.swing.JPanel;<br />import javax.swing.Timer;<br /><br />public class BouncingFacePanel extends JPanel{<br /><br /> <br /> private final int WIDTH = 300, HEIGHT = 300;<br /> private final int DELAY = 20, IMAGE_SIZE = 35;<br /> <br /> private ImageIcon icon;<br /> private int x, y, moveX, moveY;<br /> private Timer timer;<br /> <br /> public BouncingFacePanel() {<br /> timer = new Timer(DELAY, new ReboundListener());<br /> <br /> icon = new ImageIcon("images.jpg");<br /> <br /> x = 5; y=40;<br /> moveX = moveY = 3;<br /> <br /> setBackground(Color.WHITE);<br /> setPreferredSize(new Dimension(WIDTH, HEIGHT));<br /> timer.start();<br /> timer.addActionListener(new ReboundListener());<br /> <br /> }<br /> <br /> @Override<br /> protected void paintComponent(Graphics g) {<br /> super.paintComponent(g);<br /> icon.paintIcon(this, g, x, y);<br /> }<br /> <br /> private class ReboundListener implements ActionListener {<br /><br /> @Override<br /> public void actionPerformed(ActionEvent arg0) {<br /> <br /> x += moveX;<br /> y += moveY;<br /> <br /> if ( x <= 0 || x >= (WIDTH-IMAGE_SIZE)) moveX *= -1;<br /> if ( y <= 0 || y >= (WIDTH-IMAGE_SIZE)) moveY *= -1; <br /> <br /> repaint();<br /> }<br /> <br /> }<br />}<br /></pre></div></div></div>Unknownnoreply@blogger.com1