Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 3 4 [5] 6
  Print  
  TinyCode competition - trial  (Read 20358 times)
0 Members and 1 Guest are viewing this topic.
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #120 on: 2007-11-01 05:03:13 »

Thanks, I already thought of this one, and expected everyone would do
1  
byte[] b=new byte[99];

With a double for-loop..


Anyway, we'll see who can do it in 1 for-loop Smiley

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #121 on: 2007-11-01 05:36:11 »

http://213.247.55.3:8484/compileandrun/?assignment=reverse
(85 bytes, with 1 for-loop, very hard) Sad
(83 bytes, with 2 while-loops, extremely simple)

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Abuse

JGO Kernel
*****

Posts: 1866
Medals: 5


falling into the abyss of reality


« Reply #122 on: 2007-11-01 06:12:02 »

You've a long way to go yet!
(53 bytes)
Nothing like throwing weighted dice to make sure you win Grin

(no peeking @ the solution Riven Cool)
Games published by our own members! Go get 'em!
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #123 on: 2007-11-01 06:13:01 »

I'll behave this time... Kiss

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Abuse

JGO Kernel
*****

Posts: 1866
Medals: 5


falling into the abyss of reality


« Reply #124 on: 2007-11-01 06:15:33 »

[hint]
you don't need to declare a stack
[/hint]
 Grin
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #125 on: 2007-11-01 06:23:28 »

How many bytes?  Lips Sealed

(Should I be worrying about a StackOverflowException Wink)

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Abuse

JGO Kernel
*****

Posts: 1866
Medals: 5


falling into the abyss of reality


« Reply #126 on: 2007-11-01 06:29:24 »

How many bytes?  Lips Sealed

(Should I be worrying about a StackOverflowException Wink)

Sounds like you are on the right track Grin
I think it's a more scalable solution than one using a stack of byte[99] Wink
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #127 on: 2007-11-01 06:34:28 »

Weeee.... 53?

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline markush

Jr. Member
**

Posts: 52


Plöp!


« Reply #128 on: 2007-11-01 06:44:37 »

got 54 in reverse with a correct comparison c>-1 and 53 with the slightly incorrect one c>0

Was pretty easy to get there. Smiley
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #129 on: 2007-11-01 06:49:35 »

And here was my initial attempt:
1  
2  
3  
4  
int[] a = new int[99];
for(int o=1;o>0;)
   if((a[o++]=in.read())<0&&(o-=2)>0)
      out.write(a[o]);

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Games published by our own members! Go get 'em!
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #130 on: 2007-11-01 07:02:16 »

That's all for today, I'm going to study my exams again.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Martin Strand

Jr. Member
**

Posts: 60



« Reply #131 on: 2007-11-01 18:46:33 »

I was working on this 63 byte solution:
1  
2  
byte[] b = new byte[99];
for (int s = in.read(b); s-- > 0; out.write(b[s]));


but got 53 as soon as you mentioned StackOverflowException Smiley
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #132 on: 2007-11-04 17:53:29 »

At the moment, you can create an account and submissions will be logged to determine how many people did better than you (if any).

If you're not logged in, all your submissions will be assigned to the default anonymous user.

http://213.247.55.3:8484/compileandrun/


I made the statistics abolutely anonymous, so you only see how many people had their *best* solution better/equal/worse than you. No need to post your code again, to prove that you really got it down to so little bytes.



All I can say is, that it is a royal PITA to program a dynamic webpage in Java (without a framework).
Java is simply not suited to handle much text in your sourcecode.
I'm so fed up with Java in this project, that I'm going to convert it to PHP with a Java part that handles the compile&run part. Angry

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline timfoden

Jr. Member
**

Posts: 95



« Reply #133 on: 2007-11-05 07:25:08 »

At the moment, you can create an account and submissions will be logged to determine how many people did better than you (if any).

It's great that you've added accounts now.  Super work.

IMHO, it would be even better if you showed the best/equal/worse statistics next to the names of the challenges in the main /compileandrun/?account page.  Then you'd know instantly which ones you needed to work on to try to beat the best score.

Cheers, Tim.

Try Pipe Extreme -- can you get to the end of the pipe?
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #134 on: 2007-11-05 11:41:00 »

Good idea, I'll do this tonight, before the major overhaul of the site.

I just had my exams, but this week I'm dedicated to a project at school, so again... there is limited time to get things done.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline JuddMan

Sr. Member
**

Posts: 285


Your Ad Here


« Reply #135 on: 2007-11-16 10:06:40 »

this is pretty cool, but i am no good at optimizing. my attempt at the capitalizer was 113 bytes.
Offline erikd

JGO Kernel
*****

Posts: 2561
Medals: 7


Maximumisness


« Reply #136 on: 2007-11-16 13:06:32 »

I got 52 bytes for the BitEncoder. No idea how to optimze further...

Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #137 on: 2007-11-17 06:46:17 »

Hm... I wonder when I'll have time to finish this one.

Having two jobs and a full-time study pretty much consumes all my time Sad



Oh... ehm... I just noticed the SQL connection got a broken pipe after 1 day Smiley Gotta make it reconnect eh?


Update:
It reconnects now... I already wondered why nobody was registering accounts... I thought it was pretty much dead.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline timfoden

Jr. Member
**

Posts: 95



« Reply #138 on: 2007-11-20 03:27:57 »

Hi Riven,

It looks like the connection has gone again. Smiley

Cheers, Tim.

Try Pipe Extreme -- can you get to the end of the pipe?
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #139 on: 2007-11-21 13:25:18 »

Yeah... debugging something that happens hours later, aint much fun.

When I have time, I'll convert it all to PHP with a Java backend - as I said earlier.


It should be pretty darn easy and quick to do... but don't hold your breath.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline woogley

JGO Neuromancer
****

Posts: 1098
Medals: 5



« Reply #140 on: 2007-12-27 00:03:29 »

I know I'm late, but I just stumbled on this thread and found it very interesting.

I'm not very good at it, but I got most challenges down to a decent size..

I had a VERY hard time with the hex one.. I dont know bitwise operators very well, so if some of you could please explain your logic with the hex challenge, I would be grateful for the lesson!

here's my solutions:

1. Capitalizer (71 bytes)
1  
2  
3  
4  
5  
int a=0,b=0;
while ((b=in.read())>=0) {
out.write((a<33&&b>96)?b-32:b);
a=b;
}


2. Reverse (93 bytes)
1  
2  
3  
int b[]=new int[4<<6],l=0,x;
while ((x=in.read())>=0)b[l++]=x;
for (x=l-1;x>=0;x--)out.write(b[x]);


3. Hex (231 bytes)
(note: for those who are curious about the 4<<6, that's just a cheap way to get a 4-digit-sized buffer (at the time I didn't know the scenarios were not dynamic..)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
int b[] = new int[4<<6];
int x,l = 0,y = 0;
while ((x = in.read()) >= 0) b[l++] = x;
for (x = 0;x < l;x++) {
    if (b[x] >= 48 && b[x] <= 57) {
      if ((x+1)%2 == 0) y+=b[x]-48;
      else y = b[x]-48<<4;
    }
    else {
      if ((x+1)%2 == 0) y+=b[x]-87;
      else y+=b[x]-87<<4;
    }
    if ((x+1)%2 == 0) {
      out.write(y);
      y = 0;
    }
}


4. ByteSwap (63 bytes)
1  
2  
3  
4  
5  
int x;
while ((x=in.read())>0) {
  out.write(in.read());
  out.write(x);
}


5. BarcodeReader (90 bytes)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
int c = 48,x = 0;
while (x > -2) {
  x = in.read();
  if (x == 32 ^ x < 0) {
    out.write(c);
    c = 48;
  }
  else c++;
  if (x < 0) x = -2;
}


6. BinaryShrink (112 bytes)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
int x,y,z;
while ((x = in.read()) >= 0) {
  y = 7;
  z = 0;
  do {
    z+=(1<<(y--))*(x-48);
    if (y >= 0) x = in.read();
  } while (y >= 0);
  out.write(z);
}


7. BitEncoder (62 bytes)
1  
2  
3  
4  
5  
int a = 0,x;
while ((x = in.read()) > 0) {
  if (x > 48) a^=1;
  out.write(a+48);
}
Offline woogley

JGO Neuromancer
****

Posts: 1098
Medals: 5



« Reply #141 on: 2007-12-27 00:48:34 »

ok, I managed to get my hex solution down to 133 bytes, but I'm still baffled as to how the rest of you did it:

1  
2  
3  
4  
5  
6  
7  
8  
9  
int x,y,z = 1;
while (z > 0) {
  y = 0;
  for (x = 0;x < 2;x++) {
    if ((z = in.read()) < 58) y+=(x>0?z-48:z-48<<4);
    else y+=(x>0?z-87:z-87<<4);
  }
  if (y > 0) out.write(y);
}
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #142 on: 2007-12-27 02:08:19 »

Nice tries! A bit large answers, but at least your code is butt-ugly, which is what this contest is all about Wink

If only I had some free time to build this into a proper 'service'... Roll Eyes

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline erikd

JGO Kernel
*****

Posts: 2561
Medals: 7


Maximumisness


« Reply #143 on: 2007-12-27 11:57:26 »

Yeah, it's kinda weird how creating butt-ugly code can feel so satisfying  Grin

Offline noblemaster

JGO Ninja
***

Posts: 730
Medals: 6


Age of Conquest makes your day!


« Reply #144 on: 2009-10-19 20:44:59 »

So the server went offline for good or is the project alive somewhere else?  Cry

Also, was the server even been hacked or did your code successfully prevent that?

Offline Abuse

JGO Kernel
*****

Posts: 1866
Medals: 5


falling into the abyss of reality


« Reply #145 on: 2009-10-19 22:46:34 »

So the server went offline for good or is the project alive somewhere else?  Cry

Also, was the server even been hacked or did your code successfully prevent that?

Nice resurrection =>
Nothing like bringing back fond memories from almost 2 years ago.
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #146 on: 2009-10-20 03:55:28 »

Believe it or not, it never left my mind! I've been trying to find the time to make a proper implementation. It's way too much fun!

It's not too hard to code it, but coding the whole user-interface and what-not is boring and timeconsuming.

Give me a few more weeks Wink

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline noblemaster

JGO Ninja
***

Posts: 730
Medals: 6


Age of Conquest makes your day!


« Reply #147 on: 2009-10-20 04:49:44 »

Looking forward to it  Grin

Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #148 on: 2010-04-15 13:55:28 »

Any day now! Grin

Sneek preview

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #149 on: 2010-04-15 14:16:36 »

That's looking mighty good! Cheesy

Play Minecraft!
Pages: 1 ... 3 4 [5] 6
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.179 seconds with 20 queries.