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
# -*- coding: utf-8 -*- | |
import argparse | |
def reformat_table(content, start, end): | |
tabledata = [line.split(" | ") for line in content[start:end]] | |
tabledata.pop(1) | |
lengths = [0] * len(tabledata[0]) | |
for row in tabledata: |
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 math, itertools, time | |
def is_prime(n): | |
if n < 2: | |
return False | |
limit = math.floor(math.sqrt(n)) | |
for i in range(2, limit+1): | |
if n%i == 0: | |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func to_integer(slice []int) int64 { | |
k := int64(0) | |
for i := 0; i < len(slice); i++ { |
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" | |
"time" | |
) | |
func nextPermutation(slice []int) bool { | |
var k int | |
for k = len(slice) - 2; k >= 0; k-- { |
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
// Created and tested at: rustc 0.13.0-nightly | |
extern crate test; | |
use std::num::Float; | |
/// Given the limit `end` the method will find all prime values below that limit | |
fn get_primes_below_n(end: uint) -> Option<Vec<uint>> { | |
// If the parameter is less than two then we know that there cannot be any | |
// prime values found so return None |
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
SELECT t.name AS 'table', | |
c.name AS 'column', | |
fg.name AS 'filegroup_name', | |
dbf.type_desc AS 'type_description', | |
dbf.physical_name AS 'physical_location' | |
FROM sys.filegroups fg | |
INNER JOIN sys.database_files dbf | |
ON fg.data_space_id = dbf.data_space_id | |
INNER JOIN sys.tables t | |
ON fg.data_space_id = t.filestream_data_space_id |
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
param ( | |
[Parameter(Mandatory=$true, HelpMessage="Location of the Git repository to update")] | |
[string]$SourceLocation | |
) | |
# Test the source code location parameter | |
if ((Test-Path -Path $SourceLocation -PathType Container) -eq $false) { | |
Write-Host "The specified source code location is not valid" -ForegroundColor Red | |
exit 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
void Main() | |
{ | |
var newString = "Ignoring the Voices".Reverse().ToArray().AsString(); | |
newString.Dump(); | |
} | |
// Define other methods and classes here | |
public static class EnumerableExtensions | |
{ | |
public static string AsString(this char[] array) |
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 List<Book> Get(string title) | |
{ | |
using (var context = new BooksContext()) | |
{ | |
var result = context.Database.SqlQuery<Book>("SELECT * FROM Books WHERE Title LIKE '%" + title + "%'", new object[] { }); | |
return result.ToList(); | |
} | |
} |
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
// From the first 10,000 prime numbers, calculate the sum of the palindromic primes | |
[assembly: System.CLSCompliant(true)] | |
[assembly: System.Runtime.InteropServices.ComVisible(false)] | |
[assembly: System.Reflection.AssemblyVersion("1.0.0.0")] | |
[assembly: System.Reflection.AssemblyProduct("Performance Challenge - 1")] | |
namespace Challenge | |
{ |