Calculator Community > Community Contests

[ENDED] Code Golf Contest #8

(1/3) > >>

JWinslow23:
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: ---(<)i(>)
<}<{}>{>
][()][
}{[]}{
--- End code ---
would return 1, and strings like

--- Code: ---())(
<(){}[][}{)(<
(({))
<<
--- End code ---
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
RankUserSizeDateCode1JWinslow23689/1/2014 2:39:28 PMSpoiler For Spoiler: {.96>32*-}/]''+.['()''{}''[]''<>']{.(;\);@1$/"\0"*2$/\*"\0"/\*}/-1%=
Ruby2
RankUserSizeDateCode1Juju639/1/2014 2:59:26 PMSpoiler For Spoiler: p (a=gets.chop.upcase)==a.reverse.tr("[{(<>)}]","]})><({[")?1:0
TI-83+ BASIC
RankUserSizeDateCode1JWinslow231779/2/2014 5:43:43 PMSpoiler 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
RankUserSizeDateCode1Jens_K1459/4/2014 4:52:18 PMSpoiler 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
RankLangUserSizeDate1Ruby2Juju639/1/2014 2:59:26 PM2GolfscriptJWinslow23689/1/2014 2:39:28 PM3Nspire LuaJens_K1459/4/2014 4:52:18 PM4TI-83+ BASICJWinslow231779/2/2014 5:43:43 PM

Juju:
This one should be interesting. Also, 52 bytes.

alberthrocks:

--- Quote from: JWinslow23 on September 01, 2014, 11:56:35 am ---If any further clarification is needed, contact me. I'll try not to get everything backwards for you. (*crickets* Seriously, nothing? :-\ )

--- End quote ---
I liked it! ;)

Quick question - is this case sensitive or insensitive?

Princetonlion.tibd:
I think I can do this :D
68k BASIC.

calc84maniac:

--- Quote from: alberthrocks on September 01, 2014, 12:19:06 pm ---
--- Quote from: JWinslow23 on September 01, 2014, 11:56:35 am ---If any further clarification is needed, contact me. I'll try not to get everything backwards for you. (*crickets* Seriously, nothing? :/ )

--- End quote ---
I liked it! ;)

Quick question - is this case sensitive or insensitive?

--- End quote ---

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)

Navigation

[0] Message Index

[#] Next page

Go to full version