Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3
  ignore  |  Print  
  Name that Poker hand - Tiny Code Challenge  (Read 3440 times)
0 Members and 1 Guest are viewing this topic.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Posted 2014-03-13 17:28:39 »

Beloved minions,

I was thoroughly bored, so I wrote a function that determines the name of your poker hand (5 cards). I couldn't help myself and started to optimize for code size. Clueless

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
int h(char[] g){
   int n=99,i=-2,j,p=n,q=-p,r=n,s=q;
   int[][]y=new int[5][n];
   int[]a=y[0],b=y[1],c=y[2],d=y[3],e=y[4];
   for(;i<13;a[" A23456789TJQK".indexOf(g[i+=2])]++,b[g[++i]]++);
   for(i=n;--i>=0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i==1?14:i;r=r<j?r:j;s=s>j?s:j;}
   for(i=n;--i>=0;d[b[i]]=i,e[a[i]]++);boolean u,v,w=q-p==4|s-r==4;
   for(int f:a)w&=f<2;v=d[5]>0;u=w&v;
   for(boolean h:new boolean[]{u&s-r<5,u,c[4]>0,e[3]==1&e[2]==1,v,w,c[3]>0,e[2]==2,e[2]==1}){if(h)break;n--;}
   return n;
}

Code size: 477 chars (after trimming lines and removing newlines)

Can you find a bug, or can you come up with a smaller code size? Scraping off some bytes, to prove how I wasn't paying attention is appreciated too!




Usage:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
String[] hands = new String[9];
hands[0] = "3H 5D JS 3C 7C"; // one pair
hands[1] = "JH 4C 2C JD 2H"; // two pair
hands[2] = "7H 3S 7S 7D 7C"; // four of a kind
hands[3] = "8C 3H 8S 8H 3S"; // full house
hands[4] = "8C 3C 4S 8C 3C"; // two pair
hands[5] = "4C 6C 8S 5C 7C"; // straight
hands[6] = "AC 2C 3C 4C 5C"; // straight flush: A,2,3,4,5 (ace low)
hands[7] = "AC KC QC JC TC"; // royal flush: T,J,Q,K,A (ace high)
hands[8] = "AC 8C QA JH TC"; // high card
     
String[] name = new String[10];
name[0] = "royal flush";
name[1] = "straight flush";
name[2] = "four of a kind";
name[3] = "full house";
name[4] = "flush";
name[5] = "straight";
name[6] = "three of a kind";
name[7] = "two pair";
name[8] = "one pair";
name[9] = "high card";

for(String hand : hands)
   System.out.println(hand+": "+name[99-h(hand.toCharArray())]);

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline saucymeatman
« Reply #1 - Posted 2014-03-13 17:43:56 »

This is really cool!  Smiley

EDIT :
You might like this, it's codegolf, accomplish a task in a minimal amount of characters.
https://www.hackerrank.com/categories/miscellaneous/normal-languages
HackerRank.com has alot of great challenges, and you dont have to sign up. It compiles your code for you, and sends back the result, and you can do the challenges in any language.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2014-03-13 17:44:45 »

I just realized I totally forgot about 'royal flush' (same as straight flush with ace-high). Cranky


Edit: fixed, +8 chars Emo
Edit: optimized, -12 chars Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online BurntPizza
« Reply #3 - Posted 2014-03-13 20:30:50 »

This is really cool!  Smiley

EDIT :
You might like this, it's codegolf, accomplish a task in a minimal amount of characters.
https://www.hackerrank.com/categories/miscellaneous/normal-languages
HackerRank.com has alot of great challenges, and you dont have to sign up. It compiles your code for you, and sends back the result, and you can do the challenges in any language.

I remember that site, back when you could sort the leaderboard by language I was 1st in all the code golf challenges using Java  Cheesy
Granted, Java is terrible for code golf...

I'll have to try melting a few more brain cells on Riven's code and see if I can shrink it any more...

First thing I see (depending on how you count chars) is
char[] g
can be
char[]g
, saving the space.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2014-03-13 20:32:48 »

I remember that site, back when you could sort the leaderboard by language I was 1st in all the code golf challenges using Java  Cheesy

I'll have to try melting a few more brain cells on Riven's code and see if I can shrink it any more...

https://www.hackerrank.com/challenges/fizzbuzz/leaderboard/filter/language=java

I saw your #1 ranking... I'm #11th atm Smiley I only have to shave off 2 more bytes!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Grunnt

JGO Wizard


Medals: 79
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #5 - Posted 2014-03-13 20:52:26 »

To be practically useful it should not generate an ArrayIndexOutOfBoundsException when you have nothing special in your hand (e.g. on input "3H 5D JS 1C 7C"). For shrinking, wow, I have to exterminate a couple of additional brain cells...

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2014-03-13 20:53:53 »

To be practically useful it should not generate an ArrayIndexOutOfBoundsException when you have nothing special in your hand (e.g. on input "3H 5D JS 1C 7C"). For shrinking, wow, I have to exterminate a couple of additional brain cells...
"1C" is an invalid card, it should be "AC" (there are no ones, just aces), it will correctly respond with "high card"

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Grunnt

JGO Wizard


Medals: 79
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #7 - Posted 2014-03-13 20:56:14 »

Duh persecutioncomplex I'll go find a pack of cards now...

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #8 - Posted 2014-03-13 21:12:42 »

1  
2  
3  
4  
5  
6  
7  
8  
      int h(char[]g){
         int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n],a[]=y[0],b[]=y[1],c[]=y[2],d[]=y[3],e[]=y[4];
         for(;i<13;a[" A23456789TJQK".indexOf(g[i+=2])]++,b[g[++i]]++);
         for(i=n;--i>=0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i==1?14:i;r=r<j?r:j;s=s>j?s:j;}
         boolean v,w=q-p==4|s-r==4;for(i=n;--i>=0;d[b[i]]=i,e[a[i]]++)w&=a[i]<2;v=d[5]>0;
         for(boolean h: new boolean[]{w&v&s-r<5,w&v,c[4]>0,e[3]==1&e[2]==1,v,w,c[3]>0,e[2]==2,e[2]==1}){if(h)break;n--;}
         return n;
      }

Code size: 465 (thx BurntPizza for that 1 char!)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online BurntPizza
« Reply #9 - Posted 2014-03-13 21:33:06 »

Few more:


1  
2  
3  
4  
5  
6  
7  
8  
int h(char[]g){
         int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n],a[]=y[0],b[]=y[1],c[]=y[2],d[]=y[3],e[]=y[4];
         for(;i<13;a[" A23456789TJQK".indexOf(g[i+=2])]++,b[g[++i]]++);
         for(i=n;i-->0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i==1?14:i;r=r<j?r:j;s=s>j?s:j;} // --i>=0    -->     i-->0    (high postfix precedence)
         boolean v,w=q-p==4|s-r==4;for(i=n;i-->0;d[b[i]]=i,e[a[i]]++)w&=a[i]<2;v=d[5]>0;   // same as before
         for(boolean h:new boolean[]{w&v&s-r<5,w&v,c[4]>0,e[3]==1&e[2]==1,v,w,c[3]>0,e[2]==2,e[2]==1}){if(h)break;n--;}
         return n; //  ^ removed space
}
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2014-03-13 22:16:48 »

Thx, I can remove even more bytes, but I'm on my mobile now, so I can't easily compile or test...

1  
2  
3  
4  
5  
6  
7  
8  
int h(char[]g){
         int n=99,i=0,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n],a[]=y[0],b[]=y[1],c[]=y[2],d[]=y[3],e[]=y[4];
         for(;i<13;a[" A23456789TJQK".indexOf(g[i])]++,b[g[++i]]++)i+=2;
         for(i=n;i-->0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i==1?14:i;r=r<j?r:j;s=s>j?s:j;} // --i>=0    -->     i-->0    (high postfix precedence)
         boolean v,w=q-p==4|s-r==4;for(i=n;i-->0;d[b[i]]=i,e[a[i]]++)w&=a[i]<2;v=d[5]>0,t=e[2]==1;   // same as before
         for(boolean h:new boolean[]{w&v&s-r<5,w&v,c[4]>0,e[3]==1&t,v,w,c[3]>0,e[2]==2,t}){if(h)break;n--;}
         return n; //  ^ removed space
}

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online BurntPizza
« Reply #11 - Posted 2014-03-13 22:29:33 »

"t cannot be resolved to a variable"

Also -5 chars:

1  
2  
//int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n],a[]=y[0],b[]=y[1],c[]=y[2],d[]=y[3],e[]=y[4];
  int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n];int[]a=y[0],b=y[1],c=y[2],d=y[3],e=y[4];


Edit: Also replace any of those a,b,c,d,e that have less than 3 usages (looks to be b and d) with y[q], where q is the number it would've been. Each declaration is 7 chars (except the last one, no comma), each substitution adds only 3. Should save another 8 chars, if I count right.


This truly is the devil's work  Tongue
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #12 - Posted 2014-03-13 22:45:00 »

Great! Reused 'i' as cache:
1  
2  
3  
4  
5  
6  
7  
8  
   int h(char[]g){
      int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n];int[]a=y[0],b=y[1],c=y[2],d=y[3],e=y[4];
      for(;i<13;a[" A23456789TJQK".indexOf(g[i+=2])]++,b[g[++i]]++);
      for(i=n;i-->0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i==1?14:i;r=r<j?r:j;s=s>j?s:j;}
      boolean v,w=q-p==4|s-r==4;for(i=n;i-->0;d[b[i]]=i,e[a[i]]++)w&=a[i]<2;v=d[5]>0;i=e[2];
      for(boolean h:new boolean[]{w&v&s-r<5,w&v,c[4]>0,e[3]==1&i==1,v,w,c[3]>0,i==2,i==1}){if(h)break;n--;}
      return n;
   }

Code size: 455 bytes!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #13 - Posted 2014-03-13 22:49:08 »

Edit: Also replace any of those a,b,c,d,e that have less than 3 usages (looks to be b and d) with y[q], where q is the number it would've been. Each declaration is 7 chars (except the last one, no comma), each substitution adds only 3. Should save another 8 chars, if I count right.

You remove 2x 7 bytes (14)
Then you add 4x 3 bytes (12)
Net reduction of 2, not 8, right?


1  
2  
3  
4  
5  
6  
7  
8  
   int h(char[]g){
      int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n];int[]a=y[0],c=y[2],e=y[4];
      for(;i<13;a[" A23456789TJQK".indexOf(g[i+=2])]++,y[1][g[++i]]++);
      for(i=n;i-->0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i==1?14:i;r=r<j?r:j;s=s>j?s:j;}
      boolean v,w=q-p==4|s-r==4;for(i=n;i-->0;y[3][y[1][i]]=i,e[a[i]]++)w&=a[i]<2;v=y[3][5]>0;i=e[2];
      for(boolean h:new boolean[]{w&v&s-r<5,w&v,c[4]>0,e[3]==1&i==1,v,w,c[3]>0,i==2,i==1}){if(h)break;n--;}
      return n;
   }

Code size: 453 bytes

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online BurntPizza
« Reply #14 - Posted 2014-03-13 22:50:10 »

Edit: Also replace any of those a,b,c,d,e that have less than 3 usages (looks to be b and d) with y[q], where q is the number it would've been. Each declaration is 7 chars (except the last one, no comma), each substitution adds only 3. Should save another 8 chars, if I count right.

You remove 2x 7 bytes (14)
Then you add 4x 3 bytes (12)
Net reduction of 2, not 8, right?

Yep, that's enough brain cells for today...
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #15 - Posted 2014-03-13 23:10:32 »

Finally! A logic optimization... Grin

1  
2  
... i=e[2] ....
... e[3]==1&i==1 ...

basically said:
1  
... (e[3]==1)&(e[2]==1) ... // full house: (a set of 3) and (a set of 2)


You can never have 2+ sets of 3-of-a-kind (as that would require 6+ out of 5 cards), so e[3] is either 0 or 1.
You can never have 3+ sets of 2-of-a-kind (for the same reason), so e[2] is either 0, 1 or 2.

Possibility table:
0x 3-of-a-kind1x 3-of-a-kind
0x pairhigh card3 of a kind
1x pairone pairfull house
2x pairtwo pairs(impossible)

Result table:
0x 3-of-a-kind1x 3-of-a-kind
0x pair0&0 = 00&1 = 0
1x pair1&0 = 01&1 = 1
2x pair2&0 = 02&0 = 0


This means we can safely check for a full house like so:
(e[3]&e[2])>0
, which means we can replace
e[3]==1&i==1
with
(e[3]&i)>0
, shaving another 2 bytes off, further I changed
i==1?14:i
to
i<2:14:i
because i can never be zero or negative (with valid input) - which saved a 3rd byte, as after
i=e[2]
can never be higher than 2, i can replace
i==2
with
i>1
in the array of booleans. The last value in the array
i==1
can only be reached if
i>1
is false, so
i==1
can be replaced with
i>0
, still yielding true iff i==1.

1  
2  
3  
4  
5  
6  
7  
8  
   int h(char[]g){
      int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n];int[]a=y[0],c=y[2],e=y[4];
      for(;i<13;a[" A23456789TJQK".indexOf(g[i+=2])]++,y[1][g[++i]]++);
      for(i=n;i-->0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i<2?14:i;r=r<j?r:j;s=s>j?s:j;}
      boolean v,w=q-p==4|s-r==4;for(i=n;i-->0;y[3][y[1][i]]=i,e[a[i]]++)w&=a[i]<2;v=y[3][5]>0;i=e[2];
      for(boolean h:new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&i)>0,v,w,c[3]>0,i>1,i>0}){if(h)break;n--;}
      return n;
   }

Code size: 448

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #16 - Posted 2014-03-13 23:13:36 »

Riven you're hurting my head...

Online BurntPizza
« Reply #17 - Posted 2014-03-13 23:34:30 »

Ah, well done, I haven't fully comprehended your algorithm yet, so I've only been making syntactic optimizations.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #18 - Posted 2014-03-13 23:36:15 »

Oh, I just make histograms for suits and ranks, transpose them, and compose new histograms from those Smiley ... that's what happens here
y[1][g[++i]]++
and here
y[3][y[1][i]]=i
persecutioncomplex

The straight was the hardest to calculate, due to the aces, so I kept two min/max values for its dual role:
   Range A...K:
             p=p<i?p:i;  q=q>i?q:i;

   Range 2...A:
j=i<2?14:i;  r=r<j?r:j;  s=s>j?s:j;

There is a simple check whether there *can* be a straight:
  
w=q-p==4|s-r==4;
(max distance between min and max is 5 cards -1)
Then I check that there aren't any pairs (or 2,3,4 of a kinds), which would leave holes in the range:
  
for(...)w&=a[i]<2;
I piggy-back on a loop that didn't have a body.


I started with beautiful code, that was, shall we say.... maintainable, madness ensued.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online BurntPizza
« Reply #19 - Posted 2014-03-13 23:48:16 »

When I said I was done killing cells, I lied.

'Nother 12 chars, but throws exception (still outputs correctly otherwise):

1  
2  
//for(boolean h:new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&i)>0,v,w,c[3]>0,i>1,i>0}){if(h)break;n--;}
  for(j=0;!new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&i)>0,v,w,c[3]>0,i>1,i>0}[j++];n--);
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #20 - Posted 2014-03-13 23:50:41 »

Although I admire your effort, we don't want no stinking exceptions Smiley I'll try to build on your new solution though!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #21 - Posted 2014-03-13 23:55:10 »

Great, I just had to append a dummy
true
value to the boolean[] (w is known to be false as otherwise the loop would have been escaped a few iterations earlier, so !w is true)

1  
2  
3  
//for(boolean h:new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&i)>0,v,w,c[3]>0,i>1,i>0}){if(h)break;n--;}
//for(j=0;!new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&i)>0,v,w,c[3]>0,i>1,i>0}[j++];n--);
  for(j=0;!new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&i)>0,v,w,c[3]>0,i>1,i>0,!w}[j++];n--);


1  
2  
3  
4  
5  
6  
7  
8  
   int h(char[]g){
      int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n];int[]a=y[0],c=y[2],e=y[4];
      for(;i<13;a[" A23456789TJQK".indexOf(g[i+=2])]++,y[1][g[++i]]++);
      for(i=n;i-->0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i<2?14:i;r=r<j?r:j;s=s>j?s:j;}
      boolean v,w=q-p==4|s-r==4;for(i=n;i-->0;y[3][y[1][i]]=i,e[a[i]]++)w&=a[i]<2;v=y[3][5]>0;i=e[2];
      for(j=0;!new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&i)>0,v,w,c[3]>0,i>1,i>0,!w}[j++];n--);
      return n;
   }

Code size: 439 bytes!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online BurntPizza
« Reply #22 - Posted 2014-03-13 23:59:53 »

Ah, was about to post, but you beat my patch by 1 byte  Pointing
Edit, now 2. I was looking for that.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #23 - Posted 2014-03-14 00:15:48 »

Thanks for a hilarious night Smiley For now, at 1:30AM, my humble bed beckons. Pointing

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online BurntPizza
« Reply #24 - Posted 2014-03-14 00:16:02 »

Loop rework, -3 bytes:

i just finished being a loop counter, so it's value is known.

1  
2  
3  
4  
//i=e[2];
//for(j=0;!new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&i)>0,v,w,c[3]>0,i>1,i>0,!w}[j++];n--);
  p=e[2];
  for(;!new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&p)>0,v,w,c[3]>0,p>1,p>0,!w}[++i];n--);


Edit: Yay! Achievement get: medal from Riven!
Dream of code, friend   Wink
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #25 - Posted 2014-03-14 00:23:02 »

Too easy  Kiss
1  
  for(p=e[2];!new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&p)>0,v,w,c[3]>0,p>1,p>0,!w}[++i];n--);


1  
2  
3  
4  
5  
6  
7  
8  
   int h(char[]g){
      int n=99,i=-2,j,p=n,q=-p,r=p,s=q,y[][]=new int[5][n];int[]a=y[0],c=y[2],e=y[4];
      for(;i<13;a[" A23456789TJQK".indexOf(g[i+=2])]++,y[1][g[++i]]++);
      for(i=n;i-->0;c[a[i]]=i)if(a[i]>0){p=p<i?p:i;q=q>i?q:i;j=i<2?14:i;r=r<j?r:j;s=s>j?s:j;}
      boolean v,w=q-p==4|s-r==4;for(i=n;i-->0;y[3][y[1][i]]=i,e[a[i]]++)w&=a[i]<2;v=y[3][5]>0;
      for(p=e[2];!new boolean[]{w&v&s-r<5,w&v,c[4]>0,(e[3]&p)>0,v,w,c[3]>0,p>1,p>0,!w}[++i];n--);
      return n;
   }

Code size: 435!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online BurntPizza
« Reply #26 - Posted 2014-03-14 00:23:39 »

Hah.
I too should probably sleep.
Offline ricardo
« Reply #27 - Posted 2014-03-14 01:42:10 »

O_O
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #28 - Posted 2014-10-07 07:08:01 »

Topic reopened, for the purpose of getting my ass kicked, in the hope to return the favor. Bring it on, BurntPizza!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline ra4king

JGO Kernel


Medals: 350
Projects: 3
Exp: 5 years


I'm the King!


« Reply #29 - Posted 2014-10-07 07:57:39 »

Sweet, Riven I beat your score on that FizzBuzz Code-Golf! Now to somehow figure out how to get to #1.

Never mind, I just broke the longtime scores of EVERYBODY and got a new previously-never-achieved Java score of 6.40 Grin
https://www.hackerrank.com/challenges/fizzbuzz/leaderboard/filter/language=java

Pages: [1] 2 3
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (37 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (77 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!