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
Grid problems are almost always just graph problems and typically straightforward ones. I initially found them a bit weird because in algorithm classes they present graphs as adjacency nodes or adjacency matrices. In a grid, each cell is a node, and it's neighbors are the four-directional neighboring cells or sometimes 8-directional, if the problem at hand allows travel in all the diagonals in addition to up, down, left, right. The vertices are not explicit but usually we don't need to worry about them in these problems. | |
There is nothing special about a grid vs another type of graph representation. Just need to tweak the grpah algorithms at our disposal. | |
Basic graph techniques: | |
BFS- traverses the entire graph, going layer by layer expanding from the starting point. It allows us to do a couple of things, count connected components in a graph, find the shortest distance from one cell to another cell. While traversing, | |
we need to track visited cells. You can do that by changing the cell value (coloring) or r |
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
/** | |
* OpenCV video streaming over TCP/IP | |
* Client: Receives video from server and display it | |
* by Steve Tuenkam | |
*/ | |
#include "opencv2/opencv.hpp" | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
#include <unistd.h> |
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
byte PWM_IN = 3; // PWM input to be read at Arduino UNO's PWM pin 3 | |
int value; | |
void setup() | |
{ | |
pinMode(PWM_IN, INPUT); // initialising PWM_IN as an input pin | |
Serial.begin(115200); // serial begin at 115200 bauds | |
Serial.println (" Servo Angle Decoder "); | |
} |
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
// the input to be sent to arduino is like " 1:90 " , " 0:45 " 2:135" to direct servo to go to that positions | |
#include <Servo.h> | |
int servoCount = 10; | |
int servoPins[] = {2,3,4,5,6,12,11,10,9,8}; | |
Servo servos[10]; | |
void setup() { | |
Serial.begin(115200); |
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
#include <Servo.h> | |
Servo myservo; | |
int pos = 0; | |
void setup() { | |
myservo.attach(9); | |
Serial.begin(9600); | |
} | |
int jatin=2000; // interval for which servo will sweep |
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
int ledpin=13; // led on pin 13 | |
void setup() { | |
pinMode(ledpin,OUTPUT); | |
Serial.begin(9600); // serial monitor | |
} | |
int interval=4000; // time for led to remain on | |
unsigned long cm; // current milisecond |