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 Revisions

7 of 7
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/

#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;
 }
}
Numberknot
  • 935
  • 6
  • 10

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