Skip to content

Commit

Permalink
code jam 2014
Browse files Browse the repository at this point in the history
  • Loading branch information
varunnarisetty committed Aug 7, 2014
1 parent 3c395ab commit 6c2aee3
Show file tree
Hide file tree
Showing 14 changed files with 390 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CodeJam2014/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-openjdk-i386"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions CodeJam2014/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CodeJam2014</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions CodeJam2014/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
100 changes: 100 additions & 0 deletions CodeJam2014/Output.op
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Case #1: 26693.474863443684
Case #2: 228.50440147802922
Case #3: 192.30334
Case #4: 23605.836811034475
Case #5: 92.5
Case #6: 4892.14
Case #7: 3824.236038948276
Case #8: 4243.69897554173
Case #9: 5040.482426704243
Case #10: 24197.507703234274
Case #11: 3133.2440610104304
Case #12: 421.620495
Case #13: 71.390575
Case #14: 69.76488058427103
Case #15: 0.6627485051602314
Case #16: 297.1161194282322
Case #17: 448.5848921083958
Case #18: 1607.0
Case #19: 24314.455590861635
Case #20: 3750.0
Case #21: 134.08607
Case #22: 27843.954793052337
Case #23: 29.00982703210465
Case #24: 3631.0
Case #25: 23563.754660649884
Case #26: 28250.544476823583
Case #27: 23870.22138034242
Case #28: 144.64725
Case #29: 27918.115185402203
Case #30: 26043.370003325348
Case #31: 22890.85138808052
Case #32: 1047.681065731024
Case #33: 60.6480339630439
Case #34: 355.91925135135136
Case #35: 22639.257076759503
Case #36: 2003.6849419890307
Case #37: 25967.674833746074
Case #38: 50.965
Case #39: 25462.19339657641
Case #40: 25723.029569676706
Case #41: 20.826956501632527
Case #42: 2130.9704554161826
Case #43: 82.58914378728888
Case #44: 23.202
Case #45: 0.6484622243230193
Case #46: 58.51
Case #47: 5988.0
Case #48: 24808.51734981645
Case #49: 27772.43708025068
Case #50: 583.2
Case #51: 176.7285436922696
Case #52: 24126.23970532954
Case #53: 3183.0
Case #54: 25448.96093326246
Case #55: 1958.575330242585
Case #56: 24031.57014323717
Case #57: 26.38139671418522
Case #58: 25287.91573602189
Case #59: 86.82569956159577
Case #60: 177.35755798926755
Case #61: 2515.0
Case #62: 24183.506846987773
Case #63: 24038.426220802205
Case #64: 17.043305
Case #65: 0.6629296870263496
Case #66: 306.53031188118814
Case #67: 24044.969685683645
Case #68: 26509.648707528984
Case #69: 237.5
Case #70: 25168.56192779317
Case #71: 140.81198799104143
Case #72: 220.9612278196334
Case #73: 392.133235
Case #74: 359.7540098888581
Case #75: 208.55
Case #76: 3327.5670754493885
Case #77: 262.317446172495
Case #78: 24460.32636857313
Case #79: 23502.789355998975
Case #80: 169.78554228915664
Case #81: 334.9855486489573
Case #82: 27465.338364641015
Case #83: 4245.671735698512
Case #84: 28.85475
Case #85: 24495.4248361239
Case #86: 26154.718279515248
Case #87: 22759.892501319213
Case #88: 5122.926829268293
Case #89: 54.54353
Case #90: 163.7
Case #91: 0.6733996410533737
Case #92: 28011.697613744764
Case #93: 194.160845
Case #94: 99.706055
Case #95: 5251.371339607403
Case #96: 27259.460081103214
Case #97: 323.758
Case #98: 5163.771940639179
Case #99: 6099.0
Case #100: 23131.68040075327
Binary file not shown.
Binary file added CodeJam2014/bin/com/google/cookie/MainClass.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
101 changes: 101 additions & 0 deletions CodeJam2014/input.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
100
9992.42314 1.10977 99952.70807
408.28814 37.87068 1097.70964
762.58634 66.66710 384.60668
9993.73129 1.38221 99956.04764
999.5792 19.83707 185.0
9519.00000 73.00000 9948.00000
6400.0 37.0 56412.0
7954.0 78.0 27596.0
9193.0 68.0 57802.0
9994.82852 1.32300 99948.24968
5501.0 55.0 58094.0
953.04836 34.16854 843.24099
408.79546 48.71694 142.78115
130.17281 42.45454 207.97948
1.05122 99.70875 99999.19814
556.16170 59.67430 1215.61534
743.13574 13.04044 1158.36990
1607.00000 2.00000 3214.00000
9990.40633 1.31119 99968.66557
7322.00000 22.00000 7500.00000
914.45310 40.32641 268.17214
9992.40507 1.02800 99932.80687
53.52207 87.16861 473.93588
7175.00000 23.00000 7262.00000
9994.89156 1.38654 99926.72318
9993.64836 1.00129 99924.34411
9998.63460 1.35609 99965.87572
533.72207 35.35070 289.29450
9993.02554 1.02354 99998.30544
9991.34675 1.16014 99980.54840
9995.39510 1.45998 99990.98488
1469.0 25.0 71661.0
113.63282 75.48612 370.62764
666.0288 35.0 847.47950
9993.88991 1.48809 99948.51432
3616.0 60.0 22060.0
9994.24422 1.16623 99926.53710
10000.00000 76.16 101.93
9993.81110 1.20804 99938.88813
9992.87263 1.18640 99983.54413
40.15595 65.86707 50.83118
3824.0 82.0 91833.0
121.0 20.0807 1199.289
386.12897 87.42968 46.404
1.02770 99.47947 99999.66453
609.61 14.4887 117.02
5988.00000 2.00000 11976.00000
9998.39881 1.26614 99943.78904
9996.46006 1.03337 99941.22136
1029.636 12.4 1166.4
249.08 11.3 837.7452
9995.15197 1.32997 99945.21306
9186.0 69.0 6366.0
9996.01212 1.20987 99992.63141
3229.0 44.0 79561.0
9998.94009 1.33988 99944.92812
27.99 8.2031 321.176
9996.24544 1.22354 99970.43334
168.84001 93.80439 230.47610
259.33048 10.76529 644.19751
2515.00000 2.00000 5030.00000
9997.70659 1.32517 99994.35482
9994.16242 1.33835 99933.48322
66.57339 7.27202 34.08661
1.05038 99.19907 99999.16605
456.041 7.09 713.65419
9990.05997 1.33741 99979.94246
9996.15449 1.12381 99901.01965
939.29643 96.8 475.0
9993.71398 1.23315 99916.82544
267.772 100.0000 898.50084
426.042 86.93 706.12446
898.26241 76.53311 784.26647
593.43 62.6 100000.0000
518.0 74.18 417.1
5604.0 37.0 43378.0
411.3 9.41749 647.0
9992.50352 1.29743 99938.86461
9991.28318 1.39266 99970.93260
325.380 81.0 588.93001
627.15228 39.29307 884.06021
9997.36497 1.05455 99939.75819
3987.0 6.0 40121.0
623.05339 1.57101 57.70950
9996.95968 1.29511 99977.67736
9997.42260 1.15176 99929.79931
9996.36466 1.47441 99919.51461
9992.00000 80.00000 10408.00000
662.75760 9.91274 109.08706
1326.9 48.2 327.4
1.06878 99.88289 99999.90251
9996.67133 1.01723 99917.01874
624.45734 51.76222 388.32169
566.50312 53.56550 199.41211
5314.0 8.0 80041.0
9995.39065 1.06895 99965.35468
745.696 80.27925 647.51600
9216.0 58.0 71167.0
6099.00000 2.00000 12198.00000
9992.42422 1.43245 99954.44207
45 changes: 45 additions & 0 deletions CodeJam2014/src/com/google/cookie/CookieClicker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.google.cookie;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class CookieClicker {

public void solve(String input, String output) throws Exception {

Scanner scan = new Scanner(new File(input));
BufferedWriter out = new BufferedWriter(new FileWriter(output));
int test = Integer.parseInt(scan.nextLine());
for(int i =0;i<test;i++){
String[] values = scan.nextLine().split(" ");
double c = Double.parseDouble(values[0]);
double f = Double.parseDouble(values[1]);
double x = Double.parseDouble(values[2]);
double k = 2.0;
double time = 0.0;

double prev = x/k;
double a = x/(k+f);
double b = (x-c)/k;
while(a < b){
time = time + c/k;

prev = a;

k = k + f;
a = x/(k+f);
b = (x-c)/k;
//System.out.println("loop");
}

time = time + prev;
System.out.println(time);
out.write("Case #"+(i+1)+": "+time+"\n");
}

out.close();
scan.close();
}
}
16 changes: 16 additions & 0 deletions CodeJam2014/src/com/google/cookie/MainClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.google.cookie;

public class MainClass {

public static void main(String[] args) {

CookieClicker cookie = new CookieClicker();
try {
cookie.solve("input.in","Output.op");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
77 changes: 77 additions & 0 deletions CodeJam2014/src/com/google/magictrick/MagicTrick.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.google.magictrick;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class MagicTrick {

public void solve(String input, String output) throws Exception {

Scanner scan = new Scanner(new File(input));
BufferedWriter out = new BufferedWriter(new FileWriter(output));
int test = Integer.parseInt(scan.nextLine());


for(int i =0 ; i <test; i++){

int row = Integer.parseInt(scan.nextLine());
// 1 2 3 4
// 5 6 7 8
// 9 10 11 12
// 13 14 15 16
String[] rows = null;
for(int j=1;j<= 4;j++ ){
if(j == row){
rows = scan.nextLine().split(" ");
}else{
scan.nextLine();
}
}
int col = Integer.parseInt(scan.nextLine());
String[] cols = null;
for(int j=1;j<= 4;j++ ){
if(j == col){
cols = scan.nextLine().split(" ");
}else{
scan.nextLine();
}
}

String result = getResult(rows,cols);

out.write("Case #"+(i+1)+": "+result+"\n");

}



out.close();
scan.close();
}

private String getResult(String[] rows, String[] cols) {
int count =0;
String number = null;
for(int i =0; i < 4; i++){
for (int j =0 ; j < 4; j++){
if(rows[i].equals(cols[j])){
count++;
number = rows[i];
}
}
}

if(count == 0){
return "Volunteer cheated!";
}else if(count == 1){
return number;
}else{
return "Bad magician!";
}


}

}
16 changes: 16 additions & 0 deletions CodeJam2014/src/com/google/magictrick/MainClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.google.magictrick;

public class MainClass {

public static void main(String[] args) {

MagicTrick magic = new MagicTrick();
try {
magic.solve("input.in","Output.op");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
Loading

0 comments on commit 6c2aee3

Please sign in to comment.