This file contains 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
# 1 - Import library | |
import pygame | |
from pygame.locals import * | |
import math | |
import random | |
# 2 - Initialize the game | |
pygame.init() | |
width, height = 640, 480 | |
screen=pygame.display.set_mode((width, height)) |
This file contains 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
theBoard = {'7': ' ' , '8': ' ' , '9': ' ' , | |
'4': ' ' , '5': ' ' , '6': ' ' , | |
'1': ' ' , '2': ' ' , '3': ' ' } | |
board_keys = [] | |
for key in theBoard: | |
board_keys.append(key) |
This file contains 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
const firstArray = [4, 9, 5]; | |
const secondArray = [9,4,9,8,4]; | |
let intersection = firstArray.filter((el) => { return secondArray.includes(el); }); | |
console.log(intersection) |
This file contains 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 numbers = [1,3,3,4,4,4] | |
function countDuplicate(numbers){ | |
//write your code here | |
//var result = {} | |
var result = {} | |
numbers.forEach(function(x){ | |
result[x] = (result[x] || 0) + 1; | |
}); | |
numbers.filter((item,x)=>numbers.indexOf(item)==x) |
This file contains 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 countDuplicates(numbers){ | |
//[1,1,1,2,3,3,4,5,6] | |
//[1,3,1,4,5,1,6,3,2] | |
numbers.sort((a,b) => a - b) | |
// sort the array | |
let count = 0 | |
let left = 0 | |
let right = 1 | |
//loop through numbers | |
while (right < numbers.length){ |
This file contains 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
/** | |
* @param {number[]} nums1 | |
* @param {number[]} nums2 | |
* @return {number} | |
*/ | |
let totals = (garray) => { | |
let count = 0; | |
for (let i=0; i < garray.length; i++){ | |
let result = garray[i]; |
This file contains 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
/** | |
* @param {number[]} nums | |
* @param {number} target | |
* @return {number[]} | |
*/ | |
var twoSum = function(nums, target) { | |
let numsObj = new Map() | |
for(let i=0;i<nums.length;i++){ | |
let num = nums[i]; |
This file contains 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
// Returns the first character of the string str | |
var firstCharacter = function(str) { | |
return str.slice(0, 1); | |
}; | |
// Returns the last character of a string str | |
var lastCharacter = function(str) { | |
return str.slice(-1); | |
}; |
This file contains 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
const mysql = require("mysql"); | |
const Json2csvParser = require("json2csv").Parser; | |
const fs = require("fs"); | |
// Create a connection to the database | |
const connection = mysql.createConnection({ | |
host: "localhost", | |
user: "***********", | |
password: "*******", | |
database: "*******" |
This file contains 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
try: | |
from xml.etree.cElementTree import XML | |
except ImportError: | |
from xml.etree.ElementTree import XML | |
import os | |
import re | |
import pathlib | |
import zipfile |
OlderNewer