Author Topic: [ENDED] Code Golf Contest #2  (Read 17038 times)

0 Members and 3 Guests are viewing this topic.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Code Golf Contest #2
« Reply #15 on: July 27, 2014, 01:16:33 pm »
Welcome to the forums! You somehow remind me of the guy who registered and made a new topic just so he could get a solution to a level in Portal Prelude. XD

Anyways, so yeah, unless you post 4 more times AND PM me your solutions by the end of the day, I'll PM you with my email.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline 3298

  • LV2 Member (Next: 40)
  • **
  • Posts: 26
  • Rating: +1/-0
    • View Profile
Re: Code Golf Contest #2
« Reply #16 on: July 27, 2014, 01:19:53 pm »
Thanks for the welcome messages! I have written a few posts on the UCF and the recently closed DCF in the last few years, and I saw some of DJ's old posts on the UCF. And before the CasioScene drama happened I was a registered user at CasioKingdom. The restore to an old backup over there removed all evidence of that, but I won't go back there because it's become a toyland for spambots.
The permissions seem a bit screwed up, because I tried the test message you suggested, and it actually worked. I understand why this limit is in place (look at CasioKingdom to see what happens without such protection), and I think someone should enforce what that post in the news section says. I can only assume this no-PM rule has been softened, because I had to solve a captcha like at my registration. (Not a problem for a human, though.)
So with the PM way apparently working, I'll use it.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Code Golf Contest #2
« Reply #17 on: July 27, 2014, 04:42:44 pm »
That was the LONGEST update I've ever had to do. O.O But I did it! :thumbsup:
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Code Golf Contest #2
« Reply #18 on: July 27, 2014, 04:45:28 pm »
Thanks for the welcome messages! I have written a few posts on the UCF and the recently closed DCF in the last few years, and I saw some of DJ's old posts on the UCF. And before the CasioScene drama happened I was a registered user at CasioKingdom. The restore to an old backup over there removed all evidence of that, but I won't go back there because it's become a toyland for spambots.
The permissions seem a bit screwed up, because I tried the test message you suggested, and it actually worked. I understand why this limit is in place (look at CasioKingdom to see what happens without such protection), and I think someone should enforce what that post in the news section says. I can only assume this no-PM rule has been softened, because I had to solve a captcha like at my registration. (Not a problem for a human, though.)
So with the PM way apparently working, I'll use it.
Yeah I wish that CK forums owners added more anti-spams on the site after the restoral. It was old but it had lots of useful info. I guess for Omni the permissions were messed up in the upgrade we also had a few months ago. Admins will probably re-instate the post limit if more bots come in here, but let's hope the bots won't do so.

Also I didn't know that DCF closed, that sucks D:

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Code Golf Contest #2
« Reply #19 on: July 27, 2014, 10:12:24 pm »
Quickly quickly quickly! Submit your final entries by the end of the night! Also, any winners, think of challenges for our next contest!
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Code Golf Contest #2
« Reply #20 on: July 28, 2014, 01:19:04 am »
Here's my suggestion for the next challenge:

Input: a positive integer of reasonable size
Output: The highest prime factor of that integer, in binary, but with all 0s replaced with underscores (_) and all 1s replaced with minus signs (-)

Example:
Input: 15
Output: -_-

Example:
Input: 7
Output: ---

Example:
Input: 115
Output: -_---

Offline Princetonlion.tibd

  • Members
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 790
  • Rating: +3/-4
    • View Profile
Re: Code Golf Contest #2
« Reply #21 on: July 28, 2014, 08:29:53 am »
I don't think there are underscores in TI BASIC, but I'll try if you win

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Code Golf Contest #2
« Reply #22 on: July 28, 2014, 12:04:31 pm »
Here's my suggestion for the next challenge:

Input: a positive integer of reasonable size
Output: The highest prime factor of that integer, in binary, but with all 0s replaced with underscores (_) and all 1s replaced with minus signs (-)

Example:
Input: 15
Output: -_-

Example:
Input: 7
Output: ---

Example:
Input: 115
Output: -_---

This is the kind of creatively new yet simple challenge that I wish I could think of. :P

I don't think there are underscores in TI BASIC, but I'll try if you win

There is an underscore token, although it's not typeable on a calculator through normal means. It's two-byte code is BBD9. It could be entered either in a computer tokenizer or perhaps produced by an on-calc tool made for producing untypeable characters, like this.
« Last Edit: July 28, 2014, 12:07:43 pm by Runer112 »

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Code Golf Contest #2
« Reply #23 on: July 28, 2014, 01:07:22 pm »
Interesting. I like it! :thumbsup:

Now here's my TI-BASIC solution for contest #2 in 201 bytes:
Code: [Select]
:Input Str1
:DelVar CDelVar X" →Str2
:Repeat not(B
:X+1→X
:0→M
:For(N,1,X
:Ans+1→A
:inString(Str1," ",Ans→B
:End
:If not(Ans
:1+length(Str1
:sub(Str1,A,Ans-A
:For(L,1,length(Ans
:If inString("0123456789",sub(Ans,L,1
:IS>(M,M
:
:End
:If M=length(Ans
:Then
:C+expr(Ans→C
:Else
:Ans+" "+Str2→Str2
:End
:End
:ClrHome
:Output(1,1,Str2
:length(Str2)/16
:Output(int(Ans)+not(int(Ans)),16fPart(Ans)+16not(fPart(Ans)),C
« Last Edit: July 28, 2014, 02:04:40 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline 3298

  • LV2 Member (Next: 40)
  • **
  • Posts: 26
  • Rating: +1/-0
    • View Profile
Re: Code Golf Contest #2
« Reply #24 on: July 28, 2014, 02:51:23 pm »
Looking over the solutions, I noticed that the shortest Java version does not process one string, but instead assumes someone has split it already and put the parts into the command-line parameters array before the program starts. On the other hand, it shows how my solution could be shortened further (println ->print, and I could have omitted curly braces around the body of the for loop).
Edit: And that version apparently has a bug, it prints the entire array when it failed to parse one element to an integer. There are three characters missing (a+' ' should be a+' '). Due to the size being 171 instead of 174, they apparently got lost somewhere between size measurement and code posting.

I assume there are some languages with an advantage for the new challenge above. If you have a CAS-equipped calculator, the factorization is as simple as a function call, on most other languages you'll have to implement it yourself. Though such a discrimination is hard to avoid.
Luckily the 50G has a CAS, so I already have a 57-byte SysRPL solution. ;D The other languages I used will be a bit harder.
« Last Edit: July 28, 2014, 03:02:58 pm by 3298 »

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Code Golf Contest #2
« Reply #25 on: July 28, 2014, 03:05:13 pm »
Looking over the solutions, I noticed that the shortest Java version does not process one string, but instead assumes someone has split it already
That's because java automatically splits the input, as long as the input string is not surrounded by quotes.

By the way, I had a smaller version, but I have been quite busy with other projects and I forgot to submit that one. Anyway, here was that code (169 bytes):
Code: [Select]
class C{public static void main(String[] a){String s="";int i=0;for(String t:a){try{i+=Integer.parseInt(t);}catch(Exception e){s=t+" "+s;}}s+=i;System.out.println(s);}}
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline 3298

  • LV2 Member (Next: 40)
  • **
  • Posts: 26
  • Rating: +1/-0
    • View Profile
Re: Code Golf Contest #2
« Reply #26 on: July 28, 2014, 03:21:23 pm »
Okay, challenge accepted, I'm going to cut that one down.
Code: [Select]
String[] aDrop the space, 1 byte saved.
Code: [Select]
for(String t:a){...}Drop the curly braces, 2 more bytes down (I just saw that in my submission as well). Your other solution already has that.
Code: [Select]
s+=i;System.out.println(s);Two things here: Drop the ln (like in your submission), 2 bytes saved. The concatenation of string and number can be done inside the parentheses of the print, saving 3 more bytes.
Total improvement: 8 bytes, so the size is 161 now. :thumbsup:

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Code Golf Contest #2
« Reply #27 on: July 28, 2014, 03:31:27 pm »
New contest is underway!

Please move any and all discussion on code golfing here.

I already have a solution in TI-BASIC that is 122 bytes large. Who can do better?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Code Golf Contest #2
« Reply #28 on: July 29, 2014, 02:13:06 am »
Welp, I just learned I could cut out 4 bytes in my Ruby entry by shortening "print" with "p" o.o

Welp, now I know.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.