Giter VIP home page Giter VIP logo

i.gamebot's People

Contributors

cristi-zmf avatar ds012012 avatar onacaioana avatar ubernuke avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

i.gamebot's Issues

Joining lists of lists

student@306-WS10:/tmp$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> 
>>> 
>>> set_winc_1 = set(['a1', 'a2', 'a3', 'a4'])
>>> 
>>> 
>>> 
>>> 
>>> 
>>> wcomb1 = ['a1', 'a2', 'a3', 'a4']
>>> 
>>> 
>>> tkp = 'b3'
>>> 
>>> 
>>> tkp in wcomb1
False
>>> in(tkp, wcomb)
KeyboardInterrupt
>>> 
student@306-WS10:/tmp$ vim zzz.py
student@306-WS10:/tmp$ gedit zzz.py
student@306-WS10:/tmp$ 
student@306-WS10:/tmp$ 
student@306-WS10:/tmp$ 
student@306-WS10:/tmp$ python -i zzz.py
>>> 
>>> 
>>> WINNING_COMBINATIONS
{'c1c2c3c4': ['c1', 'c2', 'c3', 'c4'], 'a1b1c1d1': ['a1', 'b1', 'c1', 'd1'], 'a4b4c4d4': ['a4', 'b4', 'c4', 'd4'], 'a2b2c2d2': ['a2', 'b2', 'c2', 'd2'], 'a4b3c2d1': ['a4', 'b3', 'c2', 'd1'], 'a1a2a3a4': ['a1', 'a2', 'a3', 'a4'], 'd1d2d3d4': ['d1', 'd2', 'd3', 'd4'], 'a1b2c3d4': ['a1', 'b2', 'c3', 'd4'], 'b1b2b3b4': ['b1', 'b2', 'b3', 'b4'], 'a3b3c3d3': ['a3', 'b3', 'c3', 'd3']}
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> t = 'a1'
>>> 
>>> 
>>> WCOMB_FOR_TOKEN[t]
['a1a2a3a4', 'a1b1c1d1', 'a1b2c3d4']
>>> 
>>> 
>>> 
>>> 
>>> my_win_c = [ WINNING_COMBINATIONS[x] for x in WCOMB_FOR_TOKEN[t] ]
>>> my_win_c
[['a1', 'a2', 'a3', 'a4'], ['a1', 'b1', 'c1', 'd1'], ['a1', 'b2', 'c3', 'd4']]
>>> 
>>> 
>>> my_win_c.join()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'join'
>>> 
>>> 
>>> dir(my_win_c)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>> 
>>> 
>>> 
>>> 
>>> import itertools
>>> 
>>> 
>>> 
>>> 
>>> 
>>> list(itertools.chain(*my_win_c))
['a1', 'a2', 'a3', 'a4', 'a1', 'b1', 'c1', 'd1', 'a1', 'b2', 'c3', 'd4']
>>> 
>>> 
>>> list(itertools.chain(my_win_c))
[['a1', 'a2', 'a3', 'a4'], ['a1', 'b1', 'c1', 'd1'], ['a1', 'b2', 'c3', 'd4']]
>>> 
>>> 
>>> 
>>> joined_list = list(itertools.chain(*my_win_c))
>>> 
>>> 
>>> id (my_win_c)
139963468717736
>>> 
>>> 
>>> id(joined_list)
139963468786000
>>> 
>>> 
>>> 
>>> 
>>> 
>>> tkp in joined_list
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'tkp' is not defined
>>> 
>>> 
>>> 
>>> tkp = 'b3'
>>> 
>>> 
>>> tkp in joined_list
False
>>> tkp = 'c3'
>>> 
>>> 
>>> tkp in joined_list
True

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.