Skip to main content
space in title makes it more clear that language name is Java 7
Source Link
Timtech
  • 12.6k
  • 2
  • 45
  • 61

#Java 7,  431 317   311bytes311 bytes Thanks to @KevinCruijssen for 114 bytes.
Thanks to @RosLup for saving 6 bytes.

String c(String s){String v="",x,l[]=s.split(" "),b[]={"a","an","the","at","but,"by","for","in","of","on","to","‌​up","as","or","and","nor"};int i=0,f=0,z=0;for(String c:l){for(f=0;f<b.length;z=c.equals(b[f++])|z>0?1:0);x=(char)(c.charAt(0)-32)+c.substring(1);v+=(z>0?i<1|i>l.length-2?x:c:x)+" ";i++;}return v;}

#ungolfed

first answer above 250 bytes

 static String c(String s) {
      String v = "", x, l[] = s.split(" "),
b[]={"a","an","the","at","by","for","in","of","on","to",
                                         "‌​up","and","as","or","nor","but"};
    int i , f , z = i = f = 0;
    for (String c : l) {
        
   for (f = 0; f < b.length; z = c.equals( b[f++] ) | z > 0 ? 1 : 0);
        x = (char)(c.charAt(0) - 32) + c.substring(1);
          
        v += (z > 0 ? i < 1 | i > l.length - 2 ? x : c : x) + " ";
        i++;
   }
    return v;
    }

#Java 7,431 317   311bytes Thanks to @KevinCruijssen for 114 bytes.
Thanks to @RosLup for saving 6 bytes.

String c(String s){String v="",x,l[]=s.split(" "),b[]={"a","an","the","at","but,"by","for","in","of","on","to","‌​up","as","or","and","nor"};int i=0,f=0,z=0;for(String c:l){for(f=0;f<b.length;z=c.equals(b[f++])|z>0?1:0);x=(char)(c.charAt(0)-32)+c.substring(1);v+=(z>0?i<1|i>l.length-2?x:c:x)+" ";i++;}return v;}

#ungolfed

first answer above 250 bytes

 static String c(String s) {
      String v = "", x, l[] = s.split(" "),
b[]={"a","an","the","at","by","for","in","of","on","to",
                                         "‌​up","and","as","or","nor","but"};
    int i , f , z = i = f = 0;
    for (String c : l) {
        
   for (f = 0; f < b.length; z = c.equals( b[f++] ) | z > 0 ? 1 : 0);
        x = (char)(c.charAt(0) - 32) + c.substring(1);
          
        v += (z > 0 ? i < 1 | i > l.length - 2 ? x : c : x) + " ";
        i++;
   }
    return v;
    }

#Java 7,  431 317 311 bytes Thanks to @KevinCruijssen for 114 bytes.
Thanks to @RosLup for saving 6 bytes.

String c(String s){String v="",x,l[]=s.split(" "),b[]={"a","an","the","at","but,"by","for","in","of","on","to","‌​up","as","or","and","nor"};int i=0,f=0,z=0;for(String c:l){for(f=0;f<b.length;z=c.equals(b[f++])|z>0?1:0);x=(char)(c.charAt(0)-32)+c.substring(1);v+=(z>0?i<1|i>l.length-2?x:c:x)+" ";i++;}return v;}

#ungolfed

first answer above 250 bytes

 static String c(String s) {
      String v = "", x, l[] = s.split(" "),
b[]={"a","an","the","at","by","for","in","of","on","to",
                                         "‌​up","and","as","or","nor","but"};
    int i , f , z = i = f = 0;
    for (String c : l) {
        
   for (f = 0; f < b.length; z = c.equals( b[f++] ) | z > 0 ? 1 : 0);
        x = (char)(c.charAt(0) - 32) + c.substring(1);
          
        v += (z > 0 ? i < 1 | i > l.length - 2 ? x : c : x) + " ";
        i++;
   }
    return v;
    }
added 41 characters in body
Source Link
Numberknot
  • 935
  • 6
  • 10

#Java 7,431 317 317 bytes311bytes Thanks to @KevinCruijssen for 114 bytes.
Thanks to @RosLup for saving 6 bytes.

String c(String s){String v="",x,l[]=s.split(" "),b[]={"a","an","the","at","but,"by","for","in","of","on","to","‌​up","and","as","or","and","nor"};int i=0,f=0,z=0;for(String c:l){for(f=0;f<b.length;z=c.equals(b[f++])|z>0?1:0);x=(char)(c.charAt(0)-32)+c.substring(1);v+=(z>0?i<1|i>l.length-2?x:c:x)+" ";i++;}return v;}

#ungolfed

first answer above 250 bytes

 static String c(String s) {
      String v = "", x, l[] = s.split(" "),
b[]={"a","an","the","at","by","for","in","of","on","to",
                                         "‌​up","and","as","or","and","nor","but"};
    int i , f , z = i = f = 0;
    for (String c : l) {
        
   for (f = 0; f < b.length; z = c.equals( b[f++] ) | z > 0 ? 1 : 0);
        x = (char)(c.charAt(0) - 32) + c.substring(1);
          
        v += (z > 0 ? i < 1 | i > l.length - 2 ? x : c : x) + " ";
        i++;
   }
    return v;
    }

#Java 7,431 317 bytes Thanks to @KevinCruijssen for 114 bytes.

String c(String s){String v="",x,l[]=s.split(" "),b[]={"a","an","the","at","but,"by","for","in","of","on","to","‌​up","and","as","or","and","nor"};int i=0,f=0,z=0;for(String c:l){for(f=0;f<b.length;z=c.equals(b[f++])|z>0?1:0);x=(char)(c.charAt(0)-32)+c.substring(1);v+=(z>0?i<1|i>l.length-2?x:c:x)+" ";i++;}return v;}

#ungolfed

first answer above 250 bytes

 static String c(String s) {
      String v = "", x, l[] = s.split(" "),
b[]={"a","an","the","at","by","for","in","of","on","to",
                                         "‌​up","and","as","or","and","nor","but"};
    int i , f , z = i = f = 0;
    for (String c : l) {
        
   for (f = 0; f < b.length; z = c.equals( b[f++] ) | z > 0 ? 1 : 0);
        x = (char)(c.charAt(0) - 32) + c.substring(1);
          
        v += (z > 0 ? i < 1 | i > l.length - 2 ? x : c : x) + " ";
        i++;
   }
    return v;
    }

#Java 7,431 317 311bytes Thanks to @KevinCruijssen for 114 bytes.
Thanks to @RosLup for saving 6 bytes.

String c(String s){String v="",x,l[]=s.split(" "),b[]={"a","an","the","at","but,"by","for","in","of","on","to","‌​up","as","or","and","nor"};int i=0,f=0,z=0;for(String c:l){for(f=0;f<b.length;z=c.equals(b[f++])|z>0?1:0);x=(char)(c.charAt(0)-32)+c.substring(1);v+=(z>0?i<1|i>l.length-2?x:c:x)+" ";i++;}return v;}

#ungolfed

first answer above 250 bytes

 static String c(String s) {
      String v = "", x, l[] = s.split(" "),
b[]={"a","an","the","at","by","for","in","of","on","to",
                                         "‌​up","and","as","or","nor","but"};
    int i , f , z = i = f = 0;
    for (String c : l) {
        
   for (f = 0; f < b.length; z = c.equals( b[f++] ) | z > 0 ? 1 : 0);
        x = (char)(c.charAt(0) - 32) + c.substring(1);
          
        v += (z > 0 ? i < 1 | i > l.length - 2 ? x : c : x) + " ";
        i++;
   }
    return v;
    }
deleted 301 characters in body
Source Link
Numberknot
  • 935
  • 6
  • 10

#Java 7,431431 317 bytes Thanks to @KevinCruijssen for 114 bytes.

String fc(String s){String v="";boolean z=0>1;String[]l=sv="",x,l[]=s.split(" ");String[]b=,b[]={"a","an","the","at","but,"by","for","in","of","on","to","up""‌​up","and","as","but","or","and","nor"};int ii=0,f=i=0;forf=0,z=0;for(String c:l){for(f=0;f<b.length;++f)if(clength;z=c.equals(b[f])b[f++]){z=1>0;break;}else z=0>1;v+=z|z>0?(i==0|i++==l.length-1)?c.substring(:0,1).toUpperCase;x=(char)+c.substring(1,c.length())+" ":c+" ":c.substringcharAt(0,1).toUpperCase(-32)+c.substring(1,c);v+=(z>0?i<1|i>l.length()-2?x:c:x)+" ";++i;";i++;}return v;}
 static String fc(String s) {
  String v = "";
  booleanString zv = 0 > 1;
 "", String[]x, ll[] = s.split(" ");,
  String[] b = b[]={"a","an","the","at","by","for","in","of","on","to",
                          "up"               "‌​up","and","as","but","or","and","nor","but"};
    int i , f , z = i = 0;f = 0;
  
   for (String c : l) {
        
   for (f = 0; f < b.length; ++f) {
     z if= (c.equals( b[f]b[f++] )) {
       | z = 1 > 0;
        break;
  0 ? 1 : }0);
      else {
  x = (char)(c.charAt(0) - 32) + zc.substring(1);
 = 0 > 1;
      }
    }
    v += (z
        > 0 ? (i ==< 01 | i++i ==> l.length-1)
       - 2 ? x : c ?: c.substring(0,1).toUpperCase(x) + c.substring(1, c.length())+" "
      ";
       : c+" "i++;
          :}
 c.substring(0,1).toUpperCase() + c.substring(1, c.length())+"return ";v;
  }
  return v;
}

#Java 7,431 bytes

String f(String s){String v="";boolean z=0>1;String[]l=s.split(" ");String[]b={"a","an","the","at","by","for","in","of","on","to","up","and","as","but","or","and","nor"};int i,f=i=0;for(String c:l){for(f=0;f<b.length;++f)if(c.equals(b[f])){z=1>0;break;}else z=0>1;v+=z?(i==0|i++==l.length-1)?c.substring(0,1).toUpperCase()+c.substring(1,c.length())+" ":c+" ":c.substring(0,1).toUpperCase()+c.substring(1,c.length())+" ";++i;}return v;}
String f(String s){
  String v = "";
  boolean z = 0 > 1;
  String[] l = s.split(" ");
  String[] b = {"a","an","the","at","by","for","in","of","on","to",
                          "up","and","as","but","or","and","nor"};
  int i, f = i = 0;    
   for (String c : l) {
    for (f = 0; f < b.length; ++f) {
      if (c.equals( b[f] )) {
        z = 1 > 0;
        break;
      }
      else {
        z = 0 > 1;
      }
    }
    v += z
          ? (i == 0 | i++ == l.length-1)
             ? c.substring(0,1).toUpperCase() + c.substring(1, c.length())+" "
             : c+" "
          : c.substring(0,1).toUpperCase() + c.substring(1, c.length())+" ";
  }
  return v;
}

#Java 7,431 317 bytes Thanks to @KevinCruijssen for 114 bytes.

String c(String s){String v="",x,l[]=s.split(" "),b[]={"a","an","the","at","but,"by","for","in","of","on","to","‌​up","and","as","or","and","nor"};int i=0,f=0,z=0;for(String c:l){for(f=0;f<b.length;z=c.equals(b[f++])|z>0?1:0);x=(char)(c.charAt(0)-32)+c.substring(1);v+=(z>0?i<1|i>l.length-2?x:c:x)+" ";i++;}return v;}
 static String c(String s) {
      String v = "", x, l[] = s.split(" "),
b[]={"a","an","the","at","by","for","in","of","on","to",
                                         "‌​up","and","as","or","and","nor","but"};
    int i , f , z = i = f = 0;
    for (String c : l) {
        
   for (f = 0; f < b.length; z = c.equals( b[f++] ) | z > 0 ? 1 : 0);
        x = (char)(c.charAt(0) - 32) + c.substring(1);
          
        v += (z > 0 ? i < 1 | i > l.length - 2 ? x : c : x) + " ";
        i++;
   }
    return v;
    }
Ungolfed code formatted so I can read it easier myself...
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading
deleted 8 characters in body
Source Link
Numberknot
  • 935
  • 6
  • 10
Loading
deleted 8 characters in body
Source Link
Numberknot
  • 935
  • 6
  • 10
Loading
Source Link
Numberknot
  • 935
  • 6
  • 10
Loading