Skip to content

Instantly share code, notes, and snippets.

View dilanshah's full-sized avatar

Dilan Shah dilanshah

View GitHub Profile
@dilanshah
dilanshah / SingleRiffle.py
Last active March 2, 2018 19:11
write a function to tell if a full deck of cards is a single riffle of two other halves, half1 and half2
# write a function to tell if a full deck of cards is a single riffle of two other halves, half1 and half2
import random
from collections import deque
h1 = deque(random.sample(range(1, 27), 26))
h2 = deque(random.sample(range(27, 53), 26))
print(h1)
print(h2)
shuffled_deck = deque(random.sample(range(1, 53), 52))
@dilanshah
dilanshah / SVVR-49.mdown
Last active March 5, 2018 05:10
summary notes

SVVR Meetup #49

SVVR Passport - A membership program

This is SVVR's new shared co-working space for demonstration

  • 24 hour access
  • Demo equipment and library
  • Digital benefits

SVVR VR Mixer 2018

  • March 21st, 2018
@dilanshah
dilanshah / AudioPeer.cs
Created March 1, 2018 00:07
This script complements the audio visualizer script for initializing the parametric cubes,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class AudioPeer : MonoBehaviour {
AudioSource _audioSource;
// from a sound theory spectrum standpoint all seven of those buckets are remapped to 512 values
public static float[] _samples = new float[512];
@dilanshah
dilanshah / AudioVisualizer.cs
Created March 1, 2018 00:03
This script places parametric cubes in a ring around a user wearing an HMD Audio Visualizer
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Instantiate512Cubes : MonoBehaviour {
public GameObject _sampleCubePrefab;
private GameObject[] _sampleCube = new GameObject[512];
public float _maxScale;
@dilanshah
dilanshah / containsOddDigit.py
Created February 27, 2018 22:37
Given an integer number, write a function that returns true if there are any odd digits in the number; e.g. 2468 -> false, 2478 -> true
'''
"Given an integer number, write a function
that returns true if there are any odd digits in the
number; e.g. 2468 -> false, 2478 -> true"
'''
class Solution():
def containsOdd(self,n):
return any([int(x)%2 for x in list(str(n))])
@dilanshah
dilanshah / mergeTrees.py
Created February 27, 2018 19:44
Leetcode 617. Merge Two Binary Trees. Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
class Solution:
def mergeTrees(self, t1, t2):
"""
:type t1: TreeNode
:type t2: TreeNode
:rtype: TreeNode
"""
if not t1:
return t2
@dilanshah
dilanshah / JudgeRouteCircle.py
Last active February 26, 2018 23:10
return if move sequences qualifies as a valid circle
'''
Initially, there is a Robot at position (0, 0). Given a sequence of its
moves, judge if this robot makes a circle, which means it moves back to
the original place.
The move sequence is represented by a string. And each move is represent
by a character. The valid robot moves are R (Right), L (Left), U (Up) and
D (down). The output should be true or false representing whether the
robot makes a circle.
@dilanshah
dilanshah / predictGender.py
Created February 26, 2018 19:03
taken from siraj raval's python for data science video #1
# decision tree that creates branches for every possible outcome
from sklearn import tree
# list of lists -- each value is the length, width and shoe size
X = [[181,80,44],[177,70,43],[160,60,38],
[154,54,37],[166,65,40],[190,90,47],
[175,64,39],[177,70,40],[159,55,37],
[171,75,42],[181,85,43]]
Y = ['male', 'female', 'female', 'female', 'male', 'male',
@dilanshah
dilanshah / jadoo.py
Created February 25, 2018 06:22
HackerEarth brain teaser
'''
Jadoo hates numbers, but he requires to print a special
number "420" to recharge the equation of life. He asks
your help to print the number but Since he hates numbers,
he asks you to write the program such that there would not
be any number in the code.
'''
# Write your code here
print(sum(ord(c) for c in 'Jado&'))
@dilanshah
dilanshah / hammingDistance.py
Created February 25, 2018 00:31
461. Hamming Distance on Leetcode
'''
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Given two integers x and y, calculate the Hamming distance.
Note:
0 ≤ x, y < 231.
Input: x = 1, y = 4