Month: December 2013

  • Solve sudoku – WIP!

    [CmdletBinding()] Param() Process{ # Initial process. Clear all grids with hints. $Hash1 = 1 # Set Datahash 1 and 2 to different values. $Hash2 = 0 While($Hash1 -notmatch $Hash2){ $Hash1 = (1..9 | ForEach-Object{($Data | Where-Object{$_.”ID”}).$_}).count Process-Sudoku $Hash2 = (1..9 | ForEach-Object{($Data | Where-Object{$_.”ID”}).$_}).count } } Begin{ # $MyPath = Split-Path $MyInvocation.MyCommand.path -Parent $Data =…

  • Find primes, the proper way

    I noticed that the earlier way to find primes is really fast for small numbers, but it is really really slow for number >5000 To shorten this, and provide a proper track of what primes are found as well as looping endlessly I’ve created this thing below. Place it as prime.ps1 in a folder with…

  • Quick and dirty way to find primes

    2..5000 | ForEach-Object{ $current = $_ $f = @() 1..$Current | ForEach-Object{ $result = $current/$_ If($result.GetType().Name -eq “Int32”){ $f += $result } } if($f.count -le 2){ $current } }

  • Fibonacci sequence

    $1 = 0 $2 = 1 1..100 | ForEach-Object{ if($_%2 -eq 1){ $1 = $1+$2 $1 } Else{ $2 = $1+$2 $2 } }