Skip to content

Instantly share code, notes, and snippets.

@wuoix
wuoix / cubeSpawner.cs
Created January 17, 2015 20:34
CubeSpawner
using UnityEngine;
using System.Collections;
public class CubeSpawner : MonoBehaviour {
public GameObject cube;
void Start() {
StartCoroutine(spawnCubes());
}
@wuoix
wuoix / spiral.cpp
Created November 4, 2013 18:25
Coding Interviews Spiral Code Solution
int * spiral(int r, int c, int sr, int sc) {
//Traverse direction increment state and direction state
// %4 == 1 -> north; 2 -> east; 3 -> south; 0 -> west;
int *array = new int [r*c];
int counter = 1, steps, dir, increment, arridx = 0;
bool vertical = true;
array[arridx++] = matrix[sr-1][sc-1];
while(arridx < r*c) {
dir = counter % 4;
vertical = dir == 1 || dir == 3 ? true : false;