Skip to content

Instantly share code, notes, and snippets.

View ray-dino's full-sized avatar

Ray Diño ray-dino

View GitHub Profile
$(function() {
});
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 14.5833, lng: 121.00},
zoom: 11
});
def bubble_sort(numlist):
for i in range(0, 9):
for j in range(0, 9):
if numlist[j] > numlist[j+1]:
numlist[j], numlist[j+1] = numlist[j+1], numlist[j]
return numlist
@ray-dino
ray-dino / queens.py
Last active February 22, 2016 02:12
Place 8 Queens on an 8x8 chessboard where no 2 Queens threaten each other
def check_conflict(path, new_pos):
'''
path: list of tuples of current path.
new_pos: tuple (x, y) of new position.
'''
# print "check conflict {} {}".format(path, new_pos)
for p in path:
b1 = (p[0] + p[1]) % 8
b2 = p[1] - p[0]
if p[0]==new_pos[0] or p[1]==new_pos[1]:
```
programming challenge question:
100 people standing in a circle in an order 1 to 100.
No. 1 has a sword. He kills the next person (i.e. No. 2) and gives the sword to the next (i.e. No. 3).
All people do the same until only 1 survives. Which number survives at the last?
```
people = [i for i in range(1, 101)]
a = True
for p in people:
@ray-dino
ray-dino / twitter_public_stream_sample.json
Created November 9, 2015 02:57
Sample JSON result from Twitter's Public Stream API
This file has been truncated, but you can view the full file.
{u'contributors': None, u'truncated': False, u'text': u'Adele - Hello \nLiterally brought me to tears... https://t.co/pe39fN8DXQ', u'is_quote_status': False, u'in_reply_to_status_id': None, u'id': 657576404570083328, u'favorite_count': 0, u'source': u'<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone</a>', u'retweeted': False, u'coordinates': None, u'timestamp_ms': u'1445613406685', u'entities': {u'user_mentions': [], u'symbols': [], u'hashtags': [], u'urls': [{u'url': u'https://t.co/pe39fN8DXQ', u'indices': [48, 71], u'expanded_url': u'http://youtu.be/YQHsXMglC9A', u'display_url': u'youtu.be/YQHsXMglC9A'}]}, u'in_reply_to_screen_name': None, u'id_str': u'657576404570083328', u'retweet_count': 0, u'in_reply_to_user_id': None, u'favorited': False, u'user': {u'follow_request_sent': None, u'profile_use_background_image': True, u'default_profile_image': False, u'id': 552458224, u'verified': False, u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/656573615547088896/cH