#Java 7, (削除) 112 (削除ここまで) 104 bytes
Java 7, (削除) 112 (削除ここまで) 104 bytes
int c(int[]a){int i=a[0],j;for(int b:a)i=(j=(i+"").length()-(b+"").length())>0?b:b>i&j==0?b:i;return i;}
Different approach to save multiple bytes thanks to @Barteks2x.
Ungolfed & test cases:
class M{
static int c(int[] a){
int i = a[0],
j;
for(int b : a){
i = (j = (i+"").length() - (b+"").length()) > 0
? b
: b > i & j == 0
? b
: i;
}
return i;
}
public static void main(String[] a){
System.out.println(c(new int[]{ 1 }));
System.out.println(c(new int[]{ 9 }));
System.out.println(c(new int[]{ 1729 }));
System.out.println(c(new int[]{ 1, 1 }));
System.out.println(c(new int[]{ 34, 3 }));
System.out.println(c(new int[]{ 409, 12, 13 }));
System.out.println(c(new int[]{ 11, 11, 11, 1 }));
System.out.println(c(new int[]{ 11, 11, 11, 11 }));
System.out.println(c(new int[]{ 78, 99, 620, 1 }));
System.out.println(c(new int[]{ 78, 99, 620, 100 }));
System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
}
}
Output:
1
9
1729
1
3
13
1
11
1
99
9
3451
938
#Java 7, (削除) 112 (削除ここまで) 104 bytes
int c(int[]a){int i=a[0],j;for(int b:a)i=(j=(i+"").length()-(b+"").length())>0?b:b>i&j==0?b:i;return i;}
Different approach to save multiple bytes thanks to @Barteks2x.
Ungolfed & test cases:
class M{
static int c(int[] a){
int i = a[0],
j;
for(int b : a){
i = (j = (i+"").length() - (b+"").length()) > 0
? b
: b > i & j == 0
? b
: i;
}
return i;
}
public static void main(String[] a){
System.out.println(c(new int[]{ 1 }));
System.out.println(c(new int[]{ 9 }));
System.out.println(c(new int[]{ 1729 }));
System.out.println(c(new int[]{ 1, 1 }));
System.out.println(c(new int[]{ 34, 3 }));
System.out.println(c(new int[]{ 409, 12, 13 }));
System.out.println(c(new int[]{ 11, 11, 11, 1 }));
System.out.println(c(new int[]{ 11, 11, 11, 11 }));
System.out.println(c(new int[]{ 78, 99, 620, 1 }));
System.out.println(c(new int[]{ 78, 99, 620, 100 }));
System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
}
}
Output:
1
9
1729
1
3
13
1
11
1
99
9
3451
938
Java 7, (削除) 112 (削除ここまで) 104 bytes
int c(int[]a){int i=a[0],j;for(int b:a)i=(j=(i+"").length()-(b+"").length())>0?b:b>i&j==0?b:i;return i;}
Different approach to save multiple bytes thanks to @Barteks2x.
Ungolfed & test cases:
class M{
static int c(int[] a){
int i = a[0],
j;
for(int b : a){
i = (j = (i+"").length() - (b+"").length()) > 0
? b
: b > i & j == 0
? b
: i;
}
return i;
}
public static void main(String[] a){
System.out.println(c(new int[]{ 1 }));
System.out.println(c(new int[]{ 9 }));
System.out.println(c(new int[]{ 1729 }));
System.out.println(c(new int[]{ 1, 1 }));
System.out.println(c(new int[]{ 34, 3 }));
System.out.println(c(new int[]{ 409, 12, 13 }));
System.out.println(c(new int[]{ 11, 11, 11, 1 }));
System.out.println(c(new int[]{ 11, 11, 11, 11 }));
System.out.println(c(new int[]{ 78, 99, 620, 1 }));
System.out.println(c(new int[]{ 78, 99, 620, 100 }));
System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
}
}
Output:
1
9
1729
1
3
13
1
11
1
99
9
3451
938
#Java 7, 112(削除) 112 (削除ここまで) 104 bytes
int c(int[]a){int i=a[0];for(int b:a)i=b<i?b:i;fori=a[0],j;for(int b:a)i=(j=(i+"").length()==-(b+"").length()&b>i)>0?b:b>i&j==0?b:i;return i;}
Different approach to save multiple bytes thanks to @Barteks2x.
Ungolfed & test cases:
class M{
static int c(int[] a){
int i = a[0];a[0],
j;
for(int b : a){
i = b < i
(j = (i+"").length() - (b+"").length()) ?> b0
:? i;b
}
for(int b : a){
: b > i =& (i+"").length()j == (b+"").length() &0
b > i
? b
: i;
}
return i;
}
public static void main(String[] a){
System.out.println(c(new int[]{ 1 }));
System.out.println(c(new int[]{ 9 }));
System.out.println(c(new int[]{ 1729 }));
System.out.println(c(new int[]{ 1, 1 }));
System.out.println(c(new int[]{ 34, 3 }));
System.out.println(c(new int[]{ 409, 12, 13 }));
System.out.println(c(new int[]{ 11, 11, 11, 1 }));
System.out.println(c(new int[]{ 11, 11, 11, 11 }));
System.out.println(c(new int[]{ 78, 99, 620, 1 }));
System.out.println(c(new int[]{ 78, 99, 620, 100 }));
System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
}
}
#Java 7, 112 bytes
int c(int[]a){int i=a[0];for(int b:a)i=b<i?b:i;for(int b:a)i=(i+"").length()==(b+"").length()&b>i?b:i;return i;}
Ungolfed & test cases:
class M{
static int c(int[] a){
int i = a[0];
for(int b : a){
i = b < i
? b
: i;
}
for(int b : a){
i = (i+"").length() == (b+"").length() & b > i
? b
: i;
}
return i;
}
public static void main(String[] a){
System.out.println(c(new int[]{ 1 }));
System.out.println(c(new int[]{ 9 }));
System.out.println(c(new int[]{ 1729 }));
System.out.println(c(new int[]{ 1, 1 }));
System.out.println(c(new int[]{ 34, 3 }));
System.out.println(c(new int[]{ 409, 12, 13 }));
System.out.println(c(new int[]{ 11, 11, 11, 1 }));
System.out.println(c(new int[]{ 11, 11, 11, 11 }));
System.out.println(c(new int[]{ 78, 99, 620, 1 }));
System.out.println(c(new int[]{ 78, 99, 620, 100 }));
System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
}
}
#Java 7, (削除) 112 (削除ここまで) 104 bytes
int c(int[]a){int i=a[0],j;for(int b:a)i=(j=(i+"").length()-(b+"").length())>0?b:b>i&j==0?b:i;return i;}
Different approach to save multiple bytes thanks to @Barteks2x.
Ungolfed & test cases:
class M{
static int c(int[] a){
int i = a[0],
j;
for(int b : a){
i = (j = (i+"").length() - (b+"").length()) > 0
? b
: b > i & j == 0
? b
: i;
}
return i;
}
public static void main(String[] a){
System.out.println(c(new int[]{ 1 }));
System.out.println(c(new int[]{ 9 }));
System.out.println(c(new int[]{ 1729 }));
System.out.println(c(new int[]{ 1, 1 }));
System.out.println(c(new int[]{ 34, 3 }));
System.out.println(c(new int[]{ 409, 12, 13 }));
System.out.println(c(new int[]{ 11, 11, 11, 1 }));
System.out.println(c(new int[]{ 11, 11, 11, 11 }));
System.out.println(c(new int[]{ 78, 99, 620, 1 }));
System.out.println(c(new int[]{ 78, 99, 620, 100 }));
System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
}
}
#Java 7, 112 bytes
int c(int[]a){int i=a[0];for(int b:a)i=b<i?b:i;for(int b:a)i=(i+"").length()==(b+"").length()&b>i?b:i;return i;}
Ungolfed & test cases:
class M{
static int c(int[] a){
int i = a[0];
for(int b : a){
i = b < i
? b
: i;
}
for(int b : a){
i = (i+"").length() == (b+"").length() & b > i
? b
: i;
}
return i;
}
public static void main(String[] a){
System.out.println(c(new int[]{ 1 }));
System.out.println(c(new int[]{ 9 }));
System.out.println(c(new int[]{ 1729 }));
System.out.println(c(new int[]{ 1, 1 }));
System.out.println(c(new int[]{ 34, 3 }));
System.out.println(c(new int[]{ 409, 12, 13 }));
System.out.println(c(new int[]{ 11, 11, 11, 1 }));
System.out.println(c(new int[]{ 11, 11, 11, 11 }));
System.out.println(c(new int[]{ 78, 99, 620, 1 }));
System.out.println(c(new int[]{ 78, 99, 620, 100 }));
System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
}
}
Output:
1
9
1729
1
3
13
1
11
1
99
9
3451
938