Scripting Games 2007 Beginner PowerShell Event 5
I did not enter the beginners PowerShell Division, but did this 2 oneliners for Event 5: ABCs and 123s ( PS Answer: ABCs and 123s )
in the Beginner division:
$r = $str.tochararray() | % {([int]$_).toString('x')}
[String]::join('',[Char[]]($r |% {[int]"0x$_"}))
So you get the Following output :
PoSH> $str = "It was the best of times...you know the rest"
PoSH> $r = $str.tochararray() | % {([int]$_).toString('x')}
PoSH> $r
49
74
20
77
61
73
20
74
68
65
20
62
65
73
74
20
6f
66
20
74
69
6d
65
73
2e
2e
2e
79
6f
75
20
6b
6e
6f
77
20
74
68
65
20
72
65
73
74
PoSH> [String]::join('',[Char[]]($r |% {[int]"0x$_"}))
It was the best of times...you know the rest
PoSH>
For more oneliner fun see : Winter Scripting games Part 2 on my old blog or see the list here for other oneliner solutions the last years events : Scripting Games MMVII PowerShell Competition
Enjoy,
Greetings /\/\o\/\/