code, JAVA Programming

Assignment Help:
pls telme source code for Padovan String

Related Discussions:- code

#tSutherland cohen line clipping algorithm, how do you write the code so th...

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

Mine craft plug-in coder, Mine craft plug-in Coder Project Description: ...

Mine craft plug-in Coder Project Description: Some custom plugging for my Mine craft server. Skills required: Java, Editing

write program a, How do I write a program a bout Rotor cipher

How do I write a program a bout Rotor cipher?

Program for sorting algorithm - java program, Introduction: In this pr...

Introduction: In this project, you will explore a few sorting algorithms. You will also test their efficiency by both timing how long a given sorting operation takes and count

Explain pop, SMTP (Simple Mail Transfer Protocol) permits two mail servers ...

SMTP (Simple Mail Transfer Protocol) permits two mail servers to communicate using a easy language, and gives a step-by-step protocol for exchanging information. SMTP delivers m

Describe even higer dimensions in java, Describe even higer dimensions in j...

Describe even higer dimensions in java? You don't have to stop along with two dimensional arrays. Java allows arrays of three, four or more dimensions. Therefore chances are pr

Using rmi build robust distributed systems-jdbc odbc, This work assesses th...

This work assesses the following Outcomes: • Build robust, secure distributed systems using advanced programming techniques Use RMI to build a distributed application accessing

Develop a camera application, Project Description: I want to build a cam...

Project Description: I want to build a camera application for android. By default android will add metadata for the image, for e.g.  Date, time, resolution, gps tag etc..In this

Video course on computer security needed, Video course on computer security...

Video course on computer security needed Project Description: We want a video course on computer security. Just like the way lynda provides. Skills required are Computer S

gourav

9/7/2012 11:48:55 AM

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"));
}
}

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd