Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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 [4] 5 6
  ignore  |  Print  
  TinyCode competition - trial  (Read 28318 times)
0 Members and 1 Guest are viewing this topic.
Offline noblemaster

« JGO Spiffy Duke »


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #90 - Posted 2007-10-30 02:59:47 »

mhh, what about floating point numbers? 1.0, 0.34...

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #91 - Posted 2007-10-30 03:02:09 »

Using a sandbox should have done the trick as well, no?

弾幕 ☆ @mahonnaiseblog
Offline markush

Senior Newbie




Plöp!


« Reply #92 - Posted 2007-10-30 08:23:03 »

Barcode 64 bytes:

1  
2  
3  
4  
5  
for(int c=1,i=48;c>0;i++)
  if((c=in.read())<99){
    out.write(i);
    i=47;
  }


Sometimes you need to take some time off, to see the simple optimizations Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #93 - Posted 2007-10-30 09:26:02 »

This is fun  Cheesy
But it's too easy to cheat, ie. optimizing just for the test case while breaking the algorithm.

Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #94 - Posted 2007-10-30 09:32:46 »

Tonight I'll expend the number of testcases from 1 to N (where N >= 1)

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #95 - Posted 2007-10-30 10:34:34 »

I believe there is now a new way of crashing the server - I'll see if I can verify this @ lunchtime.

If so, I'll let you know via pm Riven  Cheesy

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Online Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #96 - Posted 2007-10-30 13:39:40 »

I believe there is now a new way of crashing the server - I'll see if I can verify this @ lunchtime.

If so, I'll let you know via pm Riven  Cheesy

No joy yet... but I'm very close.

More worryingly, if successful it will give the capability to execute arbitrary code, essentially giving almost complete control over the machine on-which the server is running  - limited only by the user level security offered by the OS.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #97 - Posted 2007-10-30 15:01:30 »

I'm very interested.

I bet it is solvable by removing the support for uppercase characters again..?

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #98 - Posted 2007-10-30 15:48:43 »

Here is what I have so far :-

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
      final Class c = new ClassLoader() {
         public Class read() {
           
            byte [] classData =
               new byte[] {-54,-2,-70,-66,0,0,0,46,0,41,7,0,2,1,0,4,66,108,97,104,7,0,4,1,0,16,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,1,0,6,99,104,101,101,115,101,1,0,1,68,1,0,8,60,99,108,105,110,105,116,62,1,0,3,40,41,86,1,0,4,67,111,100,101,9,0,11,0,13,7,0,12,1,0,16,106,97,118,97,47,108,97,110,103,47,83,121,115,116,101,109,12,0,14,0,15,1,0,3,111,117,116,1,0,21,76,106,97,118,97,47,105,111,47,80,114,105,110,116,83,116,114,101,97,109,59,8,0,17,1,0,11,105,110,105,116,105,97,108,105,115,101,100,10,0,19,0,21,7,0,20,1,0,19,106,97,118,97,47,105,111,47,80,114,105,110,116,83,116,114,101,97,109,12,0,22,0,23,1,0,7,112,114,105,110,116,108,110,1,0,21,40,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,41,86,10,0,25,0,27,7,0,26,1,0,14,106,97,118,97,47,108,97,110,103,47,77,97,116,104,12,0,28,0,29,1,0,6,114,97,110,100,111,109,1,0,3,40,41,68,9,0,1,0,31,12,0,5,0,6,1,0,15,76,105,110,101,78,117,109,98,101,114,84,97,98,108,101,1,0,18,76,111,99,97,108,86,97,114,105,97,98,108,101,84,97,98,108,101,1,0,6,60,105,110,105,116,62,10,0,3,0,36,12,0,34,0,8,1,0,4,116,104,105,115,1,0,6,76,66,108,97,104,59,1,0,10,83,111,117,114,99,101,70,105,108,101,1,0,9,66,108,97,104,46,106,97,118,97,0,33,0,1,0,3,0,0,0,1,0,25,0,5,0,6,0,0,0,2,0,8,0,7,0,8,0,1,0,9,0,0,0,55,0,2,0,0,0,0,0,15,-78,0,10,18,16,-74,0,18,-72,0,24,-77,0,30,-79,0,0,0,2,0,32,0,0,0,14,0,3,0,0,0,4,0,8,0,6,0,14,0,2,0,33,0,0,0,2,0,0,0,1,0,34,0,8,0,1,0,9,0,0,0,47,0,1,0,1,0,0,0,5,42,-73,0,35,-79,0,0,0,2,0,32,0,0,0,6,0,1,0,0,0,2,0,33,0,0,0,12,0,1,0,0,0,5,0,37,0,38,0,0,0,1,0,39,0,0,0,2,0,40};              
         
            Class c = defineClass("Blah", classData, 0, classData.length);
           
            resolveClass(c);
            return c;
         }
      }.read();

      // TODO: Find some api operation that causes the static initialiser of Class c to be invoked.
      // Complication:  The api operation must be defined in a public non-final class in the java.lang package.
      // I have yet to find a way of achieving this :-(


I'm hoping java.lang.SecurityManager holds the key..... as there is little else of use in the java.lang package.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #99 - Posted 2007-10-30 16:42:35 »

Thanks for your hack-skills, i bet there is a huge security hole here.

As you posted this here, I'll take down my server and fix it later tonight.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #100 - Posted 2007-10-30 16:52:20 »

I think that if you'd add forName("Blah"), the static initializer would have been executed...?

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #101 - Posted 2007-10-30 17:41:40 »

I think that if you'd add forName("Blah"), the static initializer would have been executed...?

forName is a method in Class, not ClassLoader.
And as Class is declared final, I cannot access the method as a sub-class (to avoid usage of the dot operator)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Online Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #102 - Posted 2007-10-30 18:55:42 »

Nope, looks like you were safe afterall, I can't find a way of executing the class initialiser of a class constructed through Reflection without using the dot operator.

The only security hole exposed through ClassLoader is that you can get an InputStream to any file on the classpath.
So in theory we could of grabbed the class files of the application, piped them to the OutputStream you provide us in the method parameter, resulting in the class file contents being piped back to us as the contents of the web page.
I suppose decompiling the resultant files might have allowed us to find an exploit in your app....

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #103 - Posted 2007-10-31 13:36:30 »

I still think there is a loophole to be found with overriding toString() (as that doesn't require the explicit method-invocation) with a body containing System.exit(0); in bytecode.

If you can grab an instance of the produced class, or can run the static initializer, it's pretty much overtaken.

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #104 - Posted 2007-10-31 15:12:56 »

You should leave it up!
Consider it the the 'out of the (sand)box' coding exercise Grin

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #105 - Posted 2007-10-31 15:43:47 »

If it was my own server... yes, but I'm renting this one, and I just paid 250 euro, and I don't want to get my account suspended.

Further, a company is dependant (critically) on a MySQL database on it.



And... I don't have much time to fix it, with my examns this week.

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

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #106 - Posted 2007-10-31 22:08:29 »

I fixed the security holes... until somebody finds some class that has a static method named read or write, that has some funny sideeffect.


And another one...

http://213.247.55.3:8484/compileandrun/?assignment=encoder
This one could get extremely small.

(48 bytes)
(46 bytes)
(45 bytes)

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #107 - Posted 2007-10-31 22:49:23 »

48,47,46  Cry

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #108 - Posted 2007-10-31 22:55:59 »

I watched you in SSH, and you're so damn near the answer...


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

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #109 - Posted 2007-10-31 22:58:40 »

you need to remember the behaviour of modulo with negative values

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #110 - Posted 2007-10-31 23:22:42 »

45!, Got there in the end  Grin

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #111 - Posted 2007-10-31 23:28:04 »

Great, you (??) caused a few (harmless) ArithmeticExceptions and NullPointerExceptions on the way  to it Smiley

I passed the getMessage() to the client now.

I only saw those that threw errors, and if your last is like that, you got a completely different solution than I came up with..

1  
for(int b=48;(b^=in.read()%2)>0;out.write(b));

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #112 - Posted 2007-10-31 23:31:13 »

yup, that's what I got to in the end.

While I wouldn't stake my life on it, it looks pretty much like the optimal solution...

p.s.

I don't think I was the cause of the exceptions - I do all my testing in Eclipse, only use the submission page to check the size.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #113 - Posted 2007-10-31 23:34:44 »

I see somebody doing extremely clever stuff at the server now, and he keeps getting stuck at 46 bytes.... it's a bit unfair, really

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #114 - Posted 2007-10-31 23:39:54 »

Are you using the same class for defining the assignments?

I have an idea for one :-P

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #115 - Posted 2007-10-31 23:41:01 »

Yup, I posted the code, and nothing changed yet.


Gimme gimme!

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

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #116 - Posted 2007-10-31 23:45:11 »

To be honest, I exp[ected more people to join in... this competition is being played by roughly 5 people Smiley


But well, once the assignments get thougher, and the website has user-accounts, things might become better.

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

Junior Devvie





« Reply #117 - Posted 2007-10-31 23:50:16 »

aargh, I give up!  Cheesy I got two similar 46 byte solutions:
1  
2  
3  
4  
5  
for (
int i = 0;
(i ^= in.read()) >= 0;
out.write(48|i)
);


1  
2  
3  
4  
5  
for (
int i = 48;
(i ^= in.read() & 3) < 50;
out.write(i)
);


Martin
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 840
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #118 - Posted 2007-10-31 23:53:34 »

I witnessed your suffering.

You got two great solutions!

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

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #119 - Posted 2007-11-01 00:34:54 »

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  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;


public class ReverseStream extends TinyCodeAssignment {

   public byte[] createQuestion() {
      return str2arr("stun slap swang god . burg slipup stool ergo trams");
   }

   public String getDefaultSource() {
      StringBuilder sb = new StringBuilder();
     
      sb.append("byte [] buffer = new byte[4];\n");
      sb.append("int len = 0;\n");
      sb.append("int b;\n");
      sb.append("while((b=in.read())>=0) {\n");
      sb.append("   buffer[len++] = (byte)b;\n");        
      sb.append("   if(len==buffer.length) {\n");
      sb.append("      byte [] newBuffer = new byte[len*2];\n");
      sb.append("      for(int i = 0;i < len;i++) {\n");
      sb.append("         newBuffer[i] = buffer[i];\n");
      sb.append("      }\n");
      sb.append("      buffer = newBuffer;\n");
      sb.append("   }\n");
      sb.append("}\n\n");
      sb.append("for(int i = len-1;i>=0; i--) {\n");
      sb.append("   out.write(buffer[i]);\n");
      sb.append("}");
     
      return sb.toString();
   }

   public String getDescription() {
      return "Reverse the order of the stream";
   }

   public String getExample() {
      return "ABCD -> DCBA";
   }

   public String getName() {
      return "reverse";
   }

   public String getTitle() {
      return "Reverse";
   }

   public void processCorrectly(InputStream in, OutputStream out)
         throws IOException {
      byte [] buffer = new byte[4];
      int len = 0;
      int b;
      while((b=in.read())>=0) {
         buffer[len++] = (byte)b;        
         if(len==buffer.length) {
            byte [] newBuffer = new byte[len*2];
            for(int i = 0;i < len;i++) {
               newBuffer[i] = buffer[i];
            }
            buffer = newBuffer;
         }
      }
     
      for(int i = len-1;i>=0; i--) {
         out.write(buffer[i]);
      }  
   }
}

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Pages: 1 2 3 [4] 5 6
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (103 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

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
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!