# Just for fun...contest problem

I attended a programming contest and one of the problems stumped me a bit. I just wanted to share it with you so if you had some free time, you could play with it. It has to do with the longest increasing substring of numbers. If you were given a sequence of numbers like "1 3 11 6 2 8 10 9 12 5 7 0" where 0 symbolized the end of input, your program would have to find the longest path of increasing numbers. The answer to this one should be 6, "1 3 6 8 10 12". The tough part on this one for me was that my program just chose the first available path, "1 3 11 12", so reported 4.
Because I was under a time constraint, and I saw that this would take a while, I skipped over it. How would you experienced programmers go at solving this with a time constraint of < 30 minutes?
I feel I need to stress again that this contest is over, and my question reflects pure curiosity. :)

I still can't see the entire effect of a recursive
function at first. I have learned to recognize which
problems lend themselves to be recursive solutions. I
just start by laying the code and testing it. It takes
a while to figure out what to change so that a
recursive function will act like I want it too. If
you do it enough times, it gets easier.Since this is in regard to the thread I posted...I'll bump it and give you some advice too. Since your recursive solution seems to be a bit simpler than mine was, although I don't yet know how it'll perform against the one I have.
Anyway, recursion is basically a couple things:
1. Base case, Test if you've solved the problem appropriately. When you've solved or completed your problem, you stop. If there could be more than one answer and you are looking for the best one, you should check your current answer that you're looking at against your best. If it is better, then store the better one and return. The returning part is essential as it stops the path from continuing since it has succeeded.
2. Do some work to get closer to a solution. (In this case, remove a number). The work you do should not hinder your solution, but it should better it. If there is more than one choice, this will be your branch part. Choose a branch, add what you chose to your solution, and recur.
3. Repeat 2 choosing the next branch.
And that's really about it. All you have to remember to do is insure that you keep a constant view of the problem as it entered your function between branch choices. Otherwise you can really mess stuff up. Anyway, this is how I tackle recursion, and it always works for me.
Just sometimes (as in the problem in this thread and the one I just posted without realizing this one existed) my recursive solution was too slow to be practical all the time and I went on a week long hunt to find an iterative solution (which I'm almost convinced doesn't exist at this point).

### Similar Messages

• Hey Guys, from Germany. I want to connect my iMac 21" with my Tv just for fun. Does anyone know, how it works. With a Hdmi adapter?

Hey guys! I want to connect my Imac 21 " with my Tv just for fun. Does anyone know , how it works?

Selecting the correct adapter and cable depends on which year model iMac you have and what inputs the TV has?
Check the User's Guide that came with your iMac or your Spec's at > Apple - Support - Technical Specifications
to see if your iMac has a Mini-DVI or Mini DisplayPort and then select that adapter with the correct connection for the TV.
Example: if you have a 2010 or 2011 iMac and an HDMI ready TV, then you would want the > Moshi Mini DP to HDMI Adapter with Audio Support - Apple Store (U.S.)

• Yesterday I ran Disk Utility and came up with hundreds of permissions that needed repair.  I hit the "repair permissions" button and waited until it said they were repaired, but just for fun I hit the v

Yesterday I ran Disk Utility and came up with hundreds of permissions that needed repair.  I hit the "repair permissions" button and waited until it said they were repaired, but just for fun I hit the "verify permissions" button again, and they all came back!  I did this several more times and every time I would hit "verify permissions" I would get the same list.  What's up?  I've always suspected diagnostic programs, but this is Apple's own!

Ignore them. They aren't errors. You will keep seeing the same ones. As long as you get the message "Permissions repair complete," you're OK.
http://support.apple.com/kb/TS1448?viewlocale=en_US

• Generate DDL for objects (just for fun)

I'm been putting together queries that generate DDL. Considering exp/imp ROWS=0 can be used, or DBMS_METADATA there is little point. Though, with restricted access those may not be possible options, but then an external tool like TOAD could do it. Therefore, my justification for this is "just for fun".
Here is one for TABLEs. It does not generate the CONSTRAINTs (which i try to get in the next query), and no storage clauses. This query is also formatted for fixed width font with tabs equivalent to eight characters:
SELECT
SUBSTR
REPLACE
CASE
WHEN Columns.Column_Id = 1 THEN
'CREATE TABLE ' || Columns.Table_Name
|| CHR(10) || '('
|| CHR(10)
END
|| ' ' || Columns.Column_Name
|| RPAD(CHR(09), Tabs - FLOOR((LENGTH(Column_Name) +1) / 8), CHR(09))
|| Data_Type
|| CASE
WHEN Data_Type IN ('CHAR', 'VARCHAR2') THEN '(' || Char_Length || ')'
WHEN Data_Type = 'FLOAT' THEN '(' || Data_Precision ||')'
WHEN Data_Type = 'NUMBER' THEN
CASE WHEN Data_Precision IS NOT NULL THEN '(' || Data_Precision
|| CASE WHEN Data_Scale IS NOT NULL THEN ', ' || Data_Scale END
||')'
END
END
|| CASE
WHEN Data_Default IS NOT NULL
THEN
CHR(09),
CASE Data_Type
WHEN 'CHAR' THEN CASE Char_Length WHEN 1 THEN 2 ELSE 1 END
WHEN 'DATE' THEN 2
ELSE 1
END,
CHR(09)
|| 'DEFAULT '
|| (
SELECT
ExtractValue
DBMS_XMLGEN.GetXMLType
SELECT
Data_Default
FROM
All_Tab_Columns
WHERE
Owner          = ''' || Columns.Owner || '''
AND     Table_Name     = ''' || Columns.Table_Name || '''
AND     Column_Name     = ''' || Columns.Column_Name ||'''
'ROWSET/ROW/DATA_DEFAULT'
FROM
Dual
END
|| CASE
WHEN Columns.Column_Id = Info.Total_Columns
THEN CHR(10) || ');' || CHR(10) || CHR(10)
ELSE ','
END,
',' || CHR(10) || CHR(10),
',' || CHR(10)
1,
181
) Statement
FROM
All_Tab_Columns     Columns,
SELECT
Owner,
Table_Name,
MAX(Column_Id)                         Total_Columns,
MAX(FLOOR((LENGTH(Column_Name) + 1) / 8)) + 1     Tabs
FROM
All_Tab_Columns
WHERE
Owner          = 'SYS'
GROUP BY
Owner,
Table_Name
)          Info
WHERE
Columns.Owner          = Info.Owner
AND     Columns.Table_Name     = Info.Table_Name
ORDER BY
Columns.Owner,
Columns.Table_Name,
Columns.Column_Id;This next query get CONSTRAINTs. No formatting is used, because it becomes quite unweildy (though, if it used multiple lines, that would change). Another interesting thing is whether the CONSTRAINT names were generated or not. If they were generated, this still uses the old name and does not generate a new one:
WITH
Cons_Columns
AS
SELECT
Owner,
Constraint_Name,
SUBSTR
REPLACE
REPLACE
XMLAgg(XMLElement("A", Column_Name)
'<A>',
'</A>'
4
) || '"' List
FROM
SELECT
Owner,
Constraint_Name,
Column_Name
FROM
All_Cons_Columns
ORDER BY
Position
GROUP BY
Owner,
Constraint_Name
SELECT
'ALTER TABLE ' || Table_Name
|| ' ADD CONSTRAINT ' || Constraint_Name
|| ' '
|| CASE Constraint_Type
WHEN 'C' THEN 'CHECK'
WHEN 'U' THEN 'UNIQUE'
WHEN 'P' THEN 'PRIMARY KEY'
WHEN 'R' THEN 'FOREIGN KEY'
END
|| '('
|| CASE
WHEN Constraint_Type = 'C' THEN
SELECT
ExtractValue
DBMS_XMLGEN.GetXMLType
SELECT
Search_Condition
FROM
All_Constraints
WHERE
Owner          = ''' || Cons.Owner || '''
AND     Constraint_Name     = ''' || Cons.Constraint_Name || '''
'ROWSET/ROW/SEARCH_CONDITION'
FROM
Dual
WHEN Constraint_Type IN ('P', 'R', 'U') THEN
SELECT
List
FROM
Cons_Columns
WHERE
Cons_Columns.Owner          = Cons.Owner
AND     Cons_Columns.Constraint_Name     = Cons.Constraint_Name
END
|| ')'
|| CASE Constraint_Type
WHEN 'R' THEN
SELECT
' REFERENCES (' || List || ')'
FROM
Cons_Columns
WHERE
Cons_Columns.Owner          = Cons.R_Owner
AND     Cons_Columns.Constraint_Name     = Cons.R_Constraint_Name
|| ' ON DELETE ' || Delete_Rule
ELSE ''
END
|| ' ' || DEFERRABLE || ' ' || DEFERRED
|| ' ' || VALIDATED || ' ' || STATUS || RTRIM(' ' || RELY)
|| ';'
FROM
All_Constraints Cons
WHERE
Owner = 'SYS'
ORDER BY
1,
Constraint_Name;

Shoblock, thanx!
For NUMBER is was using a wrong COLUMN, and also in the wrong order. Serves me right for not following the documentation. And, i just ignored FLOAT. But not it mostly matches DESC (except this query shows the ", 0" where DESC drop it instead).
I fixed the query above.
The XML part that gets the long has a failure. If the Data_Default contains an XML special char it will get encoded. The way to not encode it, it looks, requires PL/SQL. Which means it would not be done in one query (without a FUNCTION).
I am curious if anyone else is interested in such queries, whether for "fun" or otherwise.

• TS1702 how can I get anyone to give us answer on the iphone apps casino game we purchased few days ago which once the token was finished we were not able to reset and play just for fun and not for gambling. we need help and not to be charged additional

few days ago I have purchased Iphone casino games from itunes apps store. One of the game was made by the company called "ARISTOCRAT" dragan game. Usually we will get basic tokens to play the game, and if we ran out of the tokens all we need to do is going into "manu" and "setting" selete "dream" and reset that we should be able to continue play the game with same amount of the basic tokens. The one game would not let us to go back to the game. There were msg came out said" game center requires an active connection to the internet"? I didn't feel comfortable because we purchased the game for \$1.99 to play for fun and not to gamble. We do have credit card on your file. We don't want to be charged alot of money for something not in our well. I need help to answer the question on the following:
1.  Are we able to ever play this game again without going to internet? We don't even know which site to go to, because when we press the ok button nothing else came out to direct us to any area.
2. We only purchased the few days ago order ID: MGT74GN6V7 on 10/03/12. all the other games we purchased we were able to continue to play by doing the same setting.
Thank you for your help and looking forward to hear from you!

You need to contact itunes support
We are all itunes users just like you.
http://www.apple.com/support/contact/

• Counting Icons Just For Fun

Just for gee whizzes, how can I tell how many icons are in a
lesson? Is there a an already established function or variable
within AW 7.02? I know that a library gives you the count of how
many items are in the ''.a7l'' but was wondering if there was
something similar for an ''.a7p''.
TIA,
Jerry

Jerry,
- Select the root timeline
- Select Modify > File > Properties from the menu
Regards,
Andrew

• Do people at HP actually read our posts nd try to solve problems or, re we posting just for fun?

Why is there a community board if no one no one answers questions?

Hi:
First of all I would like to invite your attention to the forum rules of participation at the link below....
http://h30434.www3.hp.com/t5/Rules-of-Participation/Rules-of-Participation/m-p/252325/highlight/true​...
Now that you have read the rules of participation, you can see that this is not HP technical support.
We on this forum are all volunteers who try to help folks resolve issues with their HP products.
I do not work for HP,  I do not represent HP, and I am not a shareholder in the company.
Unfortunately, there will be several questions that go unanswered on this forum, because no one probably knows what the answer is, or even has any suggestions to offer.
Thousands of questions get anwered here with many solutions, so a general statement that 'no one answers questions,' is inaccurate to say the least.

• Just for fun:  Can you guess how I did this?

A few months ago a thread here discussed different way to stroke 3D objects in After Effects.  There were lots of clever suggestions.
I made a TV spot last week that uses growing 3D ribbons to spell out the 2012 in the product title.  There are straight planes and curves within the ribbon paths, and lighting and shadows were required to match the original album art it replicates.  I needed to get the job done quickly and didn't have time to use a 3D application, so I used (what I think) was a rather innovative approach.
So, for a bit of fun, can you pick how I did this?  The project is created entirely in AE, in one composition.
Apologies for the heavy compression in the video.

Thanks Todd!
My first attempt was exactly Rick's, using stacked solids with Stroke applied.  I gave up on it because, once shadows were applied, the "ribbons" seemed to develop a mottled texture, presumeably because each layer in the stack casts a shadow on the layer behind it.  Using Rick's design above, here's an example:
So in the end, I used text layers!  Each ribbon is simply a long string of Helvetica "I" characters, with their kerning pulled back so all the characters touch.  Convert to per-character 3D, rotate X axis 90 degrees, and apply mask as text path.  Then I use a simple Text Animator on opacity to draw the lines on or off.
The great advantage of this is no cumbersome stack of layers.  Each colour is one layer, so there's just five layers in my comp for each object. The "20" is one object, then the "1", then the "2" - 15 layers in all for the whole thing.  Changing colours is as easy as changing a single text layer.
A total render hog, all the same:  it took 11 hours to render the 15 second spot, on an 8 core Mac Pro with 16GB of RAM.  But in 3D Draft mode the comp was surprisingly easy to work with.  It's just the lighting and shadows that slow things down.
Anyways, perhaps this may inspire someone else to do something interesting with text layers.

• ITS NOT A BIZZZZZNESS PHONE... JUST FOR FUN

IM USING  PHONE FROM LAST 1 MONTH, I PURCHASED D FOR MY BIZZZNESS BUT ITS NOT FOR USEFULL...
BLACKBERRY CANT OPEN HEAVY SITES LIKE IRCTC.............. N SO ONNN
SO GUYZZ IF UR GOING TO BUY DIS PHN SO JUST REMEMBER DAT ITS USELESS FOR BIZZZZNESS
BEWARE OF IT

RAJAN_653 wrote :
IM USING  PHONE FROM LAST 1 MONTH, I PURCHASED D FOR MY BIZZZNESS BUT ITS NOT FOR USEFULL...
BLACKBERRY CANT OPEN HEAVY SITES LIKE IRCTC.............. N SO ONNN
SO GUYZZ IF UR GOING TO BUY DIS PHN SO JUST REMEMBER DAT ITS USELESS FOR BIZZZZNESS
BEWARE OF IT
Hellorajan_653,
It means you are unable to visit IRCTC but to visit sites like IRCTC which is one of the busiest site you need a good connection and speed and for that it is your Carrier Airtel which is responsible,So call your carrier and ask then . Unable to visit an website does not determine that what this Smartphone is capable of.
By the way what is this device " 2012 " I had not heard blackberry making such device model.
Prince
Click " Like " if you want to Thank someone.
If Problem Resolves mark the post(s) as " Solution ", so that other can make use of it.
Click " Like " if you want to Thank someone.
If Problem Resolves mark the post(s) as " Solution ", so that other can make use of it.

• Reg: Just for fun [Off-Topic] -

Hi All,
Has anybody ever seen Mr. Thomas Kyte over here?
Or, Steven Feurstein behind the 'The PL/SQL Challenge'?
Just getting curious to know because I've never seen those biggies over here.
@Mod - Sorry for getting off-topic.
- Ranit

Re: DISTINCT not working with  wmsys.wm_concat

• Just for fun, my new site

I had to do a little blog-like site for my web class.  The code isn't perfect (I only had a couple of days to take this from start to finish) but the results are pretty cool.  You guys always help me with my questions and projects so thought you'd like to see some of my current work.  http://mat.miracosta.edu/MAT235/studentwork/Ng_Gary/
The inspiration for this was an old school notebook I found at my parents house from when I was a kid.  Lots of doodles and stuff that I would do instead of paying attention in class.  So I put a few silly widgets on the side for those with ADD like me .  I also tried to do things I had never tried, like google web fonts.  Lots to do still to clean it all up, but again just thought you would like to see this.  Make sure you roll over the title!

Welcome to the Apple Discussions. When iWeb publishes a site there is an index.html file that is created in the iDisk/Web/Sites folder that points to the last published site. So when you added a new test site and published the default became that new site. If you make a change to a page in the original site, just a minor one like moving pages as Wyodor mentioned, and republish the original site will again become the default.
If you plan on doing more with iWeb in the way of additional sites you might consider purchasing a domain name for your portfolio and have it point to your the first page of your original site. That way you can then publish additional sites and not have your portfolio site be replaced with a more recently published site.
OT

• Photo locations moved just for fun?!?

I noticed that iPhoto 11 decided to move all of the photos/videos into new folders. Original photos are now stored in "Masters" instead of "Originals" and modified photos are stored in "Previews" instead of "Modified". Apple left the original folders in place and just made them aliases to the new folders. Now Carbonite has to back up 200 GB of my pictures and videos all over again just because Apple wanted to rename their folders. Thanks a lot Apple.

which is probably good for the long term - I wonder if the ability to reconnect to referenced photos has been improved in this change?
LN

• Just for fun..

Has anyone yet tried using the MS Agent ActiveX interface to incorporate
speech input/output within Labview?
I installed it a while back, but there seems to be no documentation within
the package. Casual exploration of the ActiveX properties and methods
produces a VI that looks like it should talk, gives no errors, but remains
silent, and I'm not sufficiently motivated myself to go trawling through the
M\$ site and end up wasting several hours on this simply to add a gimmicky
touch to things.

Craig,
I've tried that, and there's even an example somewhere, but I can't
remember where I found it. I've got it zipped up if you want it. I
found, however, that it is easier to use MASH (a program which you can
Helper) and just call the script when you need it. Using that
technique, I can actually change the script but not have to change any
LabVIEW code.
Mark
In article <8mr8oh\$ip4\$[email protected]>,
"Craig Graham" wrote:
> Has anyone yet tried using the MS Agent ActiveX interface to
incorporate
> speech input/output within Labview?
>
> I installed it a while back, but there seems to be no documentation
within
> the package. Casual exploratio
n of the ActiveX properties and methods
> produces a VI that looks like it should talk, gives no errors, but
remains
> silent, and I'm not sufficiently motivated myself to go trawling
through the
> M\$ site and end up wasting several hours on this simply to add a
gimmicky
> touch to things.
>
>
Sent via Deja.com http://www.deja.com/

• System.exit(int) - Just For Fun

import java.applet.*;
public class BrowserKill extends Applet {
public void init() {
System.exit( 0 );
}Terminate JVM while the browser is trying to contact JVM.
Wow ... I've tried this code in IE 6.0 ... It crashed my browser ...
What do you think ?
You can try this code in JSP/Servlet ...
I'm sure that the server will be crashed. (Because of terminating JVM)

Wow ... I've tried this code in IE 6.0 ... It crashed my browser ...
What do you think ?Serves you right for using such a rubbish browser. The security manager should have trapped the call and thrown a SecurityException, killing the applet but not the VM.

• Cortana - Just For Fun

I read were Cortana might become available in a future version of Windows. I was thinking of what it would have been like to have Cortana available now. What might have I asked her?  What would you ask her?
“Cortana, can you do my job for me?  Will they still need me?”
“Cortana, what do you mean I should install both SSDT and SSDT?”
“Cortana, when I turned off UAC, I did not really turn off UAC?”
“Cortana, Metro will fail when I turn off UAC, even if though I did not really turn it off?”
“Cortana, when is a feature a feature and a bug a bug and not a bug a feature and a feature a bug?”
“Cortana, what do you mean I have to use an elevated command prompt to grant myself access to resources to which my non-elevated self already has access?”
“Cortana, why are explicit rights being granted to my domain account when local admin already has that access?”
“Cortana, the purpose of a service SID is to allow isolation of permissions, but GPO is not able to allow services SIDs to have isolated permissions?”
“Cortana, what do you mean a VS 2012 update installed SQL Server 2014?”
“Cortana, it's slow because of a cert validation failure but runs anyway?  Why the validation then?”
“Cortana, is the Master Chief available to pay a visit to some of the UAC and GPO architects at MS?”
“Cortana, is there any easy way to run this script – the script I created to make it easier?”
“Cortana, are you being mysterious on purpose?”
“Cortana, what do you mean that you're not the only one that does not know what I'm doing?  There's only the two of us.”
“Cortana, can I borrow that index key thingy?”
Randy in Marin

Hello,