a game of strings english

Post on 14-Dec-2015

212 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

asas

TRANSCRIPT

AgameofstringsProblemStatement

AliceandBobarenowplayingwithstring.Initiallytheychooseastringsandtaketurntoreduceit.Ineachturnoneofthemreduceasciivalueofanyonecharacterby1.Forexampledbecomesc,cbecomesbandsoon.Theonewhoisunabletomakeamovelosesthegame.Givenastringyouneedtotellwhowillwin.Alicealwaysmovesfirst.

Note:youcannotreduce'a'.

InputFormat

FirstlinecontainsasingleintegerTwhichdenotesnumberoftestcases.EachoftheNextTlinescontainsaString.

OutputFormatForeverytestcaseinNewlineOutput'Bob'ifBobwinsotherwiseoutput'Alice'.

Constraints

1<=Lengthofeachstring<=10001<=T<=100Stringswillonlyconsistlowercaseletters.

SampleInput

3ababbhackerrank

SampleOutput

AliceBobBob

Explanation

InfirstcaseAlicewillreducethestringto'aa',thenBobwillhavenomoveleft.

Insecondcase,Alicehavetoreducethestringto"aba"or"aab".IneithercaseshewillloseasBobwillreduceitto"aaa"inhisturn.

top related