I have always enjoyed taking part in most of the

**Powershell**contests out there since Powershell is kind of a recreational administration language to me. I am thinking, for example, of the fun I had taking part in the oneliner contest (which I won) organized by fellow MVP Mike F Robbins, or of the Powershell Golf organized in 2013 by Robert Robelo on Twitter.**THE IDEAS BEHIND THE CONTEST**

Being quite proud of my blog, and despite the fact that I am more of a system administrator than a developer, I have unilaterally decided to organize my self-hosted, self-managed

**Powershell Oneliner Contest**.
The three ideas behind this game are that:

- experienced competitors (and I, of course!) should
**come away with a lot of tips**from the brightest Powershell minds that will hopefully take part in the event - novice Powershell scripters should learn that
**persistence pays off**when looking for a solution to such a contest - this is a fairly good occasion to sharpen your skills for the soon-to-start
**Powershell Scripting Games**held by the Powershell.org community

**GENERAL RULES**

- The contest is split into
**three tasks**. Each task consists of a simple scenario for which you have to produce a oneliner solution. - Submit your solutions via a comment to this blog article by
**11AM (PDT) on Wednesday, July 1st**, which is the deadline. **You MUST submit only one task solution per comment**, so that I can easily see who was the first to submit the shortest solution on a per-task basis.- Should you find a shorter oneliner to solve a task you are allowed to post additional comments (just remember to sign your comments so that I know who's who).
- Aliases are of course accepted
- Backticks accepted for readability
- No semi-colons
**UPDATE - No****Here-String****UPDATE - Please don't sign your comments as Unknown or I won't be able to know who you are.**- If you use a Powershell version other than v4, I am okay with it, but please mention it in the comment so that I can test it on the same version. Powershell v5 is welcome.
- Entries (comments) will not be made public until after the submission deadline.

**SCORING**

- The shortest solution in terms of chars wins.
- The first person to produce the shortest working solutions to a task will get 1 point, the second 2 points, the third 3 points and so on.
- The person with the lowest total score over the three mandatory tasks will be the winner.
- The winner will be announced on
**Saturday, July 4th**on this blog and the prize will be awarded at that time. - I'll be the only judge.

**THE PRIZE**

What? Is there a prize? Yes, of course. The prize will be a printed copy of the excellent book '

**Hyper-V Best Practices**' (5-Stars on amazon.com) by fellow MVP Benedict Berger (@Benedict_Berger) offered by**Packt Publishing**!!!
I was the reviewer of the book as well of the ton of Powershell code it contains. I can tell you this is the book to read in these Hyper-V times!

As a bonus, and if the winner agrees, he/she will intervene as a

Let's now dive into the contest tasks.

As a bonus, and if the winner agrees, he/she will intervene as a

**guest blogger**on this blog and will explain how one goes about learning the hidden bits of Windows Powershell. Sounds cool, doesn't it?Let's now dive into the contest tasks.

**TASK 1 - Who's taller?**

This is a rather easy challenge and I hope it will make for a good warm-up session for your Powershell muscles, especially if you are a beginner. Given a

*$n*variable showed below, write the shortest possible oneliner that outputs the absolute value of the largest double-precision floating-point number in the array.$n = -1,-2,-5,-8.9,'b',-9.11,-6,-3,-2,-9.1,-1,-1.4,'a'

**Expected output**

- The object in the output can be of any type
**UPDATE - The one-liner must work also with different values of $n**

**TASK 2 - Can you count to five?**

Time to delve into something harder. Write the shortest possible Powershell oneliner that outputs the number 12345.

**Expected output**

- You are not allowed to use the digits 0 to 9 in your oneliner
- The object in the output must be of type Int32
- Your displayed output shouldn't contain any other char

**TASK 3 - Powershell is the secret word**

I hope that by this time you are enjoying the competition. It's time for the last hard task. Write the shortest possible Powershell oneliner that outputs the word 'PowerShell' starting from a text string composed only of uppercase Xs' and whitespaces.

**Expected output**

- The string composed of X's and whitespaces must be part of the oneliner (backticks accepted!) and not be a variable defined on a separate line
- You can use as many X's and empty spaces you like or need
- P and S in the output must be uppercase
**UPDATE - No****Here-String****UPDATE - I consider jokes answers like "X "|%{"Powershell"}**

On your marks, set, go! And

I have decided to update this blog post with a function that will allow you to check if your proposed solutions are correct in terms of output and respect the task assignments.

If you want to give some visibility to this contest, feel free to twit about it. You can use the hashtags

Thanks again to Packt Publishing (and to Mary in particular) for sponsoring this event!

**remember to have fun**, it's just a game meant to produce something useful for the growing and growing Powershell community!**UPDATE - Check-Task Function**I have decided to update this blog post with a function that will allow you to check if your proposed solutions are correct in terms of output and respect the task assignments.

**Kudos for this function go to my friend Joey!**function Check-Task ([int] $Task, [scriptblock] $Command) { $n = -1,-2,-5,-8.9,'b',-9.11,-6,-3,-2,-9.1,-1,-1.4,'a' $result = & $command $check = $false switch ($Task) { 1 { $check = $result -eq '1.4' -or [double]::Parse("$result") -eq 1.4 } 2 { $check = ($result -is [int] -and $result -eq 12345) -and ("$Command" -notmatch '[0-9]') } 3 { $check = ($result -is [string] -and $result -ceq 'PowerShell') -and ("$Command" -match '([''"])[X`\s]+\1') } } if (!$check) { Write-Host -Fore Yellow "Expected: $((1.4,12345,'PowerShell')[$Task - 1])" Write-Host -Fore Red "Actual: $result" } $color = ('Red','Green')[$check] Write-Host -Fore $color ('{0,4}: {1}' -f "$Command".Trim().Length,$command) }Sample usage:

Check-Task 1 { $n.gettype() }Do not hesitate to test your solutions before posting them to my blog! Better safe than sorry.

**SPREAD THE WORD**If you want to give some visibility to this contest, feel free to twit about it. You can use the hashtags

**#poshcontest2015**and

**#powershell**so that other competitors can share their thoughts (not the solutions of course!).

Thanks again to Packt Publishing (and to Mary in particular) for sponsoring this event!

**UPDATE**: Click here to find the winner's name and his solutions!

$n | ? {$_ -is [Double]} | sort | select -L 1

ReplyDelete"$([int]$true)$($([int]$true)+$([int]$true))$($([int]$true)+$([int]$true)+$([int]$true))$($([int]$true)+$([int]$true)+$([int]$true)+$([int]$true))$($([int]$true)+$([int]$true)+$([int]$true)+$([int]$true)+$([int]$true))"

ReplyDeleteI'm not proud :D

(80,111,119,101,114,83,104,101,108,108 | % {[char]$_}) -join ''

ReplyDelete("X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -split ' ' | % {[char]$($_.length + 79)}) -join ''

ReplyDeletePlease erase my previous attempt, I didn't read the rule :)

"$('a'.length)$('aa'.length)$('aaa'.length)$('aaaa'.length)$('aaaaa'.length)"

ReplyDeleteIs far shorter than my previous attempt :)

#1

ReplyDelete-($n | ? {$_ -is [Double]} | sort | select -L 1)

#2

ReplyDelete[int]"$('a'.length)$('aa'.length)$('aaa'.length)$('aaaa'.length)$('aaaaa'.length)"

#3

ReplyDelete("X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -split ' ' | % {[char]$($_.length + 79)}) -join ''

Exo2: [int][char]"v" * [int][char]"i" - [int][char]"-"

ReplyDeleteC'est moi (notremaison)

Task 3

ReplyDelete('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' -split ' ' | % {[char]($_.length)}) -join ''

On v5

Task 3 Amended:

ReplyDelete('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'-split' '|%{[char]($_.length)})-join''

on V5

Exo 1: $n -replace "-" | ? {$_ -like "*.*"} | sort | select -First 1

ReplyDeleteTask 2:

ReplyDelete[int]([String]("b","c","d","e","f"|%{("abcdef").indexof($_)})).Replace(" ","")

No numbers used in one liner, returns an Int32, and has no other characters. Like me - it is ugly, but it is functional ;)

[int][char]"〹"

ReplyDeleteDernier Exo

ReplyDelete@"

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXX

"@ -split " " | % { Write-Host "$([char]$_.split('X').count)" -NoNewline }

Task 1: 43 chars

ReplyDelete[math]::Abs(($n|sort|?{$_-is[double]})[-1])

[int][char]'〹'

ReplyDelete-join(-split'X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'|%{[char]($_.Length+79)})

ReplyDeleteTask 1 (Powershell V5)

ReplyDelete($n |%{$_.ToString()} | where {$_.contains('.')}|%{[math]::Abs($_)} | Sort-Object)[0]|%{([string]($_)).replace(".",",")}

Task 2 Powershell V5

ReplyDelete[int32]("$([byte][char]'{')"+"$([byte][char]'-')")

Task 3 (Powershell V5)

ReplyDelete((@"

XXXXXXX

XX

"@)|%{$_ -split "`n"}|%{if($_.contains(' ')){

"$([char](112-($_.length-1)))"

}else{

"$([char](112+($_.length-1)))"

}}) -join ''

Task 2 bis (Powershell V5)

ReplyDelete[int]("$([byte][char]'{')"+"$([byte][char]'-')")

Task3 bis (Powershell V5)

ReplyDelete((@"

XXXXXXX

XX

"@)|%{$_ -split "`n"}|%{if($_.contains(' ')){"$([char](112-($_.length-1)))"}else{"$([char](112+($_.length-1)))"}}) -join ''

(($n|?{$_-is[double]})[-1])*-1

ReplyDelete[int]([char[]](49..53)-join"")

("X X"|%{$ShellId[10..19]})-join""

Task 2: 78 chars

ReplyDeleteicm{param($z)[int]"${z}xdacf"-[int]"${z}xaaa$z"+[int]"${z}xa"}-arg $null.Count

Task 3: 19 chars

ReplyDelete"X"|%{"PowerShell"}

[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("MTIzNDU="))

ReplyDelete[int][Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("MTIzNDU="))

ReplyDeleteTask 2 (shortened): 76 chars

ReplyDeleteicm{param($z)[int]"${z}xdacf"-[int]"${z}xaaa$z"+[int]"${z}xa"}-arg ([int]"")

TASK 1 ($n|?{$_.GetTypeCode() -eq "Double"}|measure -max).maximum

ReplyDeleteTASK 1 ($n|?{$_.GetTypeCode() -eq "Double"}|measure -max).maximum

ReplyDeleteMy 33char solution that is less generic that my first:

ReplyDelete-(($n|?{$_-is[double]}|sort)[-1])

1.

ReplyDelete$n|?{$_-Match'\.'}|%{$_-as[double]}|measure -ma|select -exp ma*

2.

ReplyDelete[int]::parse(-join("▲'".tochararray()|%{[int]$_}),'He')

cut and paste can't set characters below ascii 32, and I must comment that in doube quotes after -join must be character with ascii code 30 and single quote ' (ascii 39) solution is 55 characters long

Task 2 (41 chars):

ReplyDelete[int]"$([int][char]'{')$([int][char]'-')"

2. even shorter - 50 chars

ReplyDelete[int]::parse(-join("▲ ","'"|%{[int][char]$_}),'He')

3.

ReplyDelete-join('X XXXX X X XX X XX X XX X XXX XX X X XX X XX'-replace' ',1-replace'X',0-split'(\d{6})'|?{$_}|%{[char][convert]::tobyte("1$_",2)})

TASK 1 - Who's taller?

ReplyDeletePowerShell v5

Answer:

$n[11]*-1

Alexander Johansson (aleqs__@outlook.com)

Task 3 (195 chars):

ReplyDeletefor($i=0;$i-lt80;$i+=8){write-host([char][convert]::ToInt32(" X X XX XXXX XXX XXX XX X X XXX X X X XX XX X XX X X XX XX XX XX ".replace(" ",0).Replace("X",1).Substring($i,8),2))-N}

Not sure if it's allowed with the semicolon in the for statement. If not I'd like to hear it so I can take another crack.

There has to be easier/better way to do #1, but here is my attempt:

ReplyDelete[math]::Abs(($n|?{$_-is[double]}|sort)[-1])

And last but not least - #3

ReplyDelete[regex]'(.{3})'|% Re* 'X X XXX X X XXXXXXX '{switch($args.groups[1].value){'X '{'P'}' X '{'o'}' X'{'w'}'XX '{'e'}'X X'{'r'}' XX'{'S'}'XXX'{'h'}' '{'l'} }}

(should read as one line)

Solution1 30 characters

ReplyDelete($n|?{$_-is"Double"}|Sort)[-1]

Solution 2 - 14 characters

ReplyDelete[int][char]"〹"

Solution1 correction. Did not have absolute value before. Nw solution below

ReplyDelete($n|?{$_-is"Double"}|Sort)[-1]*-1

Solution1 new correction. My second entry for question 1 works but only because the number in the array is of negative value. Multiplying by -1 works in this case. If the Largest Double was positive then my solution wouldn't work. New solution is 43 characters:

ReplyDelete[math]::abs(($n|?{$_-is"Double"}|Sort)[-1])

My solution for Task 1:

ReplyDelete($n|?{$_-is[Double]}|%{[math]::abs($_)}|sort)[-1]

Using Powershell 5.

Solution3: Doesn't fell like a winner :) 1094 characters

ReplyDelete"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX".Split(" ")|%{Write-Host $([char]$_.Length)-NoNewline}

TASK 2 - Can you count to five?

ReplyDeletePowerShell v5

Answer:

[int][char]'〹'

Alexander Johansson (aleqs__@outlook.com)

Dont know if my previous entry for number three was accidentally submitted as unknown..

ReplyDeleteIf so, here it is again, My solution for Task 3:

-join((("X X XXXXX X X X X XX X X XX XX X XX X X XXXX XX X X X XXX X XX"-replace"X","0"-replace" ","1")-split"(\w{8})").split("",[StringSplitOptions]'RemoveEmptyEntries')|%{[char][convert]::toint16($_,2)})

Unig Powershell 5.

Task3

ReplyDelete("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XXXXXXX XXXXXXXXXXXXXXXXX XXXXXXXXXXXXX "|Select-String '((.)+?)\1+' -AllMatches | %{$_.matches}|%{"$([char](121-($_.value.length)))"})-join ''

($n|?{$_.GetType().Name -eq "Double"}|sort -Desc)[0]

ReplyDeleteTask 2 : [int]((("a".Length)..("Hello".Length)) -Join "")

ReplyDeleteTASK 1 - Who's taller?

ReplyDeletePowerShell v5

I update the answer since you added "The one-liner must work also with different values of $n" which I think is a bit unfair since I didn't see it until now! :D

Answer:

(($n|?{$_-is[double]})-replace'-'|sort)[0]

Alexander Johansson (aleqs__@outlook.com)

#1 max value in $n

ReplyDelete$n -match '\d'|measure -Ma|% ma*

# @KevinMarquette

#2 count to five

ReplyDelete[int][char]'〹'

@KevinMarquette

This is kind of cheating but technically correct. Have to copy/paste this into the shell (and there is a chance the encoding will be lost along the way). I found this by running this command:

[char]12345

#3 produce Powershell using a string of X and spaces

ReplyDelete# joke submit:

"X "|% "Powershell"

# more in the spirit of the contest

(0,31,39,21,34,3,24,21,28,28 | % -B{$a="X "|%{[int][char]$_[1]..([int][char]$_[0]*2)}|%{[char]$_} }{$a[$_+48]} ) -join ''

@KevinMarquette

This one takes the string "X " and converts it into the alphabet, then uses the numbers to index the letters. Not very elegant but it works.

# 3 the string Powershell starting from the string "X "

ReplyDelete# I looked at the rules and if you will allow it, I want to change my response to this

"X "|% "Powershell"

@KevinMarquette

Task 1 (91 characters)

ReplyDelete($n |%{"$_"}|?{$_.contains('.')}|%{[math]::Abs($_)}|Sort)[0]|%{("$($_)").replace(".",",")}

#1 maximum value of the floating point numbers as an absolute value

ReplyDelete$n|?{$_-is [double]}|measure -Ma|% {[math]::abs($_.maximum)}

@KevinMarquette

My first one was flawed. Didn't read the rules close enough.

Task 3 (265 chars)

ReplyDelete("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XXXXXXX XXXXXXXXXXXXXXXXX XXXXXXXXXXXXX "|sls '((.)+?)\1+' -A|%{$_.matches}|%{"$([char](121-($_.value.length)))"})-join''

Task 1 (74 chars, @mickyballadelli)

ReplyDelete"$(($n |?{$_-match'\d'}|%{[math]::Abs($_)}|Sort -D)[0])".Replace(".",",")

Task 1 (52 chars) @mickyballadelli

ReplyDelete($n |?{$_-match'\d'}|%{[math]::Abs($_)}|Sort -D)[0]

J'avais un gros bug sur le dernier, désolé:

ReplyDeleteTask 1 (57 chars) @mickyballadelli

($n|?{$_-match'\d+\.\d+'}|Sort -D)[0]|%{[math]::Abs($_)}

Task 2 (46 chars) @mickyballadelli

ReplyDelete[int]([byte][char]'{',[byte][char]'-'-join'')

My solution for Task 2:

ReplyDelete-join([int][char]'{',[int][char]'-')

Using Powershell 5

....And i just realized my mistake... New (Hopefully working) solution to Task 2:

ReplyDelete[int](-join([int][char]'{',[int][char]'-'))

Using Powershell 5

Task 1, 34: ($n-match'\.'|sort)[-1]-replace'-'

ReplyDeleteTask 2, 39: +-join([char[]]'+,-./'|%{$_-[char]'*'})

ReplyDelete# Johan Akerstrom, jakerstrom@gmail.com

ReplyDelete# I'm on PS 5.0

#Task 1, 43 chars:

$n = $n = -1,-2,-5,-8.9,'b',-9.11,-6,-3,-2,-9.1,-1,-1.4,'a'

[math]::Abs(($n|?{$_-is[double]}|sort)[-1])

#Task 2, 35 chars:

[int]-join([char[]]'{-'|%{[int]$_})

#Task 3, 20 chars:

"X "|%{'PowerShell'}

#Task1

ReplyDelete($n-match'\.'|sort)[-1]*-1

#Task2

ReplyDelete[int]-join('b','c','d','e','f'|%{[int]([char]$_-[char]'a')})

#Task 3

ReplyDelete-join(-8,23,31,13,26,-5,16,13,20,20|%{[char]($_+[int][char]('X '-replace' ',''))})

Task 3 (PS 5 -- 259 chars) @mickyballadelli

ReplyDelete("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XXXXXXX XXXXXXXXXXXXXXXXX XXXXXXXXXXXXX "|sls '((.)+?)\1+' -A|%{$_.matches}|%{"$([char](121-($_.length)))"})-join''

Task 3 (PS 5 - 249 chars) @mickyballadelli

ReplyDelete("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X XXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXX "|sls '((.)+?)\1*' -A|%{$_.matches}|%{"$([char](120-($_.length)))"})-join''

Task 1 validated by function: @mickyballadelli

ReplyDelete56: ($n|?{$_-match'\d+\.\d+'}|Sort -D)[0]|%{[math]::Abs($_)}

Task 2 validated by function @mickyballadelli

ReplyDelete43: [int]([int][char]'{',[int][char]'-'-join'')

Task 3 validated by function @mickyballadelli

ReplyDelete248: ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X XXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXX

"|sls '((.)+?)\1*' -A|%{$_.matches}|%{"$([char](120-($_.length)))"})-join''

Update: since apparently the "largest" was before converted to absolute values, new solution to task 1:

ReplyDelete($n|?{$_-is[Double]}|sort|%{[math]::abs($_)})[-1]

Same amount of characters, still Powershell 5.

(I blame language barriers for this one..)

New solution for question 3. 299 characters

ReplyDelete"X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX".Split(" ")|%{Write-Host([char]($_.Length+79))-N}

Newer solution question3. 289 chars

ReplyDelete" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXX XXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXX".Split(" ")|%{Write-Host([char]($_.Length+80))-N}

Fabien: Exo 1 : $n -replace '^-'|?{$_ -like "*.*"}|sort|select -first 1

ReplyDeleteTask 2 update, I didn't check it :(

ReplyDelete[int](("{","-"|%{[int][char]$_})-join"")

Rhys Edwards

Fabien: Exo 2: [int][char]"p"*[int][char]"o"-[int][char]"W"

ReplyDeleteTask 3:

ReplyDelete("

XXXXX

X XXX

X X X

X X

XX

XX

X X X

XXX

XXX "-split"`n"|%{[char]([convert]::toint32([int32]($_-replace"X",1-replace" ",0),2)+80)})-join""

Rhys Edwards

Task 1:

ReplyDelete[math]::abs(($n|?{$_-is[double]}|sort)[-1])

Rhys Edwards

@mickyballadelli 53 chars

ReplyDeleteCheck-Task 1 {($n|?{$_-match'\d+\.'}|Sort -D)[0]|%{[math]::Abs($_)}}

Task2 (41 chars) @mickyballadelli

ReplyDeleteCheck-Task 2 {[int]"$([int][char]'{')$([int][char]'-')"}

Task 1 (33 chars) @mickyballadelli

ReplyDeleteCheck-Task 2 {[int]([int[]][char[]]'{-'-join'')}

oops I meant task 2 --- 33 chars @mickyballadelli

ReplyDeleteCheck-Task 2 {[int]([int[]][char[]]'{-'-join'')}

New solution for question 3 using 64 characters. You say that I can use as many Xs and whitespaces as I like or need. I choose to use none :)

ReplyDelete""|%{1,32,40,22,35,4,25,22,29,29|%{Write-Host([char]($_+79))-N}}

If this solution is not acceptable then I will add an X and a whitespace in the initial string. Pls let me know /Simon

#Task2

ReplyDelete[int]-join('bcdef'-as[char[]]|%{[int]($_-[char]'a')})

Task 2, 28: +-join[int[]][char[]]'☺☻♥♦♣'

ReplyDeleteThe string '☺☻♥♦♣' is actually characters 1 through 5. They can be entered via Alt+01 through Alt+05 on the console; they cannot be entered in the ISE.

Task 3, 164: -join(-split'XXXXXXXXXXXX XXXXXXXXXXX XXXXXXXXXXXXXXXXXXX X XXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXX X XXXXXXXX XXXXXXXX'|%{$x=0}{[char]($_.Length+100-32*($x++%5-eq0))})

ReplyDeleteTask 3, 153: -join(' X X XXXX XX XXX X X X XX X X XX X X X X X X XX X XX '-split"`t"|%{[char][Convert]::ToInt32(("1$_"-replace' ',0-replace'X',1),2)})

ReplyDeleteBinary coding of the string, using spaces for 0, tabs for separation.

# Answer 1:

ReplyDelete[math]::abs(($n|?{$_ -is[double]}|measure -ma).Maximum)

# Answer 2:

[int][char]'〹'

# Answer 3:

[string]::new(([regex]::Matches(" X X XXXXXX XXXX X XXX X X XXX X X X XX XX X XX ".Replace(' ',0).Replace('X',1),'\d{6}')|%{[Text.Encoding]::UTF8.GetChars([Convert]::ToInt32("1$_",2))}))

-join(" X X XX XXXX XXX XXX XX X X XXX X X X XX XX X XX X X XX XX XX XX ".Replace(' ',0).Replace('X',1) -split'(?<=\G.{8})\B'|%{[char][convert]::ToInt16($_,2)})

ReplyDeleteTask 3, 153: -join(' X X XXXX XX XXX X X X XX X X XX X X X X X X XX X XX '-split"`t"|%{[char][Convert]::ToInt32(("1$_"-replace' ',0-replace'X',1),2)})

ReplyDeleteSolution 1: [math]::abs(($n|?{$_-Is[double]}|measure -Ma).Maximum)

ReplyDeleteSolution 2: [int]((-[int][char]"J"..-[int][char]"F"|%{[char]($_+[int][char]"{")})-join"")

Solution 3: "X "|%{$_.Replace(" ","Shell").Replace("X","Power")}

Task 2, 10: +[char]'〹'

ReplyDeleteTask 2, 9: +'〹'[+$z]

ReplyDeleteRequires uninitialized variable $z, though. Alternatively:

+'〹'[!$?]

in the hopes that the last command was successful (can obviously be a character shorter if it wasn't).

Task 2, 8: +'〹'['']

ReplyDeleteOne of these days I'll actually think before posting. This is not that day, though.

Task 3, 118: -join(' X '-split"`t"|%{[char](($_[0,1]|%{'X '.IndexOf($_)})-join'*16+'|iex)})

ReplyDeleteThis uses some ... creative interpretation of the word "whitespace", including not only space, but also everything else Unicode has to offer ;). Hexadecimal encoding of the word PowerShell by mapping 0–F to X and whitespace characters.

And another attempt to paste 2nd: +(-join[int[]][char[]]'{-')

ReplyDeleteIt starts with plus sign, bracket, join operator, int array, char array, literal string with curly and minus, closing bracket. ;)

Task 3, 117: -join(' X '-split' '|%{[char](($_[0,1]|%{'X '.IndexOf($_)})-join'*16+'|iex)})

ReplyDeleteThis time with a literal tab instead of "`t". Saves the one escape char.

Task 3, 90: Check-Task 3 { -join(-split'XXXX XXXXXX XXXXXXX XX XXXXX XXX XXXXXXXX XX X X'|%{'leSProwh'[$_.Length-1]}) }

ReplyDeleteVery trivial encoding of indexes into a reservoir of characters to use. Unary coding of the indexes. Now, this might be a bit debatable, as I defined the characters that can be produced from the encoding, but changing the X-and-whitespace string will change the output, so I guess it should count (also contains only X and spaces, without going crazy on the whitespace rule like previous solutions).

Task 3, 89: -join(-split'XXXX XXXXXX XXXXXXX XX XXXXX XXX XXXXXXXX XX X X'|%{' leSProwh'[$_.Length]})

ReplyDeleteMinor optimization of the solution before.

#1

ReplyDelete$n-match'\d{1}.\d{1}'-replace'-',''|measure -min|select -Expand minimum

2#

ReplyDelete[int](('bcdef'.ToCharArray()|%{([byte][char]$_)-([byte][char]'a')})-join'')

Really wasn't sure about #3 but here is my shot:

ReplyDelete(((('XXXXXXXXXX'))-replace('(?<=^.{0}).*','PowerShell')))

I learnt a lot from these little tasks! thanks a lot!

ReplyDeleteTask 3 238 characters, PS 5, @mickyballadelli

ReplyDeleteCheck-Task 3 {(('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX` `X` `XXXXXX` `XXXXXXXXXXXXXXXX` `XXXXXXXXXXXX` ').split('`') |% {"$([char](120-($_.length)))"})-join''}

Task 3 (236 characters) @mickyballadelli

ReplyDeleteCheck-Task 3 {(('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX` `X` `XXXXXX` `XXXXXXXXXXXXXXXX` `XXXXXXXXXXXX` ').split('`')|%{"$([char](120-($_.length)))"})-join''}

Task 3 234 Characters @mickyballadelli

ReplyDeleteCheck-Task 3 {(('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX` `X` `XXXXXX` `XXXXXXXXXXXXXXXX` `XXXXXXXXXXXX` ').split('`')|%{"$([char](120-$_.length))"})-join''}

Second try on Task 3:

ReplyDelete[string]::new(([regex]::Matches(' X X XXXXXX XXXX X XXX X X XXX X X X XX XX X XX '.Replace(' ',0).Replace('X',1),'\d{6}')|%{[char][Convert]::ToInt32("1$_",2)}))

212 Chars (yay!!) @mickyballadelli

ReplyDeleteTask 3

Check-Task 3 {((' `X`XXXXXXXXX` `XXXX` ` ` ` ` ').split('`')|%{if($_[0] -eq"X"){"$([char](110+$_.length))"}else{"$([char](110-$_.length))"}})-join''}

Task 3 (204 chars) @mickyballadelli

ReplyDeleteCheck-Task 3 {((' `XXX`XXXXXXXXXXX` `XXXXXX` ` ` ``').split('`')|%{if($_[0] -eq"X"){"$([char](108+$_.length))"}else{"$([char](108-$_.length))"}})-join''}

Second try on Task 1:

ReplyDelete[math]::abs(($n|?{$_-is[double]}|measure -ma).Maximum)

I just saw that only one answer per comment was allowed... I wrote three in my first comment. In case that comment will be ignored here is the second answer.

ReplyDeleteTask 2:

[int][char]'〹'

Task 3 (190 characters) @mickyballadelli

ReplyDeleteCheck-Task 3 {((' `XXX`XXXXXXXXXXX` `XXXXXX` ` ` ``').split('`')|%{"$([char]108)+(if($_[0] -eq'X'){$_.length}else{-$_.length})))"})-join''}

Task 3 (192 characters) (sorry the previous one was bugged) @mickyballadelli

ReplyDeleteCheck-Task 3 {((' `XXX`XXXXXXXXXXX` `XXXXXX` ` ` ``').split('`')|%{"$([char]$(if($_[0] -eq'X'){108+$_.length}else{108-$_.length}))"})-join''}

Task 3 (191 characters) @mickyballadelli

ReplyDeleteCheck-Task 3 {((' `XXX`XXXXXXXXXXX` `XXXXXX` ` ` ``').split('`')|%{"$([char](108+$(if($_[0] -eq'X'){$_.length}else{-$_.length})))"})-join''}

Task 3 (187 Characters) @mickyballadelli

ReplyDeleteCheck-Task 3 {((' `XXX`XXXXXXXXXXX` `XXXXXX` ` ` ``').split('`')|%{"$([char](108+$_.Length-$(if($_[0] -eq' '){$_.length*2})))"})-join''}

Check-Task 1 {[math]::Abs(($n|?{$_-is[double]}|sort)[-1])}

ReplyDeleteCheck-Task 2 {+[char]'〹'} # The character is UNICODE U+3039 (decimal 12345)

Check-Task 3 {"X "|%{'PowerShell'}}

This gives me all green and the following result:

43: [math]::Abs(($n|?{$_-is[double]}|sort)[-1])

10: +[char]'〹'

20: "X "|%{'PowerShell'}

Check-Task 1 {[math]::Abs(($n|?{$_-is[double]}|sort)[-1])}

ReplyDeleteCheck-Task 2 {+[char]'〹'} # The character is UNICODE U+3039 (decimal 12345)

Check-Task 3 {"X "|%{'PowerShell'}}

This gives me all green and the following result:

43: [math]::Abs(($n|?{$_-is[double]}|sort)[-1])

10: +[char]'〹'

20: "X "|%{'PowerShell'}

Before you consider "X "|%{"PowerShell"} as a joke then ask yourself this...

Is your start string and your end string the same string?

Does...

[System.Runtime.InteropServices.Marshal]::StringToCoTaskMemAnsi($startString...)

[System.Runtime.InteropServices.Marshal]::StringToCoTaskMemAnsi($endString...)

yield the same pointer value? If not then a pure replacement ought to be within the rules since you say nothing about the "PowerShell" string not to be part of the oneliner. Or you could be more specific in what type of algorithm you are expecting. :)

Having said that.... Here is my non jokes version of task 3 :)

Check-Task 1 {[math]::Abs(($n|?{$_-is[double]}|sort)[-1])}

Check-Task 2 {+[char]'〹'} # The character is UNICODE U+3039 (decimal 12345)

Check-Task 3 {" X X XXXXXX XXXX X XXX X X XXX X X X XX XX X XX "-replace"X",1-replace" ",0|tee -Va s|%{-join(0..9|%{[char]([Convert]::ToInt32($s.SubString($_*6,6),2)+64)})}}

This gives me 43,10 and 170

TASK 3 - Powershell is the secret word

ReplyDelete' XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXX XXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXX'.Split()|%{Write-Host -NoNewline([char]($_.Length+80))}

Alexander Johansson (aleqs__@outlook.com)

3. Sorry, make an error, check function help alot, still 152

ReplyDelete-join('X XXXX X X XX X XX XX XX X XXX XX X X XX X XX'-replace' ',1-replace'X',0-split'(\d{6})'|?{$_}|%{[char][convert]::tobyte("1$_",2)})

1. Forget about Abs, 78

ReplyDelete[Math]::Abs(($n|?{$_-Match'\.'}|%{$_-as[double]}|measure -ma|select -exp ma*))

3.

ReplyDeleteI Don't khow, it is considered as a joke or not ? if Yes, note than input string MUST BE USED

62: 'X '|%{(powershell -?| ?{$_-match'-Version <'})-replace'\[.*'}

3. even shorter if not a joke

ReplyDelete30: 'X '|%{$ShellId-replace'.*\.'}

3. based on previous but input string (formally) used

ReplyDelete35: 'X '|%{($_+$ShellId)-replace'.*\.'}

You really should consider, if input MUST be used and in which form

Task 2 (32 chars):

ReplyDelete[int](''..'.....'.Length-join'')

Brgds @csandfeld

Task 3 (183 chars):

ReplyDelete'X XX XXXXXXXXXX XX XXXXX XXXX XXXXX XX XXXXXXXXX XXXXXXXXX '|%{([regex]::Matches($_,'(X+)|( +)')|%{$_.Value.Length|%{if($i++%2){[char](119-10*$_+$j)}else{$j=$_}}})-join''}

Brgds @csandfeld

# Another update Johan Akerstrom,jakerstrom@gmail.com

ReplyDeleteCheck-Task 1 {[math]::Abs(($n|?{$_-is[double]}|sort)[-1])}

Check-Task 2 {+[char]'〹'} # The character is UNICODE U+3039 (decimal 12345)

Check-Task 3 {

-join(0..9|%{[char]([Convert]::ToInt32($s.SubString($_*6,6),2)+64)}-b{$s=" X X XXXXXX XXXX X XXX X X XXX X X X XX XX X XX "-replace"X",1-replace" ",0})

}

43,10,163

New entry for task 3. I solved my earlier question. Write-Host does not output a string. That is why I was getting red in Check-Task. Anyway new entry below: 71 chars

ReplyDelete"X"|%{[string]::Concat((0,31,39,21,34,3,24,21,28,28|%{[char]($_+80)}))}

1.

ReplyDelete76: ($n|?{$_-Match'\.'}|%{$_-as[double]}|measure -ma|select -exp ma*)-replace'-'

1.

ReplyDelete69: ($n|?{$_-Match'\.'}|%{$_-as[double]}|measure -ma).Maximum -replace'-'

My 14 char answer to Task2:

ReplyDelete[int][char]"〹"

/SimonW

My 159 char answer to Task3:

ReplyDelete-join('X X X X X X XX XX X X X X X XX XX XX '-split'(.{6})'-replace'X','1'-replace' ','0'|?{$_}|%{[char](120-[convert]::ToInt32($_,2))})

/SimonW

# Task 1

ReplyDelete$n | ?{$_ -like "*.*"} | Measure -Ma | Select -Exp Ma* | %{[math]::abs($_)}

Shortest but more error prone, I initially made this one :

$n | ?{$_.GetType() -eq [Double]} | Measure -Max | Select -Expa Ma* | %{[math]::abs($_)}

#Task 2

ReplyDelete[int][char]"〹"

Character is not displaying correctly but I simply used the ascii value of "12345" to get it.

# Task 3

ReplyDelete"XXXXXXXX XXXXXXX XXXXXX XX XXXXX XXXX XXX XX X X " -replace "XXXXXXXX ","P" -replace "XXXXXXX ","o" -replace "XXXXXX ","w" -replace "XXXXX ","r" -replace "XXXX ","S" -replace "XXX ","h" -replace "XX ", "e" -replace "X ","l"

Not sure I understood correctly the task though.

Thanks for the contest !

3. if the input string should be "used"

ReplyDelete33: 'X '|%{$_+$ShellId-replace'.*\.'}

but I think the rule should say "input string must be converted to 'Powershell' without use of other input sources"

and than my 152 char solution come in play

3. IfNotAJoke

ReplyDelete28: -join('X '+$ShellId)[12..21]

Task 1 (48 Chars) @mickyballadelli

ReplyDelete$n|?{$_-match'\.'}|Sort)[-1]|%{[math]::Abs($_)}

2.

ReplyDelete38: [int]-join($?..('aaaaa'.length)|%{$_})

2. oops I was too fast

ReplyDelete32: [int]-join($?..('aaaaa'.length))

Task 1:

ReplyDelete[math]::Abs(($n|?{$_ -match '^-?\d+\.\d+$'}|sort -D|select -F 1))

Task 2:

ReplyDelete[int](('@ABCD'.ToCharArray()|%{[char]($_ -0xF)}) -join '')

Task 2

ReplyDelete[int](([char[]]'@ABCD'|%{[char]($_ -0xF)}) -join '')

Task 3

ReplyDelete(' XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXX XXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXX'.split(' ')|%{[char]($_.Length+80)}) -join ''

My 158 char answer to Task3:

ReplyDelete-join(' XX X X X XX X XX X XX X X XX XXX X XXX X'-split'(.{6})'-replace'X','1'-replace' ','0'|?{$_}|%{[char](79+[convert]::ToInt32($_,2))})

/SimonW

TASK 3 - Powershell is the secret word

ReplyDeleteAnswer:

' XXXXXXXXXXX XXXXXXXXXXXXXXXXXXX X XXXXXXXXXXXXXX XXX XXXX X XXXXXXXX XXXXXXXX'.Split()|%{if($_.Length-match'[0,3]'){[int]$i=$_.Length+80}else{$i=$_.Length+100}Write-Host -NoNewline([char]$i)}

Alexander Johansson (aleqs__@outlook.com)

My 154 char answer to Task3:

ReplyDelete-join(' XX X X X XX X XX X XX X X XX XXX X XXX X'-split'(.{6})'-replace'X',1-replace' ',0|?{$_}|%{[char](79+[convert]::ToInt32($_,2))})

/SimonW

My 148 char answer to Task3:

ReplyDelete-join(' XX X X X XX X XX X XX X X XX XXX X XXX X'-split'(.{6})'-replace'X',1-replace' ',0|%{[char](79+[convert]::ToInt32($_,2))})

It throws a bunch of errors but only outputs one string to the outputstream.

/SimonW

TASK 3 - Powershell is the secret word

ReplyDeleteAnswer:

' XXXXXXXXXXX XXXXXXXXXXXXXXXXXXX X XXXXXXXXXXXXXX XXX XXXX X XXXXXXXX XXXXXXXX'.Split()|%{if($i){$l=$_.Length}if($l-match'[0,3]'){$i=$l+80}else{$i=$l+100}Write-Host -NoNewline([char]$i)}

Alexander Johansson (aleqs__@outlook.com)

3. IfNotAJoke

ReplyDelete28: -join('X '+$ShellId)[12..21]

2.

ReplyDelete30: [int]-join($?..'aaaaa'.length)

1.

ReplyDelete58: ($n|?{$_-match'^-?\d+\.\d+$'}|sort|select -l 1)-replace'-'

48: ($n|?{$_-like'*.*'}|sort|select -l 1)-replace'-' #but here is an error with other $n values like 'a.a'

1

ReplyDelete50: ($n|?{$_-match'^-?\d+\.\d+$'}|sort)[-1]-replace'-'

40: ($n|?{$_-like'*.*'}|sort)[-1]-replace'-' #but here is an error with other $n values like 'a.a'

I know it's too late but just find this page :(

ReplyDeletetask 3 in 29 chars ( with a string that use 0 space and X )

''+(iwr http://goo.gl/2nzV8B)