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
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
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
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
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
# 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)) |
NewerOlder