Skip to content

Instantly share code, notes, and snippets.

View pallavagarwal07's full-sized avatar
🙋‍♂️

Pallav Agarwal pallavagarwal07

🙋‍♂️
View GitHub Profile
@pallavagarwal07
pallavagarwal07 / ipaddr
Last active August 29, 2015 14:22
Public IP of web server
117.197.58.189
### Keybase proof
I hereby claim:
* I am pallavagarwal07 on github.
* I am pallavag (https://keybase.io/pallavag) on keybase.
* I have a public key whose fingerprint is EF10 9599 EBA3 EA30 B549 444E EDBB 91C1 DA77 D79D
To claim this, I am signing this object:
@pallavagarwal07
pallavagarwal07 / seive.c
Last active August 27, 2015 09:46
Sieve of eratosthenes
#define N 1000001
int seive[N];
void fillSieve(){
int i, j;
seive[0] = seive[1] = 1; // 0, 1 aren't primes
int n = sqrt(N);
i = 2;
for(j=2; i*j<N; j++)
seive[i*j] = 1;
for(i=3; i<=n; i+=2){
@pallavagarwal07
pallavagarwal07 / prime_list.c
Created August 27, 2015 09:52
Code to generate array of primes
int prime_list[N], len=0;
int seive[N];
void fillSieve(){
int i, j;
seive[0] = seive[1] = 1; // 0, 1 aren't primes
int n = sqrt(N);
i = 2;
for(j=2; i*j<N; j++)
seive[i*j] = 1;
for(i=3; i<=n; i+=2){
@pallavagarwal07
pallavagarwal07 / print_arr.c
Created August 27, 2015 09:53
Pretty print a 1D array.
void printArr(int n, int arr[]){
int i, j;
for(i=0; i<n; i+=10){
for(j=i; j<n && j<i+10; j++){
printf("%d\t", arr[j]);
}
printf("\n");
}
}
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
{
stdenv = { pkgs }: pkgs.stdenv //
{
mkDerivation = args: pkgs.stdenv.mkDerivation (args //
{
makeFlags = (if ( args ? makeFlags && args.makeFlags != null )
then args.makeFlags else []) ++ ["-j8" "-l8"];
});
};

Kitchen Timetable

There are N students living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head of the dormitory came up with a timetable for kitchen's usage in order to avoid the conflicts:

  • The first student starts to use the kitchen at the time 0 and should finish the cooking not later than at the time A1.
  • The second student starts to use the kitchen at the time A1 and should finish the cooking not later than at the time A2.
  • And so on.
  • The N-th student starts to use the kitchen at the time AN-1 and should finish the cooking not later than at the time AN

The holidays in Berland are approaching, so today each of these N students wants to cook some pancakes. The i-th student needs Bi units of time to cook.

[H[J[1;1H[?25l[m[H[J[1;1H[2;27HGNU GRUB version 2.02~beta2
[m[4;2H+----------------------------------------------------------------------------+[5;2H|[5;79H|[6;2H|[6;79H|[7;2H|[7;79H|[8;2H|[8;79H|[9;2H|[9;79H|[10;2H|[10;79H|[11;2H|[11;79H|[12;2H|[12;79H|[13;2H|[13;79H|[14;2H|[14;79H|[15;2H|[15;79H|[16;2H|[16;79H|[17;2H+----------------------------------------------------------------------------+[m[18;2H[19;2H[m Use the ^ and v keys to select which entry is highlighted.
Press enter to boot the selected OS, `e' to edit the commands
before booting or `c' for a command-line. [5;80H [7m[5;3H*Gentoo GNU/Linux [m[5;78H[m[m[6;3H Advanced options for Gentoo GNU/Linux [m[6;78H[m[m[7;3H [m[7;78H[m[m[8;3H [m[8;78H[m[m[9;
Yes
OpenSCAD
ReactOS
Gentoo
No
https://gist.github.com/dufferzafar/efa128fca955d524be2907bb4d7347a6