code, JAVA Programming

pls telme source code for Padovan String
Posted Date: 9/1/2012 2:34:49 AM | Location : United States





package test.padovanstring;

public class PadovanString {
public int stringOccurrences(int n, String str){

if(n >= 40)
return -1;
if(str.replaceAll("X|Y|Z","").length()>0)
return -1;
String res=pad(n);
return(res.length() - res.replaceAll(str,"").length())/(str.length());
}
public String pad(int n){
if(n == 0) return "X";
if(n == 1) return "Y";
if(n == 2) return "Z";
else return pad(n-2) + pad(n-3);

}
public static void main(String []args)
{
PadovanString p = new PadovanString();
System.out.println(p.stringOccurrences(21,"YZ"));
}
}
Posted by gourav | Posted Date: 9/7/2012 11:48:55 AM


Related Discussions:- code, Assignment Help, Ask Question on code, Get Answer, Expert's Help, code Discussions

Write discussion on code
Your posts are moderated
Related Questions
Design and implement an application that reads a sequence of up to 25 pairs of names and postal (ZIP) codes for individuals. Store the data in an object designed to store a first n

Need assignment help , on the topic “Demonstrate a console-program” Demonstrate a console-program to create an array of integers and Initialize the array and assign the values i

how do you write the code so the line will be clipped

Project Description: You should give A Working, Sample Android .apk Project and Java source code Original Photoshop PSD that I can edit and customize to fit my needs All S

Fill in the necessary parts to create a GUI that uses the CardDeck class.  In your GUI you should have a text field for each hand, two buttons and a text area.   Your program s


write complete application to play game tictactoe

Project Description: Android app for particular needs children Provide the fonts, layouts and images of the app. Functions: home screen: main page that links to 'login'

Here are some features of spring:- ? Lightweight: spring is lightweight when it comes to size and transparency. The essential version of spring framework is around 1MB. And t

Project Description: We have an encrypted HSQL Database which we need to convert into CSV format. HSQL DB . We have java application jar file which reads that database but no