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<iostream> | |
#include<algorithm> | |
typedef long long ULL; | |
#define MOD_BASE (ULL)1000000007 // NOTE: This is a prime number. | |
using namespace std; | |
template<class T> |
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<iostream> | |
#include<cmath> | |
using namespace std; | |
int main() | |
{ | |
int T; | |
cin>>T; |
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<iostream> | |
#include<string> | |
#include<cstring> | |
using namespace std; | |
int main() | |
{ | |
static int LETTER[28] = {0}; | |
int T; |
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
T = int(input()) | |
while(T>0): | |
T-=1 | |
inp = input() | |
prevRange = 0 | |
dist = 55 # max dist. (=infinity) for first robot | |
collision = False | |
# iterate through input string | |
for c in inp: |
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
/** | |
* Question found here: https://www.codechef.com/OCT18B/problems/MINDSUM | |
* | |
* You are given positive integers N and D. | |
* You may perform operations of the following two types: | |
* add D to N, i.e. change N to N+D | |
* change N to digitsum(N) | |
* Here, digitsum(x) is the sum of decimal digits of x. | |
* For example, digitsum(123)=1+2+3=6 and digitsum(100)=1+0+0=1. | |
* |
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
# define knowledge base | |
class knowledgeBase: | |
class mappingIterator: | |
def __init__(self, key, mappings): | |
self.mappings = mappings | |
self.key = key | |
self.maxlevel = 0 | |
self.curlevel = -1 | |
self.isEmpty = not key in mappings | |
if self.isEmpty: |
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<iostream> | |
#include<string.h> | |
#include<vector> | |
#include<algorithm> | |
using namespace std; | |
#define MAXN 200000 | |
int numarray[MAXN]; | |
vector<long long> sums; |
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
char data = 0; | |
bool flip = true; | |
void setup() | |
{ | |
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission | |
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin | |
} | |
void loop() | |
{ | |
if(Serial.available() > 0) // Send data only when you receive data: |
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
""" | |
Write a program that repeatedly prompts a user for integer numbers untill the user enters 'done'. | |
Once 'done' is entered print out the largest and smallest of the numbers. | |
If user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. | |
Enter 7, 2, bob, 10 and 4 and match the output. | |
Invalid input | |
Maximum is 10 | |
Minimum is 2 | |
""" |
NewerOlder