I just want to say THX to this thread which helped me a lot to solve this problem.
Brathering

Moderator: Board moderators
Code: Select all
#include <iostream>
#include <string>
using namespace std;
struct boxes {
int pile;
int place;
};
struct piles {
int pileSize;
};
int count = 0;
piles *myPiles;
void initBoxes(boxes *boxvar) {
int i;
for (i = 0; i < count; i++) {
boxvar[i].pile = i;
boxvar[i].place = 1;
myPiles[i].pileSize = 1;
}
}
void moveOnto(int blockA, int blockB, boxes *boxvar) {
int i, a = 0, pileA = 0, pileB = 0, blockApos = 0;
pileA = boxvar[blockA].pile;
pileB = boxvar[blockB].pile;
blockApos = boxvar[blockA].place;
if (pileA != pileB) {
for (i = 0; i < count; i++) {
if (((boxvar[i].pile == pileA) || (boxvar[i].pile == pileB)) &&
(boxvar[i].place > blockApos)) {
myPiles[boxvar[i].pile].pileSize -= 1;
boxvar[i].pile = i;
boxvar[i].place = 1;
myPiles[i].pileSize = 1;
a++;
}
}
boxvar[blockA].pile = pileB;
boxvar[blockA].place = myPiles[pileB].pileSize + 1;
myPiles[pileA].pileSize -= (1 + a);
myPiles[pileB].pileSize += 1;
}
}
void moveOver(int blockA, int blockB, boxes *boxvar) {
int i, a = 0, pileA = 0, pileB = 0, blockApos = 0;
pileA = boxvar[blockA].pile;
pileB = boxvar[blockB].pile;
blockApos = boxvar[blockA].place;
if (pileA != pileB) {
for (i = 0; i < count; i++) {
if ((boxvar[i].pile == pileA) && (boxvar[i].place > blockApos)) {
boxvar[i].pile = i;
boxvar[i].place = 1;
myPiles[i].pileSize = 1;
a++;
}
}
boxvar[blockA].pile = pileB;
boxvar[blockA].place = myPiles[pileB].pileSize + 1;
myPiles[pileA].pileSize -= (1 + a);
myPiles[pileB].pileSize += 1;
}
}
void pileOnto(int blockA, int blockB, boxes *boxvar) {
int i, pileA = 0, pileB = 0, blockApos = 0, blockBpos = 0, pileBsize = 0;
pileA = boxvar[blockA].pile;
pileB = boxvar[blockB].pile;
blockApos = boxvar[blockA].place;
blockBpos = boxvar[blockB].place;
if (pileA != pileB) {
for (i = 0; i <= count; i++) {
if ((boxvar[i].pile == pileB) && (boxvar[i].place > blockBpos)) {
boxvar[i].pile = i;
boxvar[i].place = 1;
myPiles[i].pileSize += 1;
myPiles[pileB].pileSize -= 1;
}
}
pileBsize = myPiles[pileB].pileSize;
for (i = 0; i <= count; i++) {
if ((boxvar[i].pile == pileA) && (boxvar[i].place >= blockApos)) {
boxvar[i].pile = pileB;
boxvar[i].place = (boxvar[i].place - blockApos) + pileBsize + 1;
myPiles[pileB].pileSize += 1;
myPiles[pileA].pileSize -= 1;
}
}
}
}
void pileOver(int blockA, int blockB, boxes *boxvar) {
int i, pileA = 0, pileB = 0, blockApos = 0, pileBsize = 0;
pileA = boxvar[blockA].pile;
pileB = boxvar[blockB].pile;
blockApos = boxvar[blockA].place;
pileBsize = myPiles[pileB].pileSize;
if (pileA != pileB) {
for (i = 0; i <= count; i++) {
if ((boxvar[i].pile == pileA) && (boxvar[i].place >= blockApos)) {
boxvar[i].pile = pileB;
boxvar[i].place = (boxvar[i].place - blockApos) + pileBsize + 1;
myPiles[pileA].pileSize -= 1;
myPiles[pileB].pileSize += 1;
}
}
}
}
void doDisplay(boxes *boxvar) {
int c,i;
int *display;
for (i = 0; i < count; i++) {
cout << i << ":";
if (myPiles[i].pileSize > 0) {
display = new int[myPiles[i].pileSize-1];
for (c = 0; c < count; c++) {
if (boxvar[c].pile == i) {
//cout << " " << c;
display[boxvar[c].place-1] = c;
}
}
for (c = 0; c < myPiles[i].pileSize; c++) {
cout << " " << display[c];
}
} else {
cout << " ";
}
cout << "\n";
}
}
int main() {
int i = 0;
boxes *mybox;
string input;
cin >> count;
mybox = new boxes[count];
myPiles = new piles[count];
initBoxes(mybox);
string action, actfor;
int from, to = 0;
while (cin >> action) {
if (action.compare("quit") == 0) {
break;
}
if (action.compare("display") == 0) {
doDisplay(mybox);
} else {
cin >> from >> actfor >> to;
if ((from != to) && ((from <= count-1) && (to <= count-1)) &&
((from >= 0) && (to >= 0))) {
//cout << action << " " << from << " " << actfor << " " << to << "\n";
if ((action.compare("move") == 0) && (actfor.compare("onto") == 0)) {
// Move onto
moveOnto(from,to,mybox);
}
if ((action.compare("move") == 0) && (actfor.compare("over") == 0)) {
// Move over
moveOver(from,to,mybox);
}
if ((action.compare("pile") == 0) && (actfor.compare("onto") == 0)) {
// Pile onto
pileOnto(from,to,mybox);
}
if ((action.compare("pile") == 0) && (actfor.compare("over") == 0)) {
// Pile over
pileOver(from,to,mybox);
}
}
}
}
doDisplay(mybox);
//system("PAUSE");
return 0;
}
But if I remove the if statement at the pileOver function (the one that checks to see if pileA != pileB) then I get wrong answer.Your program has died with signal 11 (SIGSEGV). Meaning:
Invalid memory reference
Before crash, it ran during 0.062 seconds.
Code: Select all
#include<stdio.h>
#include<string.h>
#define INF 29
long point[30],prev[30],next[30],last[30],stk[30],n;
void toinitials(long a)
{
long x;
while(next[a] != INF)
{
x = next[a];
point[x] = x;
prev[x] = INF;
last[x] = x;
stk[x] = x;
next[a] = INF;
a = x;
}
}
void renew(long x,long y)
{
do
{ stk[x] = y;
x = next[x];
}while(x != INF);
}
void move_onto(long a,long b)
{
toinitials(a);
toinitials(b);
next[b] = a;
next[a] = INF;
next[prev[a]] = INF;
if(point[a] == a)
point[a]= INF;
last[stk[a]] = prev[a];
last[stk[b]] = a ;
prev[a] = b;
stk[a] = stk[b];
}
void move_over(long a,long b)
{
toinitials(a);
next[last[stk[b]]] = a;
next[a] = INF;
next[prev[a]] = INF;
if(point[a] == a)
point[a] = INF ;
last[stk[a]] = prev[a];
prev[a]= last[stk[b]];
last[stk[b]] = a;
stk[a] = stk[b];
}
void pile_onto(long a,long b)
{
toinitials(b);
next[b] = a;
next[prev[a]] = INF;
last[b] = last[stk[a]];
if(point[a] = a)
{ point[a] = INF;
last[a] = INF;
}
else
last[stk[a]] = prev[a];
prev[a] = b;
renew(a,stk[b]);
}
void pile_over(long a,long b)
{
next[last[stk[b]]] = a;
next[prev[a]] = INF;
prev[a] = last[b];
last[b] = last[stk[a]];
if(point[a]==a)
{ point[a] = INF;
last[a] = INF;
}
else
last[stk[a]] = prev[a];
renew(a,stk[b]);
}
void main()
{
//freopen("101.in","r",stdin);
//freopen("101.out","w",stdout);
char s1[100],s2[100];
long a,b,i,m;
scanf("%ld",&n);
for(i=0;i<n;i++)
{
point[i] = i; prev[i] = INF; next[i] = INF; last[i] = i; stk[i] = i;
}
while(scanf(" %s",s1)==1)
{
if(strcmp(s1,"quit")==0)
break;
scanf("%ld %s %ld",&a,s2,&b);
if(a == n || stk[a]==stk[b] || a>=n || a< 0 || b>=n || b< 0)
continue;
if(strcmp(s1,"move")==0)
{
if(strcmp(s2,"onto")==0)
move_onto(a,b);
else if(strcmp(s2,"over")==0)
move_over(a,b);
}
else if(strcmp(s1,"pile")==0)
{ if(strcmp(s2,"onto")==0)
pile_onto(a,b);
else if(strcmp(s2,"over")==0)
pile_over(a,b);
}
}
for(i = 0; i < n; i++)
{
printf("%2ld: ",i);
m = point[i];
while(m != INF)
{
printf(" %ld",m);
m = next[m];
}
printf("\n");
}
}
Code: Select all
10
...
...
quite
5
..
..
quite
Thx. That one solved it for meChung Ha, Yun wrote:Insert this condition. You will get accept.gits wrote:my code gives:
...
Any command in which a = b or in which a and b are in the same stack of blocks is an illegal command. All illegal commands should be ignored and should have no affect on the configuration of blocks
Code: Select all
#include<stdio.h>
int arr[25][2];
int start[25];
int col[25];
int main()
{
int i,j,k,l;
int n;
char str1[20],str2[20];
int a,b;
while(1)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
arr[i][0]=-1;
arr[i][1]=-1;
start[i]=i;
col[i]=i;
}
scanf("%s",str1);
while(strcmp(str1,"quit")!=0)
{
scanf("%d %s %d",&a,str2,&b);
if(a==b || col[a]==col[b])
{
scanf("%s",str1);
continue;
}
if(strcmp(str1,"move")==0)
{
i=arr[a][1];
while(i!=-1)
{
j=arr[i][1];
arr[arr[i][0]][1]=-1;
arr[i][0]=-1;
col[i]=i;
start[i]=i;
i=j;
}
}
if(strcmp(str2,"onto")==0)
{
i=arr[b][1];
while(i!=-1)
{
j=arr[i][1];
arr[arr[i][0]][1]=-1;
arr[i][0]=-1;
col[i]=i;
start[i]=i;
i=j;
}
}
i=b;
while(arr[i][1]!=-1)
i=arr[i][1];
if(arr[a][0]==-1)
{
start[a]=-1;
}
else
{
arr[arr[a][0]][1]=-1;
}
arr[a][0]=i;
arr[i][1]=a;
col[a]=col[b];
scanf("%s",str1);
}
for(i=0;i<n;i++)
{
printf("%d:",i);
j=start[i];
while(j!=-1)
{
printf(" %d",j);
j= arr[j][1];
}
printf("\n");
}
}
return 0;
}
Code: Select all
# include <iostream.h>
# include <string.h>
using namespace std;
struct no
{int n;no *u,*d;};
no *Z[26],*X[26];int n,Y[26];
void rem(int a);
void pr();
int main()
{int a,b;char s[5],s2[5];no *t,*t2;
cin>>n;
for(a=0;a<n;a++)
{Z[a]=NULL;Z[a]=new no;Z[a]->u=NULL;
Z[a]->n=a;Z[a]->d=NULL;
Y[a]=a;X[a]=Z[a];
}
while(1)
{cin>>s;if(strcmp(s,"quit")==0) break;
cin>>a>>s2>>b;
if(a==b || a<0 || a>=n || b<0 || b>=n || Y[a]==Y[b]) continue;
if(strcmp(s,"move")==0 && strcmp(s2,"onto")==0)
{rem(a);rem(b);t=X[Y[a]];
X[Y[a]]=t->d;if(t->d==NULL) Z[Y[a]]=NULL; else t->d->u=NULL;
if(X[Y[b]]==NULL) Z[Y[b]]=t; else X[Y[b]]->u=t;
t->d=X[Y[b]];X[Y[b]]=t;
Y[a]=b;
}
else if(strcmp(s,"move")==0 && strcmp(s2,"over")==0)
{rem(a);t=X[Y[a]];
X[Y[a]]=t->d;if(t->d==NULL) Z[Y[a]]=NULL; else t->d->u=NULL;
if(X[Y[b]]==NULL) Z[Y[b]]=t; else X[Y[b]]->u=t;
t->d=X[Y[b]];X[Y[b]]=t;
Y[a]=b;
}
else if(strcmp(s,"pile")==0 && strcmp(s2,"onto")==0)
{rem(b);t2=X[Y[a]];
for(t=X[Y[a]];;t=t->d)
{if(t->n==a) break;
Y[t->n]=Y[b];
}
X[Y[a]]=t->d;if(t->d==NULL) Z[Y[a]]=NULL; else t->d->u=NULL;
if(X[Y[b]]==NULL) Z[Y[b]]=t; else X[Y[b]]->u=t;
t->d=X[Y[b]];X[Y[b]]=t2;
Y[a]=b;
}
else if(strcmp(s,"pile")==0 && strcmp(s2,"over")==0)
{t2=X[Y[a]];
for(t=X[Y[a]];;t=t->d)
{if(t->n==a) break;
Y[t->n]=Y[b];
}
X[Y[a]]=t->d;if(t->d==NULL) Z[Y[a]]=NULL; else t->d->u=NULL;
if(X[Y[b]]==NULL) Z[Y[b]]=t; else X[Y[b]]->u=t;
t->d=X[Y[b]];
X[Y[b]]=t2;Y[a]=b;
}
}pr();
for(a=0;a<n;a++)
for(t=Z[a];t!=NULL;)
{if(t->u==NULL) delete t;
t=t->u;if(t!=NULL && t->d!=NULL) delete t->d;
}
return 0;
}
void rem(int a)
{no *t=X[Y[a]];
while(t->n!=a)
{X[Y[a]]=t->d;t->d->u=NULL;
if(X[t->n]==NULL) Z[t->n]=t; X[t->n]->u=t;
t->d=X[t->n];X[t->n]=t;
Y[t->n]=t->n;
}
}
void pr()
{int a;no *t;
for(a=0;a<n;a++)
{cout<<a<<":";
for(t=Z[a];t!=NULL;t=t->u)
cout<<" "<<t->n;
cout<<"\n";
}
}
Code: Select all
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
int main (void){
int num;
cin >> num;
vector <int> nista;
vector <vector <int> > pozicije (num, nista);
for (int i=0; i<num; i++){
pozicije[i].push_back(i);
}
while (true){
string com1, com2;
int koga, kam;
cin >> com1;
if (com1=="quit") break;
else cin >> koga >> com2 >> kam;
if (koga==kam) continue;
bool k3=false;
for (int i=0; i<pozicije.size(); i++){
bool k1=false, k2=false;
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==koga) k1=true;
if (pozicije[i][j]==kam) k2=true;
}
if (k1==true && k2==true) k3=true;
}
if (k3==true) continue;
if (com1=="move" && com2=="onto"){
for (int i=0; i<pozicije.size(); i++){
bool naso=false;
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==koga){
pozicije[i].erase(pozicije[i].begin()+j);
naso=true;
for (int k=j; k<pozicije[i].size();){
pozicije[pozicije[i][j]].push_back(pozicije[i][j]);
pozicije[i].erase(pozicije[i].begin()+j);
}
}
}
if (naso==true) break;
}
for (int i=0; i<pozicije.size(); i++){
bool naso=false;
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==kam){
for (int k=j+1; k<pozicije[i].size();){
pozicije[pozicije[i][j]].push_back(pozicije[i][j]);
pozicije[i].erase(pozicije[i].begin()+j);
}
pozicije[i].insert(pozicije[i].begin()+j+1, koga);
break;
naso=true;
}
}
if (naso==true) break;
}
}
else if (com1=="move" && com2=="over"){
for (int i=0; i<pozicije.size(); i++){
bool naso=false;
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==koga){
pozicije[i].erase(pozicije[i].begin()+j);
naso=true;
for (int k=j; k<pozicije[i].size();){
pozicije[pozicije[i][j]].push_back(pozicije[i][j]);
pozicije[i].erase(pozicije[i].begin()+j);
}
}
}
if (naso==true) break;
}
for (int i=0; i<pozicije.size(); i++){
bool naso=false;
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==kam){
naso=true;
pozicije[i].push_back(koga);
break;
}
}
if (naso==true) break;
}
}
else if (com1=="pile" && com2=="onto"){
vector <int> premjestam;
for (int i=0; i<pozicije.size(); i++){
bool naso=false;
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==koga){
naso=true;
for (int k=j; k<pozicije[i].size();){
premjestam.push_back(pozicije[i][j]);
if (pozicije[i][j]==kam) break;
pozicije[i].erase(pozicije[i].begin()+j);
}
}
}
if (naso==true) break;
}
bool premjesti=false;
for (int i=0; i<pozicije.size(); i++){
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==kam){
for (int k=j+1; k<pozicije[i].size();){
pozicije[pozicije[i][j+1]].push_back(pozicije[i][j+1]);
pozicije[i].erase(pozicije[i].begin()+j+1);
}
for (int l=0, k=j+1; l<premjestam.size(); k++, l++){
pozicije[i].insert(pozicije[i].begin()+k, premjestam[l]);
}
premjesti=true;
break;
}
}
if (premjesti==true) break;
}
}
else if (com1=="pile" && com2=="over"){
vector <int> premjestam;
for (int i=0; i<pozicije.size(); i++){
bool naso=false;
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==koga){
naso=true;
for (int k=j; k<pozicije[i].size();){
premjestam.push_back(pozicije[i][j]);
if (pozicije[i][j]==kam) break;
pozicije[i].erase(pozicije[i].begin()+j);
}
}
}
if (naso==true) break;
}
for (int i=0; i<pozicije.size(); i++){
bool naso=false;
for (int j=0; j<pozicije[i].size(); j++){
if (pozicije[i][j]==kam){
naso=true;
for (int k=0; k<premjestam.size(); k++) pozicije[i].push_back(premjestam[k]);
break;
}
}
if (naso==true) break;
}
}
}
for (int i=0; i<num; i++){
cout << i << ": ";
for (int j=0; j<pozicije[i].size(); j++){
cout << pozicije[i][j] << " ";
}
cout << endl;
}
return 0;
}
Code: Select all
# Program that solves The Blocks Problem
# http://acm.uva.es/p/v1/101.html
# class Robot that solves The Blocks Problem
class Robot:
# Class members:
# blocks blocks - list of stacks
# n number of blocks on a table
# constructor
# initializes an array of stacks "blocks" with blocks 1, 2,..., n
# in: n - number of blocks
def __init__(self, size):
self.n = size
self.blocks = [[i] for i in range(size)]
# methos that prints the Robot object with 'print' command
def __str__(self):
tempStr = ""
for i in range(self.n):
tempStr += str(i)+":"
for el in self.blocks[i]:
tempStr += " "+str(el)
tempStr += "\n"
return tempStr
# finds position 0..n-1 in which element el is
# in: el - element
#out: position of the block (0..n-1)
def getPosition(self, el):
for i in range(self.n):
if el in self.blocks[i]:
return i
# moves elements on top of el in position pos to their initial position
# in: el - element
# in: pos - position
def moveToInitial(self, el, pos):
while True:
popped = self.blocks[pos].pop()
if popped != el:
self.blocks[popped].append(popped)
else:
self.blocks[pos].append(popped)
break
# moves a onto/over b
# in: s - string holding 'onto'/'over'
# in: a, b - blocks
def move(self, s, a, b):
aPos = self.getPosition(a)
bPos = self.getPosition(b)
self.moveToInitial(a, aPos)
if s == 'onto':
self.moveToInitial(b, bPos)
self.blocks[bPos].append(self.blocks[aPos].pop())
# piles a onto/over b
# in: s - string holding 'onto'/'over'
# in: a, b - blocks
def pile(self, s, a, b):
aPos = self.getPosition(a)
bPos = self.getPosition(b)
if s == 'onto':
self.moveToInitial(b, bPos)
tempStack = []
while True:
el = self.blocks[aPos].pop()
tempStack.append(el)
if el == a:
break
while tempStack != []:
self.blocks[bPos].append(tempStack.pop())
file = open('input.txt')
robot = Robot(int(file.readline().strip()))
for line in file:
s = line.strip().split(' ')
if s[0] == 'move':
robot.move(s[2], int(s[1]), int(s[3]))
elif s[0] == 'pile':
robot.pile(s[2], int(s[1]), int(s[3]))
elif s[0] == 'quit':
break
file.close()
print robot
Code: Select all
class Robot:
def __init__(self, size):
self.n = size
self.blocks = [[i] for i in range(size)]
def __str__(self):
tempStr = ""
for i in range(self.n):
tempStr += str(i)+":"
for el in self.blocks[i]:
tempStr += " "+str(el)
tempStr += "\n"
return tempStr
def getPosition(self, el):
for i in range(self.n):
if el in self.blocks[i]:
return i
def moveToInitial(self, el, pos):
while True:
popped = self.blocks[pos].pop()
if popped != el:
self.blocks[popped].append(popped)
else:
self.blocks[pos].append(popped)
break
def move(self, s, a, b):
aPos = self.getPosition(a)
bPos = self.getPosition(b)
self.moveToInitial(a, aPos)
if s == 'onto':
self.moveToInitial(b, bPos)
self.blocks[bPos].append(self.blocks[aPos].pop())
def pile(self, s, a, b):
aPos = self.getPosition(a)
bPos = self.getPosition(b)
if s == 'onto':
self.moveToInitial(b, bPos)
tempStack = []
while True:
el = self.blocks[aPos].pop()
tempStack.append(el)
if el == a:
break
while tempStack != []:
self.blocks[bPos].append(tempStack.pop())
file = open('input.txt')
robot = Robot(int(file.readline().strip()))
for line in file:
s = line.strip().split(' ')
if s[0] == 'move':
robot.move(s[2], int(s[1]), int(s[3]))
elif s[0] == 'pile':
robot.pile(s[2], int(s[1]), int(s[3]))
elif s[0] == 'quit':
break
file.close()
print robot
Code: Select all
# Program that solves The Blocks Problem
# http://acm.uva.es/p/v1/101.html
# class Robot that solves The Blocks Problem
class Robot:
# Class members:
# blocks blocks - list of stacks
# n number of blocks on a table
# constructor
# initializes an array of stacks "blocks" with blocks 1, 2,..., n
# in: n - number of blocks
def __init__(self, size):
self.n = size
self.blocks = [[i] for i in range(size)]
# methos that prints the Robot object with 'print' command
def __str__(self):
tempStr = ""
for i in range(self.n):
tempStr += str(i)+":"
for el in self.blocks[i]:
tempStr += " "+str(el)
tempStr += "\n"
return tempStr
# finds position 0..n-1 in which element el is
# in: el - element
#out: position of the block (0..n-1)
def getPosition(self, el):
for i in range(self.n):
if el in self.blocks[i]:
return i
# moves elements on top of el in position pos to their initial position
# in: el - element
# in: pos - position
def moveToInitial(self, el, pos):
while True:
popped = self.blocks[pos].pop()
if popped != el:
self.blocks[popped].append(popped)
else:
self.blocks[pos].append(popped)
break
# moves a onto/over b
# in: s - string holding 'onto'/'over'
# in: a, b - blocks
def move(self, s, a, b):
aPos = self.getPosition(a)
bPos = self.getPosition(b)
self.moveToInitial(a, aPos)
if s == 'onto':
self.moveToInitial(b, bPos)
self.blocks[bPos].append(self.blocks[aPos].pop())
# piles a onto/over b
# in: s - string holding 'onto'/'over'
# in: a, b - blocks
def pile(self, s, a, b):
aPos = self.getPosition(a)
bPos = self.getPosition(b)
if s == 'onto':
self.moveToInitial(b, bPos)
tempStack = []
while True:
el = self.blocks[aPos].pop()
tempStack.append(el)
if el == a:
break
while tempStack != []:
self.blocks[bPos].append(tempStack.pop())
file = open('input.txt')
robot = Robot(int(file.readline().strip()))
for line in file:
s = line.strip().split(' ')
if s[0] == 'move':
robot.move(s[2], int(s[1]), int(s[3]))
elif s[0] == 'pile':
robot.pile(s[2], int(s[1]), int(s[3]))
elif s[0] == 'quit':
break
file.close()
print robot