This file contains hidden or 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
use std::collections::HashMap; | |
use std::io; | |
fn keypad_code(s: &String) -> String { | |
let keypad = HashMap::from([ | |
('0', (3, 1)), | |
('A', (3, 2)), | |
('1', (2, 0)), | |
('2', (2, 1)), | |
('3', (2, 2)), | |
('4', (1, 0)), |
This file contains hidden or 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
{ | |
"url": "https://www.youtube.com/watch?v=cBEsK7Z9zos", | |
"title": "testing", | |
"segments": [{ | |
"start": 0, | |
"end": 78.44 | |
}], | |
"captions": [{ | |
"start": 0, | |
"end": 2.47, |
This file contains hidden or 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
nub' :: [Int] -> [Int] | |
nub' (x:xs) | elem x xs = nub' xs | |
| otherwise = x:(nub' xs) | |
nub' [] = [] | |
nub = reverse . nub' . reverse |
This file contains hidden or 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 <iostream> | |
using namespace std; | |
int main() | |
{ | |
int T; | |
cin >> T; | |
for (int kase = 1; kase <= T; ++kase) | |
{ int d; | |
int limit = 0, cur = 0, cha = 1, ans = 0; | |
string s; |
This file contains hidden or 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 <stdio.h> | |
#include <math.h> | |
double f (double x) | |
{ | |
return x*x*x - 2 *x + 2; | |
} | |
double df(double x) | |
{ |
This file contains hidden or 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 <stdio.h> | |
#include <string.h> | |
void init(int d[9][9]) | |
{ for (int i = 0; i < 9; ++i) | |
for (int j = 0; j < 9; ++j) | |
d[i][j] = (i == j) ? 0 : -1; | |
d[0][1] = 4; d[0][7] = 8; | |
d[1][0] = 4; d[1][7] = 11; d[1][2] = 8; | |
d[2][1] = 8; d[2][8] = 2; d[2][3] = 7; d[2][5] = 4; |
This file contains hidden or 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
import java.io.*; | |
import java.net.*; | |
class P2Server | |
{ public static void main(String args[]) throws Exception | |
{ DatagramSocket serverSocket = new DatagramSocket(9090); | |
// System.out.println("Server now running on 9090..."); | |
while (true) | |
{ DatagramPacket receivedPacket = new DatagramPacket(new byte[128], 128); |
This file contains hidden or 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
iterator findMid(iterator& l, iterator& r) const | |
{ | |
iterator slow = l, fast = l; // slow run 1 step , fast run 2 step per loop. | |
while (fast != r) | |
{ | |
if (++fast == r) break; | |
++fast; | |
++slow; | |
} | |
return slow; |