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 main | |
import ( | |
"fmt" | |
) | |
func main() { | |
counter := 0 | |
if shouldStartWithOne() { |
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 main | |
import ( | |
"fmt" | |
) | |
func main() { | |
counter := 0 | |
if shouldStartWithOne() { |
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
# This example requires CSVkit (https://github.com/wireservice/csvkit). A Python toolset with a lot of very cool CSV tools. | |
# IMPORTANT NOTE: make sure to use a proper csv file. I had a lot of trouble with a csv file created by a service with Dutch | |
# as locale. Changing it to US solved the problem. Some locales use comma's to seperate point numbers. A semicolon is then | |
# used. | |
# Create table example and Load file-a.csv into it | |
csvsql --db sqlite:///example.db --table example --insert file-a.csv | |
# Add an extra file to table example |
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
func backtrack(board *[9][9]int) bool { | |
if !hasEmptyCell(board) { | |
return true | |
} | |
for i := 0; i < 9; i++ { | |
for j := 0; j < 9; j++ { | |
if board[i][j] == 0 { | |
for candidate := 9; candidate >= 1; candidate-- { | |
board[i][j] = candidate | |
if isBoardValid(board) { |
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
func isBoardValid(board *[9][9]int) bool { | |
//check duplicates by row | |
for row := 0; row < 9; row++ { | |
counter := [10]int{} | |
for col := 0; col < 9; col++ { | |
counter[board[row][col]]++ | |
} | |
if hasDuplicates(counter) { | |
return false |
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
func parseInput(input string) [9][9]int { | |
board := [9][9]int{} | |
scanner := bufio.NewScanner(strings.NewReader(input)) | |
scanner.Split(bufio.ScanRunes) | |
for row := 0; row < 9; row++ { | |
for col := 0; col < 9; col++ { | |
scanner.Scan() | |
i1, _ := strconv.Atoi(scanner.Text()) |
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
func printBoard(board [9][9]int) { | |
fmt.Println("+-------+-------+-------+") | |
for row := 0; row < 9; row++ { | |
fmt.Print("| ") | |
for col := 0; col < 9; col++ { | |
if col == 3 || col == 6 { | |
fmt.Print("| ") | |
} | |
fmt.Printf("%d ", board[row][col]) | |
if col == 8 { |
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
<?php | |
public function loadMNISTImages($filename) | |
{ | |
$fp = fopen($filename, 'rb'); | |
$array = unpack("N4", fread($fp, 16)); | |
$magic = $array[1]; | |
if($magic != 2051) { |
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
<?php | |
public function loadMNISTLabels($filename) | |
{ | |
$fp = fopen($filename, 'rb'); | |
$array = unpack("N2", fread($fp, 8)); | |
$magic = $array[1]; | |
if($magic != 2049) { |
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
<?php | |
public function processResults($res, $request) | |
{ | |
$data = ['hits' => [], 'nbHits' => count($res)]; | |
foreach ($res as $result) { | |
$file = file_get_contents($result['path']); | |
$crawler = new Crawler; | |
$crawler->addHtmlContent($file); |
NewerOlder