<jupyter_start><jupyter_text>Answers to Hackerrank Artificial Intelligence challenges. Written without editorial or discussion help unless otherwise noted.  Code written in Python 2.By: <NAME>  Bot Building ChallengesAnswer to Bot saves Princess: https://www.hackerrank.com/challenges/saveprincess/problem<jupyter_code>#!/bin/python
def displayPathtoPrincess(n,grid):
#print all the moves here
    #Find princess
    #If princess is in top row
    if 'p' in grid[0]:
        for i in range(n/2):
            print 'UP\n',
    #Else princess is on bottom
    else:
        for i in range(n/2):
            print 'DOWN\n',
    #Check left
    if grid[0][0] == 'p' or grid[n-1][0] == 'p':
        for i in range(n/2):
            print 'LEFT\n',
    #Else she is on the right
    else:
        for i in range(n/2):
            print 'RIGHT\n',
    

m = input()

grid = []
for i in xrange(0, m):        
    grid.append(raw_input().strip())

displayPathtoPrincess(m,grid)<jupyter_output>5
p----
-----
--m--
-----
-----
UP
UP
LEFT
LEFT<jupyter_text>Answer to Bot saves Princess - 2: https://www.hackerrank.com/challenges/saveprincess2/problem<jupyter_code>#!/bin/python
def nextMove(n,r,c,grid):
    #Shift bot c position to match princess 
    #Find princess y position
    #If greater, she is down from bot
    if p_y > r:
        return 'DOWN'
    #If less, she is up from bot
    elif p_y < r:
        return 'UP'
    #Else she is in same column as bot
    #Find princess x position
    #If greater, she is right of bot
    if p_x > c:
        return 'RIGHT'
    #If less, she is left of bot
    elif p_x < c:
        return 'LEFT'
    #Else she is already in same row as bot
    return

n = input()
r,c = [int(i) for i in raw_input().strip().split()]
grid = []
for i in xrange(0, n):
    grid_line = raw_input()
    if 'p' in grid_line:
        p_x, p_y = grid_line.find('p'), i 
    grid.append(grid_line)

print nextMove(n,r,c,grid)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12264631043256997, 'fraction_numerical': 0.007633587786259542, 'mean_word_length': 2.5487364620938626, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '137729', 'license': 'OLDAP-2.7', 'n_tokens_mistral': 709, 'n_tokens_neox': 682, 'n_words': 225, 'path': 'Hackerrank Artificial Intelligence Challenges.ipynb', 'repo_name': 'GeoffLyle/hackerrank_projects', 'size': '1970'}