Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

#Java 7,(削除) 182 (削除ここまで) 177 bytes

I ported Karl Napf C answer to JAVA I ported Karl Napf C answer to JAVA And Thanks to Karl Napf Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

#Ungolfed

class Beef {
 public static void main(String[] args) {
 int x = f(new int[] { 1222, 3107, 1508, 3997, 1906, 379, 2874, 2926, 1480, 1487, 3565, 633 });
 System.out.println(x >> 4);
 System.out.println(x & 15);
 }
 static int f(int[] a) {
 int x = 9,
 y,
 z = 0;
 for (; x-- > 0; ) {
 for (y = 0; y < 9; a[y++] /= 2)
 if ((a[y] & 15) == 11 
 & (a[y + 1] & 15) == 14
 & (a[y + 2] & 15) == 14 
 & (a[y + 3] & 15) == 15)
 z = (x << 4) + y;
 a[y] /= 2;
 a[10] /= 2;
 a[11] /= 2;
 }
 return z;
 }
}

#Java 7,(削除) 182 (削除ここまで) 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

#Ungolfed

class Beef {
 public static void main(String[] args) {
 int x = f(new int[] { 1222, 3107, 1508, 3997, 1906, 379, 2874, 2926, 1480, 1487, 3565, 633 });
 System.out.println(x >> 4);
 System.out.println(x & 15);
 }
 static int f(int[] a) {
 int x = 9,
 y,
 z = 0;
 for (; x-- > 0; ) {
 for (y = 0; y < 9; a[y++] /= 2)
 if ((a[y] & 15) == 11 
 & (a[y + 1] & 15) == 14
 & (a[y + 2] & 15) == 14 
 & (a[y + 3] & 15) == 15)
 z = (x << 4) + y;
 a[y] /= 2;
 a[10] /= 2;
 a[11] /= 2;
 }
 return z;
 }
}

#Java 7,(削除) 182 (削除ここまで) 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

#Ungolfed

class Beef {
 public static void main(String[] args) {
 int x = f(new int[] { 1222, 3107, 1508, 3997, 1906, 379, 2874, 2926, 1480, 1487, 3565, 633 });
 System.out.println(x >> 4);
 System.out.println(x & 15);
 }
 static int f(int[] a) {
 int x = 9,
 y,
 z = 0;
 for (; x-- > 0; ) {
 for (y = 0; y < 9; a[y++] /= 2)
 if ((a[y] & 15) == 11 
 & (a[y + 1] & 15) == 14
 & (a[y + 2] & 15) == 14 
 & (a[y + 3] & 15) == 15)
 z = (x << 4) + y;
 a[y] /= 2;
 a[10] /= 2;
 a[11] /= 2;
 }
 return z;
 }
}

#Java 7,(削除) 182 (削除ここまで) 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

#Ungolfed

class Beef {
 public static void main(String[] args) {
int x = f(new int[]{1222, 3107, 1508, 3997, 1906, 379, 2874, 2926,1480,1487, 3565, 633});
 System.out.println(x x>>4>> 4);
 System.out.println(x x&15& 15);
}
static int f(int[] a){
int x = 9, y y,z = 0 ;0;

for (; x-- > 00; ;) {
 for ( y = 0 ; for (y <= 90; ;y a[< y++9; ]a[y++] /= 2) if( ( a[ y ] if ((a[y] & 15) == 11 & ( a[ y + 1 ] & 15(a[y + 1] & 15) == 14
 &( a[ y + 2 ]& (a[y + 2] & 15) == 14 & ( a[ y + 3 ] & 15(a[y + 3] & 15) == 15)
 z = (x << 4) + y ;y;
 a[ y ] a[y] /= 22;
 ; a[ 10 ] a[10] /= 22;
 ; a[ 11 ] a[11] /= 2 ;
2;
 }
 return z ; return z;
 }
}

#Java 7,(削除) 182 (削除ここまで) 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

#Ungolfed

class Beef {
 public static void main(String[] args) {
int x = f(new int[]{1222, 3107, 1508, 3997, 1906, 379, 2874, 2926,1480,1487, 3565, 633});
 System.out.println( x>>4 );
 System.out.println( x&15 );
}
static int f(int[] a){
int x = 9, y ,z = 0 ;
for (; x-- > 0 ;) {
 for ( y = 0 ; y < 9 ; a[ y++ ] /= 2) if( ( a[ y ] & 15) == 11 & ( a[ y + 1 ] & 15 ) == 14
 &( a[ y + 2 ] & 15) == 14 & ( a[ y + 3 ] & 15 ) == 15)
 z = (x << 4) + y ;
 a[ y ] /= 2 ; a[ 10 ] /= 2 ; a[ 11 ] /= 2 ;

 }
 return z ;
 }
}

#Java 7,(削除) 182 (削除ここまで) 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

#Ungolfed

class Beef {
 public static void main(String[] args) {
int x = f(new int[]{1222, 3107, 1508, 3997, 1906, 379, 2874, 2926,1480,1487, 3565, 633});
 System.out.println(x >> 4);
 System.out.println(x & 15);
}
static int f(int[] a){
int x = 9, y,z = 0;

for (; x-- > 0; ) {
  for (y = 0; y < 9; a[y++] /= 2)  if ((a[y] & 15) == 11  & (a[y + 1] & 15) == 14
 & (a[y + 2] & 15) == 14  & (a[y + 3] & 15) == 15)
 z = (x << 4) + y;
 a[y] /= 2;
  a[10] /= 2;
 a[11] /= 2;
 }
  return z;
 }
}
added 339 characters in body
Source Link
Numberknot
  • 935
  • 6
  • 10

#Java 7,182(削除) 182 (削除ここまで) 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]>>=1y=0;y<9;a[y++]/=2)if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]>>=1;a[y+1]>>=1;a[y+2]>>=1;+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

#Ungolfed

class Beef {
public static void main(String[] args) {

int x = f(new int[]{1222, 3107, 1508, 3997, 1906, 379, 2874, 2926,1480,1487, 3565, 633});
 System.out.println( x>>4 ) ;
 System.out.println( x&15 ) ;

}
static int f( int[] a ){
int x = 9 , y ,z = 0 ;
for ( ; x-- > 0 ;) {
for ( y = 0 ; y < 9 ; a[ y++ ] >>=/= 12 ) 
if( ( a[ y ] & 15 ) == 11 & ( a[ y + 1 ] & 15 ) == 14 
 &( a[ y + 2 ] & 15 ) == 14 & ( a[ y + 3 ] & 15 ) == 15)
 z = ( x << 4 ) + y ;
a[y] >>= 1 ; a[ y + 1 ] >>=/= 12 ; a[ y10 +] /= 2 ; a[ 11 ] >>=/= 12 ;
}
return z ;
 }

}

#Java 7,182 bytes

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]>>=1)if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]>>=1;a[y+1]>>=1;a[y+2]>>=1;}return z;}

#Ungolfed

class Beef {
public static void main(String[] args) {

int x = f(new int[]{1222, 3107, 1508, 3997, 1906, 379, 2874, 2926,1480,1487, 3565, 633});
 System.out.println( x>>4 ) ;
 System.out.println( x&15 ) ;

}
static int f( int[] a ){
int x = 9 , y ,z = 0 ;
for ( ; x-- > 0 ;) {
for ( y = 0 ; y < 9 ; a[ y++ ] >>= 1 ) 
if( ( a[ y ] & 15 ) == 11 & ( a[ y + 1 ] & 15 ) == 14 
 &( a[ y + 2 ] & 15 ) == 14 & ( a[ y + 3 ] & 15 ) == 15)
 z = ( x << 4 ) + y ;
a[y] >>= 1 ; a[ y + 1 ] >>= 1 ; a[ y + 2 ] >>= 1 ;
}
return z ;
 }

}

#Java 7,(削除) 182 (削除ここまで) 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2)if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

#Ungolfed

class Beef {
public static void main(String[] args) {
int x = f(new int[]{1222, 3107, 1508, 3997, 1906, 379, 2874, 2926,1480,1487, 3565, 633});
 System.out.println( x>>4 ) ;
 System.out.println( x&15 ) ;
}
static int f( int[] a ){
int x = 9 , y ,z = 0 ;
for ( ; x-- > 0 ;) {
for ( y = 0 ; y < 9 ; a[ y++ ] /= 2 ) 
if( ( a[ y ] & 15 ) == 11 & ( a[ y + 1 ] & 15 ) == 14 
 &( a[ y + 2 ] & 15 ) == 14 & ( a[ y + 3 ] & 15 ) == 15)
 z = ( x << 4 ) + y ;
 a[ y ] /= 2 ; a[ 10 ] /= 2 ; a[ 11 ] /= 2 ;
}
return z ;
 }
}
deleted 6 characters in body
Source Link
Numberknot
  • 935
  • 6
  • 10
Loading
added <!-- language-all: lang-java --> for highlighting
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31
Loading
deleted 1 character in body
Source Link
Numberknot
  • 935
  • 6
  • 10
Loading
Source Link
Numberknot
  • 935
  • 6
  • 10
Loading

AltStyle によって変換されたページ (->オリジナル) /