Skip to content

Instantly share code, notes, and snippets.

@pikajude
Created May 11, 2011 05:04
Show Gist options
  • Select an option

  • Save pikajude/965940 to your computer and use it in GitHub Desktop.

Select an option

Save pikajude/965940 to your computer and use it in GitHub Desktop.
<script type="text/javascript">function count_tiles() {
var str = prompt("Please enter your mapdata:");
if(str == null || str == "") { return; }
var msg = "";
var tiles = {"1": '3|4|5|2', "2": 'G|H|I|F', "3": '\\?|@|A|>', "4": '7|8|9|6', "E": '1', "5": 'Q|N|O|P', "6": 'J|K|L|M', "7": 'C|D|E|B', "8": ';|<|=|:', "D": "0"}
var counts = {}
var total = 0
for (var key in tiles) {
var count = str.split(new RegExp(tiles[key], "g")).length - 1
msg += ("There are " + count + " '" + key + "' tiles.\n")
if(key == "D") { console.log("There are " + (713 - count) + " total filled tiles.") }
}
alert(msg)
}</script>
<button onclick="count_tiles()">Mapdata</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment