HELP!!! Trying to figure out how to go about this problem. (I need some explanation and a head start Please)

115 views
Skip to first unread message

Mr. Carter

unread,
Oct 14, 2016, 2:35:08 AM10/14/16
to Python GCU Forum
International Mines tournaments have declined lately, but there is word that a new one is in the

works — rumor has it that it could be even bigger than the legendary Budapest 2005 one, in no

small part because inhabitants of planet Htrae might be attending.

What better way to get prepared for the tournament than to write your own implementation?

There's just a small twist. Planet Htrae is not very different from Earth, except that space in the

Yklim way, Htrae's star cluster, doesn't have three dimensions — at least, not always: it

fluctuates between 2 and, on the worst days, 60. In fact, it's not uncommon for an Htraean to

wake up flat, for example, and finish the day in 7 dimensions — only to find themselves living in

to three or four dimensions on the next morning. It takes a bit of time to get used to it, of course.

In any case, Htraeans are pretty particular about playingMines. Kids on Htrae always play on

regular, 2D boards, but champions like to play on higher-dimensional boards, usually on as

many dimensions as the surrounding space. Your code will have to support this, of course.

Here's the weather advisory for the week of the tournament:

...VERY DIMENSIONAL IN SOUTHWEST OHADI ON YADRIF...

.AN EXITING LOW PRESSURE SYSTEM WILL INCREASE NORTHWEST DIMENSIONAL

FLUX IN AND SOUTH OF THE EKANS RIVER BASIN ON YADRIF. ESIOB IS NOW

INCLUDED IN THE ADVISORY BUT THE STRONGEST FLUX WILL BE SOUTH AND

EAST OF MOUNTAIN EMOH TOWARD THE CIMAG VALLEY.

ZDI014>030-231330-016-

UPPER ERUSAERT VALLEY-SOUTHWEST HYPERLANDS-WESTERN CIMAG VALLEY-

1022 MP TDM UHT PES 22 6102

...DIMENSION ADVISORY REMAINS IN EFFECT FROM 10 MA TO 9 MP ON

YADIRF...

* DIMENSIONAL FLUX...30 TO 35 DIMENSIONS WITH GUSTS TO 45.

* IMPACTS...CROSSFLUXES WILL MAKE FOR DIFFICULT TRAVELLING

CONDITIONS ON LOW-DIMENSIONAL ROADS.

This lab trains the following skills:

Manipulating 2- and N-dimensional arrays implemented with nested lists

Recursively exploring simple graphs and nested data structures

Writing doctests and documenting functions

Since most of the difficulty of this lab lies in implementing recursive functions, please do not use

standard library modules that use recursion behind the scenes, such as itertools .

Part 2 of this lab is tricky; please plan accordingly.



So what i have so far:

def dump(game):
    
    lines = ["dimensions: {}".format(game["dimensions"]),
             "board: {}".format("\n       ".join(map(str, game["board"]))),
             "mask:  {}".format("\n       ".join(map(str, game["mask"])))]
    print("\n".join(lines))

def new_game(num_rows, num_cols, bombs):
   
    game = {}
    game['dimensions'] = [num_rows, num_cols]
    game['mask'] = [[False]*num_cols]*num_rows
    game['board'] = [[0]*num_cols]*num_rows
    bomb_num = len(bombs)
    if bom_num == 0:
        return game

    return game
Reply all
Reply to author
Forward
0 new messages