This file contains hidden or 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
| data Particle = Particle { mass :: Float, xPos :: Float, yPos :: Float} | |
| --probably silly | |
| delta z a b = z a - z b | |
| deltaX = delta xPos | |
| deltaY = delta yPos | |
| dist a b = sqrt (deltaX a b ** 2 + deltaY a b ** 2) |
This file contains hidden or 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.LinkedHashSet; | |
| public class Permutation { | |
| private LinkedHashSet<String> set; | |
| private String s; | |
| private boolean found; | |
| Permutation(String s){ | |
| this.s = s; | |
| found = false; |
This file contains hidden or 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
| sumPair :: [Int] -> Int -> [(Int,Int)] | |
| sumPair xs num = helper xs num [] | |
| where helper [] _ [] = [] | |
| helper [] _ [z] = [] | |
| helper [] num (z:zs) = helper (z:zs) num [] | |
| helper (x:[]) _ [] = [] | |
| helper (x:[]) num zs = helper zs num [] | |
| helper (x:y:xs) num [] | |
| | x + y == num = (min x y,max x y):(helper xs num []) | |
| | otherwise = helper (x:xs) num [y] |
This file contains hidden or 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
| sumPair options num :: [Int] -> Int -> [(Int,Int)] | |
| sumPair options num = [(x,y) | x <- options, y <- options, x + y == num, x < y] ++ [(x,x) | x <- options, x*2 == num] |