Skip to content

Instantly share code, notes, and snippets.

View aaayushsingh's full-sized avatar

Ayush Singh aaayushsingh

View GitHub Profile
int countSumOfTwoRepresentations2(int n, int l, int r) {
if (l==r){ return l*2==n?1:0;}
int c = r-n/2 >= n/2-l ? l: r;
if (n/2<=l||n/2>=r) return 0;
int t=0;
if(n%2==0) t=1;
return Math.abs(n/2-c)+t;
}
int[] codefightsTournament(int p, int s) {
return new int[] {(int)(Math.pow(0.5,p)*4000),p==1?2*s:s};
}
app.get('/',function(req,res){
console.log(req.method+" request received at "+req.url);
request({
url:"https://sc.productrx.com/public/",
method:"GET",
qs:{resource:"schema",data_type:"JSON"}
},function(err,response,body){
log
$ heroku local
[WARN] No ENV file found
11:01:03 AM web.1 | Your server is now running...
11:01:03 AM web.1 | 5000
11:01:07 AM web.1 | GET request received at /
11:01:09 AM web.1 | <!DOCTYPE html>
11:01:09 AM web.1 | <html>
11:01:09 AM web.1 | <head>
@aaayushsingh
aaayushsingh / phonebook.c
Last active July 5, 2017 19:09
phonebook using linked list for mayank
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<malloc.h>
#include<string.h>
struct entry{
char name[50];
char nick[50];
char email[50];
@aaayushsingh
aaayushsingh / hexor.js
Created July 24, 2017 09:11
Gets hexor for the array, init array dynamically when using. {N}, Helfis
var arr = [03,01,00,170,25,01];
var dem = 00;
arr.forEach(function(e) {
dem ^= e;
}, this);
console.log("answer:" + dem.toString(16));
@aaayushsingh
aaayushsingh / BluetoothLEFindActivity.java
Created August 21, 2017 05:08
new, checks permissions
package com.sunflyelec.smartearphone.module.bluetooth.activity;
import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
@aaayushsingh
aaayushsingh / programs.c
Last active September 17, 2017 11:00
c programs vishal
//Program 1, to reverse strings.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) //used to accept command line args
{
if(argc < 2 ){ //check if there are any inputs in command line
printf("please provide inputs"); //if no, exit
exit(1);
import csv
filen = 'full-corpus.csv'
with open(filen) as csv_file:
reader = csv.reader(csv_file, delimiter=',', quotechar='"')
for item in reader:
print(item[0])
function whatsAppText(t) {
window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox = document.querySelector('#main > footer > div.block-compose > div.input-container > div.pluggable-input.pluggable-input-compose > div.pluggable-input-body.copyable-text.selectable-text');
textbox.textContent = t;
textbox.dispatchEvent(event);