Skip to content

Instantly share code, notes, and snippets.

@kdclmn
kdclmn / physics.html
Created December 20, 2015 09:28
html/js forces simulator
<!DOCTYPE html>
<html>
<style>
div{ margin-top:10px; font-size: .9em;}
input[type='number']{width:25px;}
#info{}
#clickSetting{}
.container{position:inherit;float:right; left:850px;padding:10px; width:500px; height:600px; }
</style>
@kdclmn
kdclmn / dictionary lookup
Created December 13, 2013 03:36
Copy and paste code into a new Java (BlueJ) window and run it
public static void main()
{
String[] names_F = { "Julia ", "Maddy ", "Rachel ", "Kristi ", "Emily ", "Sophie "};
String[] names_M = { "Graham ", "Joey ", "Matt ", "Sammy ", "Aaron "};
String[] pnouns = { "I ", "you ", "me ", "him ", "her ", "it "/*5*/,"my ","you're ","anyone ", "one "/*9*/,"It's "};
String[] words = {
"information ", "future ", "anyone ", "Dear ", "for ", "life ", "love ", "will ", "encrypt ", "advantage ",
"power ", "struggle ", "hate ", "never ", "again ", "find ", "miss ", "this ", "that ", "really ", "would ", "because ",
"know ", "honestly ", "afraid ", "consider ", "even ", "in ", "the ", "near ", "was ", "want ", "rest ","am ","writing ",
"of ","feelings ","don't ", "and ","didn't ","stuff ", "only ","to ","take ","do ","have ","tomorrow ", "wrists ", "plays ",
@kdclmn
kdclmn / codinbat
Created November 5, 2012 07:56
Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and right are gone. So "ab*cd" yields "ad" and "ab**cd" also yields "ad". starOut("ab*cd") → "ad" starOut("ab**cd") → "ad" starOu
public String starOut(String str) {
String str1 = "";
int count = 0;
int[] x = new int[str.length()*2];
boolean v = true;
if(str.equals("*"))
{
return "";
}
for(int i = 0;i<str.length();i++)
@kdclmn
kdclmn / Encrypt
Created August 13, 2012 21:25
encryptions
import java.util.*;
public class Encryption
{
private ArrayList<String> letters = new ArrayList<String>();
private int[] pos = new int[letters.size()];
private String alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private String newest = "";
public int getNum(String x)
{
return alph.indexOf(x);
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.image.*;
import java.awt.event.*;
public class intersections extends JFrame
{
private GraphicRectangle right;
private GraphicRectangle left;
private GraphicRectangle top;
@kdclmn
kdclmn / gist:1470955
Created December 13, 2011 06:47
Given 2 int arrays, a and b, of any length, return a new array with the first element of each array. If either array is length 0, ignore that array. front11({1, 2, 3}, {7, 9, 8}) → {1, 7} front11({1}, {2}) → {1, 2} front11({1, 7}, {}) → {1}
public int[] front11(int[] a, int[] b) {
int[] tempS = new int[2];
int[] tempA= new int[1];
if(a.length<1 || b.length<1){
if(a.length<1){
tempA[0]=b[0];}
if(b.length<1){
tempA[0]= a[0];}
}
@kdclmn
kdclmn / help
Created December 3, 2011 19:54
the error is: java.lang.ArrayIndexOutOfBoundsException: 2 at ArrayOps.findNegatives(ArrayOps.java:68) at ArrayDemo.main(ArrayDemo.java:11)
public int[] findNegatives(int[] x)
{
int[] array = new int[100];
int count =0;
for (int index =0; index<x.length; index++)
{
if( (x[index]*-1) > 0)
{
array[count]=index;
public static void main2()
{
int counter = 0;
boolean playGame = (true);
char lastBoard[][]=new char[3][3];
System.out.println("Please enter a number: ");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();
int x = choice%3;
int y = choice/3;
// i know that i named the class incorrectly
import java.util.* ;
import java.lang.Character;
public class RockPaperSiccors
{
public static void main(String[] args)
{
int n = 0;