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
//change this array and play with Bubble Sort! | |
a = [1,43,5,67,8,912,3,465,89,89,82,34] | |
println a.size() | |
for(out in (a.size()-2)..2) | |
{ | |
0.upto(out) { index -> | |
if(a[index] > a[index+1]) | |
swap(index,index+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
//change this array and play with selection sort :) | |
a = [2,34,4,123,45,56,3,56,67,87,21,45,56,67,22,4234,4234,2342,1,34,546,67,677,343,4,41,32,456,1341,13,454,234,453,565,5,524,234,234,5456,567,673,245,567,78,78,324,56576,782,435,676,873,2,345,6767,7,3463,3,6767673,34534,2,345,656,3,5652,1,34345,3453545,35345356,66,7883345,676787,8988] | |
b = a | |
long startTime = System.currentTimeMillis(); | |
(0..(a.size()-2)).each { | |
minimumValue = it | |
(it+1).upto(a.size()-1){ insideElement -> | |
if(a[insideElement] < a[minimumValue]) | |
minimumValue = insideElement | |
} |
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
input = args[0] as Integer | |
top = -1 | |
stack = new long[input] | |
def push(long j) | |
{ | |
stack.putAt(++top,j) | |
} | |
def pop() | |
{ | |
stack.getAt(top--) |
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
/* | |
These two inputs input and input2 are passed via command line | |
*/ | |
//input as a String for reversal! | |
input2 = args[1] | |
//input for the size of Stack! | |
input = args[0] as Integer | |
top = -1 | |
stack = new String[input] | |
boolean full = false |
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
/* | |
These two inputs input and input2 are passed via command line | |
*/ | |
input2 = args[0] | |
//input for the size of Stack! | |
input = input2.size() | |
top = -1 | |
stack = new String[input] | |
boolean full = false | |
def push(String j) |
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
<html> | |
<head> | |
<title>Play With Pixel</title> | |
<style> | |
canvas { margin: 0px auto 0; display: block; } | |
</style> | |
</head> | |
<body> | |
<canvas id="canvas" height="900" width="800"></canvas> | |
<script> |
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
//a book keep! | |
def a = ["grails","griffon","gradle","groovy"] | |
//user sentence | |
def sentence = "gralis grfifon grovoy gralde" | |
def split = sentence.split(' ') | |
def bool = false | |
split.each { | |
i = 0 | |
def temp = [] | |
temp << it.split{it=""} |
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
//http://cse0812.blogspot.in/2012/02/problem-from-top-coder.html | |
def a = [".15", "7..", "402", "..3"] | |
c = a.permutations() as List | |
ans = [] | |
c.each { | |
ans << it.join().tokenize('.')*.toList().collect{ it*.toInteger().sum() } | |
} | |
println ans.flatten().max() |
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 <stdio.h> | |
#define INSIDEWORD 1 | |
#define OUTSIDEWORD 0 | |
#define MAXWORD 10 | |
main() { | |
char c; | |
int i=0,j,state= OUTSIDEWORD,words =0, ndigits[10],length=0; | |
for(i=0;i<10;i++) | |
ndigits[i] = 0; | |
while((c = getchar()) != EOF) |
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
String.metaClass.nutritions = { | |
def pro = [Carbohydrates:0.0,Protein:24.68,Fat:12.56, | |
Water:63.93] | |
if(delegate.toLowerCase() == "chicken") | |
{ | |
println "--------$delegate Properties is--------" | |
pro.each { k,v -> | |
print k + " found in chicken is " | |
println v |