🤷♂️
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
| using UnityEngine; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| [ExecuteInEditMode] | |
| public class monkey : MonoBehaviour { | |
| private Mesh mesh; | |
| private List<Vector3> verts = new List<Vector3>(){ | |
| new Vector3(1f, 1f, -1f), |
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
| function checkVersion() | |
| { | |
| // jQuery 1.3+ .live | |
| // jQuery 1.4.3+ .delegate | |
| // jQuery 1.7+ .on | |
| var vernums = $.fn.jquery.split('.'); | |
| if(vernums.length >=2 ) | |
| { | |
| // if there is no 3rd param set to zero | |
| if(vernums.length == 2) vernums[2] = 0; |
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
| var LinkedList = function() { | |
| this.head = null; | |
| this.tail = null; | |
| var Node = function(data) { | |
| this.data = data; | |
| this.next = null; | |
| }; | |
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
| function binarySearch(target, data) | |
| { | |
| if(data.length <= 0) return -1; | |
| if(data.length == 1 && data[0] != target) return -1; | |
| var midpoint = Math.floor(data.length/2); | |
| if(data[midpoint] == target) | |
| { | |
| return true; | |
| } else { |
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
| def merge_sort(l, first_iteration=False): | |
| data = [] | |
| if first_iteration: | |
| return merge_sort([[i] for i in l]) | |
| else: | |
| for i in xrange(0, len(l), 2): | |
| left, right = l[i], l[i+1] if i != len(l)-1 else [] | |
| subdata = [] | |
| for l_item in list(left): | |
| for r_item in list(right): |
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
| letters = 'aaaabbbbbbbcccddddddddeeeee' | |
| data = {} | |
| for letter in letters: | |
| if letter in data: | |
| data[letter] += 1 | |
| else: | |
| data[letter] = 1 | |
| # which letter has the most repeating chars | |
| l = max(data.iterkeys(), key=lambda k: data[k]) |
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
| def main(): | |
| for i in xrange(1, 101): | |
| if i % 3 == 0 and i % 5 == 0: | |
| print('%d FizzBuzz' % i) | |
| elif i % 3 == 0: | |
| print('%d Fizz' % i) | |
| elif i % 5 == 0: | |
| print('%d Buzz' % i) | |
| else: | |
| print(i) |
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
| def quick_sort(l, start=None, end=None): | |
| # get the length of our working list | |
| list_len = len(l[start:end]) | |
| # if this is the first iteration end is length of whole list | |
| end = len(l) if end is None else end | |
| # choose the last item of working list as pivot | |
| pivot = l[end-1] | |
| # set wall left of first element in working list | |
| wall_index = start-1 if start is not None else -1 | |
| # set the current element we start with to after wall (first element in working list) |
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
| def inplace_insertion_sort(unsorted_list, split_index=None): | |
| # if we have no split_index yet we know this is first iteration so lets split it | |
| split_index = 1 if not split_index else split_index | |
| # loop over each item in unsorted list | |
| for uitem in unsorted_list[split_index:len(unsorted_list)]: | |
| # reverse the sorted list to loop over as we compare right to left | |
| for index, sitem in enumerate(reversed(unsorted_list[:split_index])): | |
| if uitem > sitem: | |
| # remove from unsorted so we don't look at it again | |
| unsorted_list.remove(uitem) |
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
| def bubble_sort(l): | |
| # keep track of if we did any swapping | |
| swapped = False | |
| # loop over all elements in list | |
| for i in xrange(0, len(l), 1): | |
| # look at this item and the next and see if they need to swap | |
| if i != len(l) - 1: | |
| if l[i] > l[i + 1]: | |
| l[i], l[i + 1] = l[i + 1], l[i] | |
| swapped = True |