This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
public class JosephusPosition { | |
public static int josephusSurvivorPosition(final int n, final int k) { | |
// 'n' is the number of people in the cave of death, such that :- the first person is 1 and last is n | |
ArrayList soldiers = new ArrayList<>(); | |
for (int j = 1; j <= n; j++) { | |
soldiers.add(j); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.InputMismatchException; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
long creditCardNo = 0; | |
Scanner scan = new Scanner(System.in); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
//Entering given text for process. | |
System.out.println("Enter the text to be encrypted with Vigenere method"); | |
Scanner scanInputString = new Scanner(System.in); | |
String inputString = scanInputString.nextLine().toLowerCase(); | |
//Entering key word/s. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String demovingShift(String inputCodedString, int shift, int decremental){ | |
char[] inCodedCharArr = new char[inputCodedString.length()]; | |
for (int q = 0; q < inputCodedString.length(); q++) { | |
int DeFlushV =0 , DeFlushVDec = 0; | |
DeFlushV = (int)inputCodedString.charAt(q); | |
if (DeFlushV >= 65 && DeFlushV <=90){ | |
DeFlushVDec = DeFlushV - shift; | |
if(DeFlushVDec < 65) { | |
while (DeFlushVDec < 65) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This method is for encription of text. | |
* @param s The input text which is to be encrypted | |
* @param shift The initial key value to be executed at the first | |
* letter of the text. | |
* @param incremental The number by which the value of key is increased. | |
* @return The encrypted text is returned. | |
**/ | |
public static String movingShift(String s, int shift, int incremental){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NotePassing { | |
public static String decipher (String codedMessage, int key){ | |
char[] charArray = new char[codedMessage.length()]; | |
int[] intArray = new int[codedMessage.length()+1]; | |
for (int r = 0; r < codedMessage.length(); r++){ | |
boolean isUCase = (codedMessage.charAt(r)>=65) && (codedMessage.charAt(r)<=90); | |
boolean isLCase = (codedMessage.charAt(r)>=97) && (codedMessage.charAt(r)<=122); | |
int changedAsci = ((int)codedMessage.charAt(r)) + key; | |
if (isUCase) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Keypad { | |
public static int presses(String phrase){ | |
int noPresses = 0; | |
for(int i = 0 ; i<phrase.length(); i++){ | |
char aToZ = phrase.toUpperCase().charAt(i); | |
if (aToZ == 'A'||aToZ == 'D'||aToZ == 'G'||aToZ == 'J'||aToZ == 'M'||aToZ == 'P'||aToZ == 'T'||aToZ == 'W'||aToZ == '1'||aToZ == ' '||aToZ == '*'||aToZ == '#'){ | |
noPresses = noPresses + 1; | |
System.out.println(noPresses+" 1 = "+aToZ);} | |
else if (aToZ == 'B'||aToZ == 'E'||aToZ == 'H'||aToZ == 'K'||aToZ == 'N'||aToZ == 'Q'||aToZ == 'U'||aToZ == 'X'||aToZ == '0'){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Accumul { | |
public static String accum(String s){ | |
StringBuilder stBuild = new StringBuilder(); | |
for(int i = 0; i < s.length(); i++){ | |
for(int j = 0; j <= i; j++) { | |
if (j==0){ | |
stBuild.append(s.toUpperCase().charAt(i)); | |
} | |
else { | |
stBuild.append(s.toLowerCase().charAt(i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringUtils { | |
public static boolean isHexNumber(String s) { | |
int cursor; | |
if (s.length() == 0){ | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Built application files | |
/*/build/ | |
# Crashlytics configuations | |
com_crashlytics_export_strings.xml | |
# Local configuration file (sdk path, etc) | |
local.properties | |
# Gradle generated files |