#!/usr/bin/env python
#
# while statement
#
import time
import datetime
import random
def code_peg():
    code = raw_input()
    if len(code)==4:
        return code
    else:
        print "please enter four digits"
        return code_peg()



def play():
    lines = []
    i=0
    pegs = ["r","g","b","y","p","w"]
    #answer = [random.sample(pegs,1)[0],random.sample(pegs,1)[0],
    #          random.sample(pegs,1)[0],random.sample(pegs,1)[0]]
    answer = ["r","r","r","g"]
    is_winner = False
    for q in range(0,8):
        print "****|****"
        
    while i<=8 and not is_winner:
        
        print "r stands for red"
        print "g stands for green"
        print "b stands for blue"
        print "y stands for yellow"
        print "p stands for purple"
        print "w stands for white"
        print "----------------------"
        print "o stands for right order and color"
        print "c stands for right color"        
        code = code_peg()
        temp = []
        for x in code:
            temp.append(x)
        temp2 = temp[0:]
        answer2 = answer[0:]
        
        black = 0
        m = 0
        while m<4:
            if temp[m] == answer[m]:
                black=black+1
                temp2.remove(temp[m])
                answer2.remove(answer[m])
            m = m+1
            
        white = 0
        
        for x in temp2:
            if x in answer2:
                white = white+1
                answer2.remove(x)
        
        key = ""
        for p in range(0,black):
            key = key+"o"
        for p in range(0,white):
            key = key+"c"
        lines.append(code+"|"+key)

        if black ==4:
            is_winner = True
            lastwords = "you win the game"
        else:
            lastwords = "you lost the game"
        j=8-i
        for x in lines:
            print x
        while j>0:
            print "****|****"
            j=j-1
            
        i=i+1
    print lastwords
    print answer
    
    


def test_ready():
    ready = raw_input("Do you want to play, yes or no: ")
    if ready == "yes":
        mybeforetime = time.time()
        play()
        myaftertime = time.time()
        
        diff = myaftertime - mybeforetime
        print "you used %s seconds" %diff
        test_ready()
    elif ready == "no":
        print
    else:
        return test_ready()

test_ready()

