Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Numerous always-ignore extensions
###################
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~

*.sass-cache
# Folders to ignore
###################
.hg
.svn
.CVS
# OS or Editor folders
###################
.DS_Store
Icon?
Thumbs.db
ehthumbs.db
nbproject
.cache
.project
.settings
.tmproj
*.esproj
*.sublime-project
*.sublime-workspace
# Dreamweaver added files
###################
_notes
dwsync.xml
# Komodo
###################
*.komodoproject
.komodotools
2 changes: 1 addition & 1 deletion FoxListeningToMusic.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<li>song 0 -> song 1 (with probability 1/4)</li>
<li>song 1 (with probability 1/2)</li>
</ul>
</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{1, 10, 100, 1000, 10000}</pre></td></tr><tr><td><pre>0</pre></td></tr></table></td></tr><tr><td><pre>Returns: {0.2, 0.2, 0.2, 0.2, 0.2 }</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{5, 8, 4, 7}</pre></td></tr><tr><td><pre>10</pre></td></tr></table></td></tr><tr><td><pre>Returns: {0.1875, 0.3125, 0.1875, 0.3125 }</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{10, 1}</pre></td></tr><tr><td><pre>9</pre></td></tr></table></td></tr><tr><td><pre>Returns: {0.9990234375, 9.765625E-4 }</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">4)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{58, 47, 36, 25, 14, 3}</pre></td></tr><tr><td><pre>100</pre></td></tr></table></td></tr><tr><td><pre>Returns:
</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{1, 10, 100, 1000, 10000}</pre></td></tr><tr><td><pre>0</pre></td></tr></table></td></tr><tr><td><pre>Returns: {0.2, 0.2, 0.2, 0.2, 0.2 }</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{5, 8, 4, 7}</pre></td></tr><tr><td><pre>10</pre></td></tr></table></td></tr><tr><td><pre>Returns: {0.1875, 0.3125, 0.1875, 0.3125 }</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{10, 1}</pre></td></tr><tr><td><pre>9</pre></td></tr></table></td></tr><tr><td><pre>Returns: {0.9990234375, 9.765625E-4 }</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">4)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{58, 47, 36, 25, 14, 3}</pre></td></tr><tr><td><pre>100</pre></td></tr></table></td></tr><tr><td><pre>Returns:
{0.32895835374381194, 0.26291497538241776, 0.18463894970453887, 0.1312301113062895,
0.07518634032025856, 0.017071269542683242 }</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. </p></body></html>
12 changes: 6 additions & 6 deletions FoxListeningToMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ public class FoxListeningToMusic
{
public double[] getProbabilities(int[] length, int T)
{

}

public static void main(String[] args)
{
long time;
double[] answer;
boolean errors = false;
double[] desiredAnswer;

boolean same;

time = System.currentTimeMillis();
answer = new FoxListeningToMusic().getProbabilities(new int[]{1, 2}, 1);
System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
Expand Down Expand Up @@ -200,8 +200,8 @@ public static void main(String[] args)
else
System.out.println("Match :-)");
System.out.println();


if (errors)
System.out.println("Some of the test cases had errors :-(");
else
Expand Down
12 changes: 6 additions & 6 deletions MinimumLiars.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ public int getMinimum(int[] claim)
}
}
}

if (mid == sz) {
return -1;
} else {
return l;
}
}

public static void main(String[] args)
{
long time;
int answer;
boolean errors = false;
int desiredAnswer;


time = System.currentTimeMillis();
answer = new MinimumLiars().getMinimum(new int[]{1,1,1,2});
System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
Expand Down Expand Up @@ -123,8 +123,8 @@ public static void main(String[] args)
else
System.out.println("Match :-)");
System.out.println();


if (errors)
System.out.println("Some of the test cases had errors :-(");
else
Expand Down
10 changes: 5 additions & 5 deletions TheJackpotDivTwo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ public int[] find(int[] money, int jackpot)
Arrays.sort(money);
return money;
}

public static void main(String[] args)
{
long time;
int[] answer;
boolean errors = false;
int[] desiredAnswer;

boolean same;

time = System.currentTimeMillis();
answer = new TheJackpotDivTwo().find(new int[]{1, 2, 3, 4}, 2);
System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
Expand Down Expand Up @@ -177,8 +177,8 @@ public static void main(String[] args)
else
System.out.println("Match :-)");
System.out.println();


if (errors)
System.out.println("Some of the test cases had errors :-(");
else
Expand Down
34 changes: 17 additions & 17 deletions TheNumbersWithLuckyLastDigit.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public int find(int n)
{
return solve(n,0);
}

int solve(int n,int flag) {
int x1 = n/2;
int x2 = n-x1;
Expand All @@ -23,7 +23,7 @@ int solve(int n,int flag) {
}
}
//System.out.println(" ---- " + n + " ----- ");
//System.out.println("" + x1 + " --- " + x2 + "");
//System.out.println("" + x1 + " --- " + x2 + "");
if (solve2(x1,x2)) {
return 2;
} else {
Expand All @@ -42,28 +42,28 @@ int solve(int n,int flag) {
return -1;
}
}

boolean solve2 (int x1, int x2) {

if ( x1 <= 0 || x2 <=0 ) return false;
System.out.println(")))) " + x1 + " --- " + x2 + "");

System.out.println(")))) " + x1 + " --- " + x2 + "");

if (isl(x1)) {
if (isl(x2)) {
return true;
} else {
System.out.println(">>>>> " + (x1-1) + " --- " + (x2+1) + "");
System.out.println(">>>>> " + (x1-1) + " --- " + (x2+1) + "");
return solve2(x1-1,x2+1);
}
} else {
System.out.println("xxxx " + (x1-1) + " --- " + (x2+1) + "");
System.out.println("xxxx " + (x1-1) + " --- " + (x2+1) + "");
return solve2(x1-1,x2+1);
}
}

boolean isl(int n) {

Integer nn = n;
String ns = nn.toString();
//int res = n % (Math.pow( 10*Integer.parseInt(ns.charAt(0)), ns.length()));
Expand All @@ -73,18 +73,18 @@ boolean isl(int n) {
return false;
}
}

public static void main(String[] args)
{
int answer = new TheNumbersWithLuckyLastDigit().find(51);
System.out.println(answer);

/*long time;
int answer;
boolean errors = false;
int desiredAnswer;


time = System.currentTimeMillis();
answer = new TheNumbersWithLuckyLastDigit().find(99);
System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
Expand Down Expand Up @@ -149,8 +149,8 @@ public static void main(String[] args)
else
System.out.println("Match :-)");
System.out.println();


if (errors)
System.out.println("Some of the test cases had errors :-(");
else
Expand Down
28 changes: 14 additions & 14 deletions archive/ActivateGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace std;

#define pb push_back
#define all(v) v.begin(),v.end()
#define sz size()
#define sz size()
#define loop(i,m) for(ui i=0;i<m;i++)
#define loop2(i,m) for(i=0;i<m;i++)
#define loop4m(i,x,m) for(ui i=x;i<m;i++)
Expand Down Expand Up @@ -54,11 +54,11 @@ vvi g;
vector< vector<bool> > act;

int solve( int x, int y ){

cout <<x<<" "<<y<<endl;

if (x > cc || y > rr || x < 0 || y < 0)return 0;

int maxx = 0;
int res;
for(int i = -1 ; i<=1;i++ ){
Expand All @@ -74,16 +74,16 @@ int solve( int x, int y ){
}
}
}

return maxx;
}

int ActivateGame::findMaxScore(vector <string> grid) {

rr= grid.sz;
if(rr > 0)cc= grid[0].sz;
else cc =0;

act.resize(rr);
g.resize(rr);
loop(i,rr){
Expand All @@ -96,9 +96,9 @@ int ActivateGame::findMaxScore(vector <string> grid) {
act[i].pb(false);
}
}

act[0][0]=true;

return solve(0,0);
// return 5;
}
Expand Down Expand Up @@ -205,23 +205,23 @@ double test3() {
int main() {
int time;
bool errors = false;

time = test0();
if (time < 0)
errors = true;

time = test1();
if (time < 0)
errors = true;

time = test2();
if (time < 0)
errors = true;

time = test3();
if (time < 0)
errors = true;

if (!errors)
cout <<"You're a stud (at least on the example cases)!" <<endl;
else
Expand Down
Loading