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
package topcoder; | |
import java.util.*; | |
/** | |
* Problem statement: | |
* http://community.topcoder.com/stat?c=problem_statement&pm=10808&rd=14234 | |
* | |
* I used permutation code from: | |
* http://www.cs.utexas.edu/users/djimenez/utsa/cs3343/lecture25.html |
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
public class LevenshteinDistance | |
{ | |
public static void main(String[] args) | |
{ | |
new LevenshteinDistance().solve(); | |
} | |
public void solve() | |
{ | |
System.out.println(distance("exponential", "polynomial")); // 6 |
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
/************************************************************************* | |
* Compilation: javac LCS | |
* Execution: java LCS < example10.txt | |
* Dependencies: StdIn.java | |
* | |
* Reads in two strings from stdin and computes their longest | |
* common subsequence. | |
* | |
*************************************************************************/ |
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> // for printf | |
#include <cstring> // for memset | |
int main(int argc, char *argv[]) | |
{ | |
int xx[2][2] = {{1,1},{2,2}}; | |
printf("{{%d,%d},{%d,%d}}\n", xx[0][0], xx[0][1], xx[1][0], xx[1][1]); | |
memset(xx, 0, sizeof(xx)); // change to {{0,0},{0,0}} | |
printf("{{%d,%d},{%d,%d}}\n", xx[0][0], xx[0][1], xx[1][0], xx[1][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
/************************************************************************* | |
* Compilation: javac Knapsack.java | |
* Execution: java Knapsack N W | |
* | |
* Generates an instance of the 0/1 knapsack problem with N items | |
* and maximum weight W and solves it in time and space proportional | |
* to N * W using dynamic programming. | |
* | |
* For testing, the inputs are generated at random with weights between 0 | |
* and W, and profits between 0 and 1000. |
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
/************************************************************************* | |
* Compilation: javac FordFulkerson.java | |
* Execution: java FordFulkerson V E | |
* Dependencies: FlowNetwork.java FlowEdge.java Queue.java | |
* | |
* Ford-Fulkerson algorithm for computing a max flow and | |
* a min cut using shortest augmenthing path rule. | |
* | |
*********************************************************************/ |
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
import java.util.Arrays; | |
public class Knapsack1 | |
{ | |
private int n; // number of itens | |
private int k; // capacity | |
private int[][] dp; | |
private Item[] itens; | |
private class Item implements Comparable<Item> { |
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
<!-- https://www.w3.org/TR/html50/forms.html#dom-cva-setcustomvalidity --> | |
<html> | |
<script> | |
function check(input, size) { | |
if (input.value.length < size) { | |
input.setCustomValidity('Favor preencher no mínimo ' + | |
size + ' caracteres.'); | |
} else { | |
input.setCustomValidity(''); |
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
<!-- | |
get the images base64 from the site below: | |
https://material.io/tools/icons/?style=baseline | |
--> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Material Icons</title> | |
<meta name="Description" content="material icons"> |
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> | |
<style> | |
:root { | |
--padding-left: 3px; | |
--padding-top: 30px; | |
} | |
#box1 { | |
padding-left: var(--padding-left); |
OlderNewer