This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this is a side helper class to perform vector calculations, that are useful for certain movement and calculations | |
| function Vector2(x,y){ | |
| this.x = (x === undefined) ? 0 : x; | |
| this.y = (y === undefined) ? 0 : y; | |
| } | |
| Vector2.prototype = { | |
| unit: function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # code to sort a list based on second index | |
| lst = [[1,"e"],[2,"t"],[9,"a"][5,"r"][4,"b"]] | |
| ans = sorted(lst,key=lambda x: (x[1], x[0])) |