Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.
public static int getWordValue(String s){
int nsum = 0;
s = s.toLowerCase();
for(int j=0; j<s.length(); j++){
nsum += (s.charAt(j) - 'a' + 1);
}
return nsum;
}
public class FindWords {
public static int getWordValue(String s){
int nsum = 0;
s = s.toLowerCase();
for(int j=0; j<s.length(); j++){
nsum += (s.charAt(j) - 'a' + 1);
}
return nsum;
}
public static void main(String[] args) {
try{
BufferedReader br1 = new BufferedReader(new FileReader("austen.txt"));
String line = null;
while((line = br1.readLine()) != null){
String [] ss = line.split("\\s+");
for(String s0: ss){
if(getWordValue(s0) == 100)System.out.println(s0);
}
}
br1.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
variety
applying
excellent
towards
austen.txt
public class FindWord {
public static int getWordValue(String s){
int nsum = 0;
s = s.toLowerCase();
for(int j=0; j<s.length(); j++){
nsum += (s.charAt(j) - 'a' + 1);
}
return nsum;
}
public static String get100Words() {
String alph = "abcdefghijklmnopqrstuvwxyz";
Random rr = new Random();
String sum = "";
while(true){
sum += alph.charAt(rr.nextInt(26));
int tot = getWordValue(sum);
if(tot == 100)return sum;
else if (tot > 100){
sum = "";continue;
}
}
}
public static void main(String[] args) {
System.out.println(get100Words());
}
}
qhraexnkb
public class FindmanyWords {
public static int getWordValue(String s){
int nsum = 0;
s = s.toLowerCase();
for(int j=0; j<s.length(); j++){
nsum += (s.charAt(j) - 'a' + 1);
}
return nsum;
}
public static ArrayList <String> get100Words(int num) {
ArrayList<String> ar = new ArrayList<String>();
String alph = "abcdefghijklmnopqrstuvwxyz";
Random rr = new Random();
String sum = "";
while(true){
sum += alph.charAt(rr.nextInt(26));
int tot = getWordValue(sum);
if(tot == 100){ar.add(sum); if (ar.size() == num) return ar;}
else if (tot > 100){
sum = "";continue;
}
}
}
public static void main(String[] args) {
System.out.println(get100Words(10));
}
}
[iayxcgmdn, poxigxe, dimcegeyoie, jkjfqvcu, pyunpce, ydhsgjrah, ndwgetlchd, fkgxkgdwg, ccesuedpx, rboiycrj]
public static ArrayList <String> get100Words(int num) {
ArrayList<String> ar = new ArrayList<String>();
String alph = "abcdefghijklmnopqrstuvwxyz";
Random rr = new Random();
String sum = "";
int tot = 0;
while(true){
if(tot > 75 && tot <100) sum += alph.charAt(rr.nextInt(Math.min(100-tot,26)));
else sum += alph.charAt(rr.nextInt(26));
tot = getWordValue(sum);
if(tot == 100){ar.add(sum); if (ar.size() == num) return ar;}
else if (tot > 100){
sum = ""; tot = 0; continue;
}
}
}
public class FindManyWords{
public static int getWordValue(String s){
int nsum = 0;
s = s.toLowerCase();
for(int j=0; j<s.length(); j++){
nsum += (s.charAt(j) - 'a' + 1);
}
return nsum;
}
static int count;
public static ArrayList <String> get100Words(int num) {
ArrayList<String> ar = new ArrayList<String>();
String alph = "abcdefghijklmnopqrstuvwxyz";
Random rr = new Random();
String sum = "";
int tot = 0;
while(true){
if(tot > 75 && tot <100) sum += alph.charAt(rr.nextInt(Math.min(100-tot,26)));
else sum += alph.charAt(rr.nextInt(26));
// sum += alph.charAt(rr.nextInt(26));
tot = getWordValue(sum);
if(tot == 100){ar.add(sum); if (ar.size() == num) return ar;}
else if (tot > 100){
count++;
sum = ""; tot = 0; continue;
}
}
}
public static void main(String[] args) {
System.out.println(get100Words(10) + " total tried: " + count);
}
}
[nhcppxhhba, xcnpclbseaa, wacknsaragaa, ggyumllc, zfcensudb, vfnzrjaba, vjmkrsg, hfkbcwzjib, ivvhqffia, czrcsitaa] total rejected: 9
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.