Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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 27592 times)
0 Members and 1 Guest are viewing this topic.
Offline SimonH
« Reply #60 - Posted 2007-10-29 02:01:10 »

Tomorrow = exams

Good luck - but hopefully you won't need it!

People make games and games make people
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #61 - Posted 2007-10-29 03:40:17 »

Can anyone tell me why my read pointer is not advancing?
1  
2  
3  
4  
for(int a=in.read(),b=in.read();(a|b)>0;){
    out.write(b);
    out.write(a);
}


Whenever I run this, it just goes into an infinite loop.  When I debug it, a and b keep reading the first 2 characters from the stream.

Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #62 - Posted 2007-10-29 06:00:56 »

Consider: for(<part1>;<part2>;<part3>)...

<part1> is only executed ONCE and the beginning of the loop to initialize variables etc...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #63 - Posted 2007-10-29 09:58:42 »

Ouch...  Wink

Two new assignments:
http://213.247.55.3:8484/compileandrun/?assignment=capitalizer
http://213.247.55.3:8484/compileandrun/?assignment=barcode




I made the barcode assignment extra hard by not adding a space at the end.

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

Senior Newbie




Plöp!


« Reply #64 - Posted 2007-10-29 10:30:06 »


85 bytes for capitalizer, but that has to go shorter...
there are 3 variables in there...
who needs 3 variables anyway? Smiley

1  
2  
for(int c,i=0,s=0; (c=in.read())>0 ; out.write(c-(i++==s & c > 96 & c < 123?32:0)))
      s =c == 32 ? i+1 : s;


for the barcode thingy 89 bytes

1  
2  
3  
4  
int i,c;
for(i=48;(c=in.read())>0;i=c==32?48:i+1)
   if(c==32)out.write(i);
if(i>0)out.write(i);


So lets start that shortening iteration again Smiley

Edit:
capitalizer down to 7170:
1  
2  
for(int c,s=32; (c=in.read())>0;)
   out.write(s=c-(s==32 & c > 96 & c < 123?32:0));


barcode down to 66 bytes:
1  
2  
3  
4  
5  
6  
7  
for(int c=1,i=48;c>0;i++){
  c=in.read();
  if(c<99){
    out.write(i);
    i=47;
  }
}
Online Riven
« League of Dukes »

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #65 - Posted 2007-10-29 12:01:44 »

Capitalizer:
1  
2  
for(int c,s=32; (c=in.read())>0;)
out.write(s=s==c/96*32?c-s:c);

(61 bytes)

This was optimisation on the logic-level.
It didn't have anything to do with reasoning.

...

I have yet to figure out how it works..


Thanks markush, for the jump-start.

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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #66 - Posted 2007-10-29 12:11:43 »

We need another operator eh?

1  
2  
s=s*3          --->>> s*=3;
s=s==3?4:5;    --->>> s===3?4:5;

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

Junior Member


Projects: 2



« Reply #67 - Posted 2007-10-29 12:28:32 »

Capitalizer:
1  
2  
for(int c,s=32; (c=in.read())>0;)
out.write(s=s==c/96*32?c-s:c);

(61 bytes)

The above code works with the test case, but IMO doesn't solve the spirit of the problem in all cases. Smiley

Try it with a test case that includes the end conditions: e.g.

"@ 2pm { today }, I saw a bear at the zoo "

The above code would change the @ { } chars.

Here's my current go @ Capitalizer:
1  
2  
for(int c, p = 32; (c = in.read()) > 0; )
 out.write( p = p == 32 & c > 96 & c < 123 ? c - p : c );

(67 bytes)

Cheers, Tim.

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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #68 - Posted 2007-10-29 12:31:34 »

Yeah, I cheated. I removed the upper-bound check.

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

Junior Member


Projects: 2



« Reply #69 - Posted 2007-10-29 12:38:35 »

Yeah, I cheated. I removed the upper-bound check.

Yes...  and the lower bound check is wrong... should be /97

Try Pipe Extreme -- can you get to the end of the pipe?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #70 - Posted 2007-10-29 12:46:07 »

I'll cry myself to sleep tonight. Embarrassed

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

Junior Member


Projects: 2



« Reply #71 - Posted 2007-10-29 14:30:14 »

BinaryShrink
1  
2  
3  
4  
5  
6  
for( int v = 1; (v += v + in.read() % 2) > 1; )
  if( v > 255 )
  {
    out.write( v );
    v = 1;
  }

(61 bytes)

Try Pipe Extreme -- can you get to the end of the pipe?
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #72 - Posted 2007-10-29 14:43:21 »

Consider: for(<part1>;<part2>;<part3>)...

<part1> is only executed ONCE and the beginning of the loop to initialize variables etc...

doh  Embarrassed

Thanks.

Offline Mr_Light

Senior Member




shiny.


« Reply #73 - Posted 2007-10-29 18:35:28 »

barcode down to 66 bytes:
1  
2  
3  
4  
5  
6  
7  
for(int c=1,i=48;c>0;i++){
  c=in.read();
  if(c<99){
    out.write(i);
    i=47;
  }
}

67 bytes:
1  
out.write(new byte[] { 50,51,56,49,52,57,54,50,51,49,49,50,48,49,51 });

 Wink

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Online Riven
« League of Dukes »

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #74 - Posted 2007-10-29 20:30:12 »

I'll add a bunch of testcases to each assignment, when I have time for it.

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

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #75 - Posted 2007-10-30 00:27:20 »

hey Riven, I killed your server  Grin

1  
com.sun.org.apache.regexp.internal.recompile.main("".split(""));

(64 bytes)

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

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #76 - Posted 2007-10-30 00:44:03 »

 Grin

Online Riven
« League of Dukes »

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #77 - Posted 2007-10-30 01:24:44 »

WHAAAA

It was worse than you might every have thought...


There was a piece of user-submitted sourcecode processed by BASH... Shocked Shocked Shocked

That's like total control...


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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #78 - Posted 2007-10-30 01:29:01 »

I'm not going to launch the http-server until I fixed this...


Hm... there is a System.exit(0) inside that method...

I really can't understand how that System.out (!!!) could end up in bash.

I mean... after System.exit(0) is called, the JVM is supposed to be dead, and everything that was buffered in System.out should be discarded, not writting into STDIN...

Anybody?

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

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #79 - Posted 2007-10-30 01:43:12 »

yeah, it was the System.exit(0); that I was exploiting to terminate the vm....
Took me ages to think of a way to pass in a String[], to get the desired effect :-)

What was it that was written to stdin?
the socket input stream? or system.out?

Can you reproduce it?

Seems like a serious vm bug to me, it isn't like my code did anything that a normal java service couldn't do as the result of some kind of unrecoverable error.
Presumably it's the result of a thread race condition, as I guess our provided code is executing on it's own thread?

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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #80 - Posted 2007-10-30 02:00:35 »

User-sourcecode is compiled by janino.

The compiled sourcecode cannot be sent to STDIN, because it only exists in bytecode-form.

I do a
System.out.println(code);
to monitor the submission you guys post.

Unfortunately, to enforce the time-limit of 100ms, I have to call Thread.stop() if the newly created thread running your code, runs out of time.
Now... before I even can call stop(), the System.exit(0) is already executed, so I doubt the problem is in that 'unsafe' method.

It feels like this was the actual chain of events:
1. System.out.println(code);
2. new Thread(){public void run(){System.exit(0);}}.start();

Result:
the bytes buffered in STDOUT get flushed to STDIN after termination.


Is it correct that you submitted this full block of code?
1  
2  
3  
4  
5  
6  
7  
com.sun.org.apache.regexp.internal.recompile.main("".split(""));
out.write(str2arr("hello world!"));
int a=0,i=0,b;
while((b=in.read())>0) {
a=a<<4|(b-'0');
if ((i^=1)==0) out.write(a);
}

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

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #81 - Posted 2007-10-30 02:04:55 »

nope, I only submitted

"com.sun.org.apache.regexp.internal.recompile.main("".split(""));"

The rest is nothing to do with me, never seen it before in my life.
"byte [] str2arr(String)" is one of your methods isn't it? declared in TinyCodeAssignment.
Was that just someone attempting to access this method from their own code?

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

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #82 - Posted 2007-10-30 02:06:57 »

The compiled sourcecode cannot be sent to STDIN, because it only exists in bytecode-form.

I was thinking more of the source code that is embedded in the html page served back to the client?

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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #83 - Posted 2007-10-30 02:07:10 »

It was part of the sourcecode I posted in this thread (many many lines).


Somebody thought he could access the str2arr or arr2str because it was defined in the posted TinyCodeAssignment class.

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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #84 - Posted 2007-10-30 02:09:23 »

The code sent back to the client doesn't have < and >, only &lt; and &gt; to prevent HTML-tags (and scripts!) breaking out of the <textarea></textarea>

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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #85 - Posted 2007-10-30 02:12:45 »

Anyway, as you can see in the screenshot, the JVM is shutdown after your one-line submission, yet the next (?) submission is executed in BASH...


I'll investigate tomorrow, and go to bed now. It's 02:00, and I got yet another exam tomorrow.

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

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #86 - Posted 2007-10-30 02:25:42 »

Eagerly awaiting my gold 'I crashed the server' badge  Grin

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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #87 - Posted 2007-10-30 02:31:53 »

Bah, I didn't go to bed! Lips Sealed


I found it...

it wasn't that spooky. If you type something in Bash, while a program is running, it's sent to STDIN.
If you type CTRL-C, the bytes in System.in are discarded.
If System.exit(0) is invoked, the bytes in System.in are passed to STDIN of Bash (as in: if the child-process doesn't handle it, the parent process will)

So... it turned out I probably pasted that code accidently yesterday, and never noticed.


(...working on the badge)

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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #88 - Posted 2007-10-30 02:53:44 »


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

JGO Overlord


Medals: 751
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #89 - Posted 2007-10-30 03:33:26 »

I'm hosting it again, now allowing uppercase characters, but no unicode.

It only allows a "." if it is followed by "read(" or "write(".

I think this should catch all random acts of vandalism Smiley


Please report exploits... in private-mail on jgo

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!