Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <string.h>
int isHappy(char pancakes[1000]);
int main(){
int n;
FILE *ifp = fopen("A-large-practice.in", "r");
FILE *ofp = fopen("ouput.txt", "w");
@jonpchin
jonpchin / count_duplicate.sh
Created May 29, 2017 21:20
Count Duplicates count_duplicate.sh "abcdeaB" => 2
#!/bin/bash
#Count Duplicates count_duplicate.sh "abcdeaB" => 2
total=0
for letter in {a..z} ; do
storage=$(echo "$1" | grep -o -i "$letter" | wc -l)
if [ $storage -gt 1 ]
then
total=$((total+1))
fi
done
@jonpchin
jonpchin / summerfruit256.vim
Created February 1, 2017 16:19
Summerfruit256 color scheme file in C:\Program Files (x86)\Vim\vim80\colors
" Vim color file
" Maintainer: Martin Baeuml <baeuml@gmail.com>
" Last Change: 2008-02-09
"
" This color file is a modification of the "summerfruit" color scheme by Armin Ronacher
" so that it can be used on 88- and 256-color xterms. The colors are translated
" using Henry So's programmatic approximation of gui colors from his "desert256"
" color scheme.
"
" I removed the "italic" option and the background color from
@jonpchin
jonpchin / _virmc
Last active February 2, 2017 22:59
Vim config
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
colorscheme summerfruit256
set guifont=Consolas:h11:cANSI
set number
set backupdir=~/vimtmp/backup//
set directory=~/vimtmp/swap//
set undodir=~/vimtmp/undo//
// Jonathan Chin
// 11/2/15
// My solution to the Array's Force question on Hackerearth.
#include <stdio.h>
int storage[1000001];
long long temp[1000001];
int main(){
@jonpchin
jonpchin / primesieve.c
Created January 14, 2017 05:12
Prime Sieve
#include <stdio.h>
// this is the greatest possible prime number to store in sieve
#define MAXPRIME 50000
int storage[MAXPRIME];
int main(){
int prime[MAXPRIME];
int i;
@jonpchin
jonpchin / cuttingrods.c
Created January 14, 2017 05:10
Finding the max sell price by optimally cutting rods
// Jonathan Chin
// 11/15/2015
// Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n.
// Determine the maximum value obtainable by cutting up the rod and selling the pieces.
#include <stdio.h>
#define MAX(a,b)( ((a)>(b)) ? (a) : (b))
int main()
{
FILE *ifp = fopen("input.txt", "r");
@jonpchin
jonpchin / array.txt
Created January 14, 2017 05:07
Console rotation of 2D array
4 4
1 2 3 4
5 6 7 8
9 0 1 2
9 8 7 6
@jonpchin
jonpchin / editdistance.c
Created January 14, 2017 04:12
Algorithm to quantify how similar two strings are
// Jonthan Chin
// 11/15/15
// Minnimum Edit Distance algorithm which finds the minnimum
//number of character insertions, deletions, or replacements to make one string equal to another string
#include <stdio.h>
#include <string.h>
#define MIN(a,b)( ((a) > (b)) ? (b) : (a))
int main()
{
@jonpchin
jonpchin / eggdrop.c
Last active January 14, 2017 04:12
Classical Egg Drop problem
// Jonathan Chin
// 11/15/15
// Classical Egg drop problem, using dynamic programming
#include <stdio.h>
#include <limits.h>
#define MAX(a, b)( ((a)>(b)) ? (a) : (b))
void eggdrop(int eggs, int height);
int main(){