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
#!/bin/sh | |
if [ -z "$*" ]; then echo "Missing folder"; exit 1; fi | |
for d in $1; do | |
if [ -d "$d" ]; then | |
cd "$d" | |
exiftool -n -q -p '${Duration;our $sum;$_=ConvertDuration($sum+=$_)}' ./*.mp3| tail -n1 | |
fi | |
done |
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
pub fn solution<'a>( | |
board_stack: &mut VecDeque<(Board, Vec<ChessPiece>)>, | |
solutions: &'a mut HashSet<Board>, | |
tested_configurations: &mut HashSet<Board>, | |
) -> &'a HashSet<Board> { | |
while !board_stack.is_empty() { | |
let (board, pieces) = board_stack.pop_back().unwrap(); | |
for row in 1..=board.m { | |
for col in 1..=board.n { | |
let new_piece = Piece { |
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
func SamePices(used1,used2 []primitives.Attacks) { | |
u1:=append([]primitives.Attacks{},used1…) | |
u2:=append([]primitives.Attacks{},used2…) | |
for _,u := range [][]primitives.Attack{u1,u2} { | |
sort.Sort(u, func (i,j int) bool { | |
x,y:=u[i],u[j] | |
if x.Row()!=y.Row() { return x.Row()<y.Row() } | |
if x.Col()!=y.Col() { return x.Col()!=y.Col() } | |
return x.Name()<y.Name() |
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
package main | |
import "fmt" | |
type ChessPiece struct { | |
row int | |
col int | |
piece rune | |
} | |
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
done::Board->Bool | |
done Board{usedPieces = up, numberOfPieces=n} = length up == n |
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
findCandidate :: ChessPiece -> Board -> Set Board | |
findCandidate p b | |
= Data.Set.fromList $ | |
[ newBoard | |
| rr <- [1 .. (m b)] | |
, cc <- [1 .. (n b)] | |
, let pp = createPiece (piece p) rr cc | |
, let newBoard = place b pp | |
, isSafe b pp] |
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 PieceType = Rook | Bishop | Knight | Queen | King deriving(Show, Eq, Ord) | |
data ChessPiece = Piece {row:: !Int, col:: !Int, piece:: PieceType} deriving(Eq, Ord) | |
data Board = Board{m:: !Int, n:: !Int, usedPieces:: Set ChessPiece , numberOfPieces:: !Int} deriving(Eq, Ord) |
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
/*** | |
* @param board ChessBoard | |
* @param pieces Chess Pieces selected by the user | |
* @param solutions valid solutions to the problem | |
* @param testedConfigurations Board configurations to which solutions were not found | |
* @return return a list of possible solutions to the problem in the form of a list of filled chess boards | |
*/ | |
public static Set<Board> solution(Board board, List<Character> pieces, Set<Board> solutions, Set<Board> testedConfigurations) { | |
if (!pieces.isEmpty()) { // if pieces is empty I return the solutions | |
for (int i = 1; i < board.getM(); i++) { |
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
public class Board { | |
private int M; | |
private int N; | |
private char[][] board; | |
private ArrayList<ChessPiece> usedPieces; | |
} |
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
public class Bishop extends ChessPiece { | |
public boolean attacks(ChessPiece dest) { | |
return Math.abs(dest.getRow() - this.getRow()) == Math.abs(dest.getCol() - this.getCol()); | |
} | |
@Override | |
public char piece() { | |
return 'B'; | |
} |
NewerOlder