Is anyone participating in the google code jam?

My approach to the "The Repeater" problem was marked incorrect, and
I'm not seeing where I went wrong.

(I think it's ok to share code after the round is over - the rules ask
us to not share code during the round, but it is over now, and there's
no way anyone can take advantage of my code any longer - even if it
were "correct".)

Briefly, my approach looked like this:

segments=: 1,2~:/\]
runs=: +/\@segments
uniq=:runs {./. ]
counts=: #/.~@runs

result=:3 :0
  if. 1<#~.uniq&.> y do. 'Felga Won' return. end.
  +/13 :'<./+/|-/~ y'"1]|: counts&> y
)

which performed correctly on these test cases:

   result 'mmaw';'maw'
   result 'gcj';'cj'
   result 'aaabbb';'ab';'aabb'
   result 'abc';'abc'
   result 'aabc';'abbc';'abcc'

Now, a possible issue has to do with an ambiguity in the rules. The rules were:

     * Select any character in any of the strings and repeat it (add
another instance of this character exactly after it). For example, in
a single move Omar can change "abc" to "abbc" (by repeating the
character 'b').

and

     * Select any two adjacent and identical characters in any of the
strings, and delete one of them. For example, in a single move Omar
can change "abbc" to "abc" (delete one of the 'b' characters), but
can't convert it to "bbc".

Anyways, it's probably something silly which I did wrong (it usually
is), but if someone else here is participating and got the small data
set correct, I would like to compare notes to see where I went wrong.

Thanks,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to