not pretty, but here is my solution
pt2 was kind of hacky instead of rewriting the train to calculate, I
just reworked the input to add myself to it
input =: fread 'c:/joe/lang-lab/j/advent2015/day13.txt'
parsed=: ' ' cut each cutLF input
who =: {. every
sitBy =: ([: }: each {: every)
getScore=: [: (] -@]^:((<'lose') e. 0&{@[) ".@>@(1&{))"1 @: ((2,3)&{) each ]
getChoices=: ([: (] A.~ i.@!@#) [: ~. who)
getMax=: [: (>./)&:(+/"1) (>@getScore@] {~ (who,.sitBy) i.
(],|."1@])@((2]\ ])"1)@([: ({:,])"1 getChoices))
smoutput pt1=:getMax parsed
addMe=: ((((;: 'would gain 0 happiness units sitting next to Me.')
(];[) ]) each) @ (~.&:who))
addThem=: ((((;: 'Me would gain 0 happiness units sitting next to')
([,<@]) ('.',~])) each) @ (~.&:who))
smoutput pt2=: getMax (] , (addMe,addThem)) parsed
sample=: 0 : 0
Alice would gain 54 happiness units by sitting next to Bob.
Alice would lose 79 happiness units by sitting next to Carol.
Alice would lose 2 happiness units by sitting next to David.
Bob would gain 83 happiness units by sitting next to Alice.
Bob would lose 7 happiness units by sitting next to Carol.
Bob would lose 63 happiness units by sitting next to David.
Carol would lose 62 happiness units by sitting next to Alice.
Carol would gain 60 happiness units by sitting next to Bob.
Carol would gain 55 happiness units by sitting next to David.
David would gain 46 happiness units by sitting next to Alice.
David would lose 7 happiness units by sitting next to Bob.
David would gain 41 happiness units by sitting next to Carol.
)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm