TinyCode competition - trial

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)

int a=0,b=0;
while ((b=in.read())>=0) {
out.write((a<33&&b>96)?b-32:b);
a=b;
}

  1. Reverse (93 bytes)

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]);

  1. 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…)

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;
    }
}

  1. ByteSwap (63 bytes)

int x;
while ((x=in.read())>0) {
  out.write(in.read());
  out.write(x);
}

  1. BarcodeReader (90 bytes)

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;
}

  1. BinaryShrink (112 bytes)

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);
}

  1. BitEncoder (62 bytes)

int a = 0,x;
while ((x = in.read()) > 0) {
  if (x > 48) a^=1;
  out.write(a+48);
}

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:


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);
}

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’… ::slight_smile:

Yeah, it’s kinda weird how creating butt-ugly code can feel so satisfying ;D

So the server went offline for good or is the project alive somewhere else? :’(

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.

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:

Looking forward to it ;D

Any day now! ;D

Sneek preview

That’s looking mighty good! :smiley:

It looks rather retro, dated, monochrome, yes, but…

the real good thing is the bytecode interpreter running
behind the scenes, it can bridge to Java, it only doesn’t
support the new keyword yet, but who needs that! :persecutioncomplex:

look nice, how doest it work ? click on compile & run but nothing happend ?

Same here, I assumed the preview was non-functional.

You assumed correctly: this is the template filled with nonsense