Author Topic: [ENDED] Code Golf Contest #8  (Read 9007 times)

0 Members and 1 Guest 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
[ENDED] Code Golf Contest #8
« on: September 01, 2014, 11:56:35 am »
This challenge should confuse some people.

NEXT: Here
PREVIOUS: Here

Challenge 8

Problem

Check if a string is conveniently palindromic, and output 1 if it is and 0 if it isn't. This means that the char pairs () {} [] <> should be handled such that strings such as
Code: [Select]
(<)i(>)
<}<{}>{>
][()][
}{[]}{
would return 1, and strings like
Code: [Select]
())(
<(){}[][}{)(<
(({))
<<
would return 0.
Case insensitive when possible.

Deadline
September 8, 2014, 1:00 AM EST

If any further clarification is needed, contact me. I'll try not to get everything backwards for you. (*crickets* Seriously, nothing? :/ )

Golfscript
RankUserSizeDateCode
1JWinslow23689/1/2014 2:39:28 PM
Spoiler For Spoiler:
{.96>32*-}/]''+.['()''{}''[]''<>']{.(;\);@1$/"\0"*2$/\*"\0"/\*}/-1%=

Ruby2
RankUserSizeDateCode
1Juju639/1/2014 2:59:26 PM
Spoiler For Spoiler:
p (a=gets.chop.upcase)==a.reverse.tr("[{(<>)}]","]})><({[")?1:0

TI-83+ BASIC
RankUserSizeDateCode
1JWinslow231779/2/2014 5:43:43 PM
Spoiler For Spoiler:
" "+Ans+" ->Str1
Ans->Str3
"({[<)}]>->Str2
For(X,1,length(Str1
For(Y,1,4
sub(Str1,X,1
5(Ans=sub(Str2,Y,1))+(Ans=sub(Str2,Y+4,1
If Ans
sub(Str1,1,X-1)+sub(Str2,Y+Ans-1,1)+sub(Str1,X+1,length(Str1)-X->Str1
End
End
Str1
For(X,1,length(Ans)-1
sub(Ans,2X,1)+Ans
End
Str3=sub(Ans,1,X

Nspire Lua
RankUserSizeDateCode
1Jens_K1459/4/2014 4:52:18 PM
Spoiler For Spoiler:
function cgc8(s)
R=1
r="<>()[]{}/\\"l=s:len()for i=1,l do
p=r:find(s:sub(i,i),1,1)or 0
p=p+p%2*2-1
q=l-i+1
R=p>0 and r:sub(p,p)~=s:sub(q,q)and 0 or R
end
print(R)
end

Language Ranking
RankLangUserSizeDate
1Ruby2Juju639/1/2014 2:59:26 PM
2GolfscriptJWinslow23689/1/2014 2:39:28 PM
3Nspire LuaJens_K1459/4/2014 4:52:18 PM
4TI-83+ BASICJWinslow231779/2/2014 5:43:43 PM
« Last Edit: June 11, 2015, 08:57:37 am by pimathbrainiac »
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 #8
« Reply #1 on: September 01, 2014, 11:59:06 am »
This one should be interesting. Also, 52 bytes.

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.

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: Code Golf Contest #8
« Reply #2 on: September 01, 2014, 12:19:06 pm »
If any further clarification is needed, contact me. I'll try not to get everything backwards for you. (*crickets* Seriously, nothing? :-\ )
I liked it! ;)

Quick question - is this case sensitive or insensitive?
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline Princetonlion.tibd

  • Members
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 790
  • Rating: +3/-4
    • View Profile
Re: Code Golf Contest #8
« Reply #3 on: September 01, 2014, 12:21:19 pm »
I think I can do this :D
68k BASIC.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Code Golf Contest #8
« Reply #4 on: September 01, 2014, 12:22:42 pm »
If any further clarification is needed, contact me. I'll try not to get everything backwards for you. (*crickets* Seriously, nothing? :/ )
I liked it! ;)

Quick question - is this case sensitive or insensitive?

On a related note, are we supposed to handle characters that aren't parentheses/brackets, and if so, do those also have to produce a palindrome?

For example, (b]o[b)
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Princetonlion.tibd

  • Members
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 790
  • Rating: +3/-4
    • View Profile
Re: Code Golf Contest #8
« Reply #5 on: September 01, 2014, 12:24:54 pm »
I think so, as it says
Check if a string is conveniently palindromic, and output 1 if it is and 0 if it isn't.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Code Golf Contest #8
« Reply #6 on: September 01, 2014, 12:27:09 pm »
How is the string supposed to be input ? I mean, from what I read, nothing prevents me from saying that my program only works when the string is copied in L1 (in Axe) without caring how it got in L1 since the problem is just "check", not "input and check" :P
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Code Golf Contest #8
« Reply #7 on: September 01, 2014, 12:53:13 pm »
so, convieniently palindromic for letters, it'd be for "b" and "d", and "p" and "q" ? (also symetrical letters in themselves like "i", "l", "o", "v", "w", "x")

For example : b(][)d is conviniently palindromic, but not b(][)b

Looks harder if we have to handle chars different than brackets :P
« Last Edit: September 01, 2014, 01:30:41 pm by Adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

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 #8
« Reply #8 on: September 01, 2014, 01:00:42 pm »
I shall change the rules to accomodate those kinds of letter pairs. () {} [] <> /\
« Last Edit: September 01, 2014, 03:27:49 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 calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Code Golf Contest #8
« Reply #9 on: September 01, 2014, 01:23:10 pm »
I guess TI-83+ implementations should handle two-byte tokens (such as lowercase letters) properly? That seems kind of annoying, but as long as it's consistent among the entries that would be fine with me.

Edit: Actually, case insensitivity would really kill my code (z80 assembly). It's super hard to scan backwards through a token string if you don't know the size the preceding token should be, and I get that size from the token it should match scanning forward.
« Last Edit: September 01, 2014, 01:34:56 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

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 #8
« Reply #10 on: September 01, 2014, 03:20:06 pm »
no chars except the bd and pq should be case sensitive
I agree, that's probably overkill. Either it's sensitive or insensitive, not a mix (although you can try if you want).

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.

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 #8
« Reply #11 on: September 01, 2014, 03:27:28 pm »
Progress on my Golfscript entry:

Returns correct results for all test cases given. The program actually can handle any number of arbitrary pairs. It is now 72.
« Last Edit: September 01, 2014, 03:43:11 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 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 #8
« Reply #12 on: September 02, 2014, 05:55:01 pm »
Bump.

I have another entry! TI-BASIC.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?