Skip to content

Instantly share code, notes, and snippets.

@thedavecarroll
Last active July 5, 2019 17:42
Show Gist options
  • Save thedavecarroll/74e370e243ba8847db0b05b329fe2e24 to your computer and use it in GitHub Desktop.
Save thedavecarroll/74e370e243ba8847db0b05b329fe2e24 to your computer and use it in GitHub Desktop.
IronScripter Challenge June 28, 2019
KeyInterval: 1,12
Message: PracticePowerShellDaily
KeyInterval DecodedMessage
----------- --------------
1,1 PkTr2sz2*cF-raz7GuD4w6U#gctK3E@Bt1aYQPic%705ZvAeW6jePRfpmI)Hy^LoowCnbJdOSi9Mber#)ieU*f2Z6MSh7VuD5a(hsv8el1oWZO7lpKyJlDz$-jI@tT23Raikq=F&wB6c%Hly
1,2 PTrsz*c-rz7uDw6#gtKE@t1YQic70ZveWjeRfmIHyLowCbJOS9Mer)iU*2ZMS7VD5(hv8l1WZ7lKylD$-I@T2RakqF&B6%Hy
1,3 Pr22*-r7G4w#gK3BtYQc%5ZeWePpmHyoonbOSMb#)U*Z6h7D5hselWZlpJl$-@t3Rkq&wc%y
1,4 P2scFz74wgcE@aYc%Zv6jfpHyowJd9M#)*fMSuDhsl1O7yJ$-tTaiF&c%
1,5 Psz-ruD#gE@YQ70eWRfHywCOSerU*MSD5v8WZKy$-T2kqB6y
1,6 Pz2azw6K3aY70W6pmLoJdbeU*Sha(l1lpz$T2q=c%
1,7 P2*7G#gBtc%eWpmooOS#)Z6D5ellp$-3R&wy
1,8 P*cuDtKYQZvRfLoOS)iMS(hWZlDT2F&y
1,9 PcF4wE@c%6jHyJd#)MShsO7$-aic%
1,10 PF-6Ut15ZfpwCbeZ6(hO7-jkqly
1,11 P-r#gYQeWHyOSU*D5WZ$-kqy
1,12 PracticePowerShellDaily
1,13 PazK370pmJdU*a(lpT2c%
1,14 Pz7E@ZvHy9MMSl1$-F&
1,15 P7GBteWoo#)D5lp3Ry
2,1 kT2s2*F-azGu4wU#ct3EBtaYPi%75ZAe6jPRpm)H^LownbdOi9be#)eUf26Mh7uDa(sveloWO7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-ztE7ZmHO92Mvll$kF
12,4 -7KB5eHoM#hDWl@3cy
13,1 ratK%7fpbJeU5a7ltT6c
13,2 rzKE0ZIHS9ZM8lD$qF
13,3 r73BZeyob#7DZlt3%y
14,1 az3E5Z)Hi96Melz$=F
14,2 a7EBve^oe#VDOlT3Hy
15,1 z7@BAeLor#uD7l23ly
$crypto = @"
P k T r 2 s z 2 * c F -
r a z 7 G u D 4 w 6 U #
g c t K 3 E @ B t 1 a Y
Q P i c % 7 0 5 Z v A e
W 6 j e P R f p m I ) H
y ^ L o o w C n b J d O
S i 9 M b e r # ) i e U
* f 2 Z 6 M S h 7 V u D
5 a ( h s v 8 e l 1 o W
Z O 7 l p K y J l D z $
- j I @ t T 2 3 R a i k
q = F & w B 6 c % H l y
"@
function Get-CryptoSolution {
param(
$FullText,
$X,
$Y
)
$FullText = $FullText.Replace("`r`n",'').Replace(' ','')
$Counter = 0
while ($Counter -lt $FullText.Length) {
$First = $Counter + $X - 1
$Second = $First + $Y
try {
$Message += $FullText.Substring($First,1)
$Message += $FullText.Substring($Second,1)
$Counter = $Counter + $X + $Y
}
catch { break }
}
$Message
}
for ($x = 1; $x -le 20; $x++) {
for ($y = 1; $y -le 20; $y++) {
$DecodedMessage = Get-CryptoSolution -FullText $crypto -X $x -Y $y
if ($DecodedMessage.Length -gt ($X + $Y)) {
[PsCustomObject]@{
KeyInterval = '{0},{1}' -f $x,$y
DecodedMessage = $DecodedMessage
}
}
}
}
@thedavecarroll
Copy link
Author

I really thought about making a function too but in the end just went with a script with a hard coded max value. Our solutions are very similar. This was definitely a tough one to get some clean code.

How did you know the max value?

@jdhitsolutions
Copy link

Did you get a result? My solution is very similar - brute force looping and looking for a result that is meaningful.

@thedavecarroll
Copy link
Author

Yes, I just failed to post the result in this gist. I'll update it in a few.

@camusicjunkie
Copy link

camusicjunkie commented Jul 5, 2019

I really thought about making a function too but in the end just went with a script with a hard coded max value. Our solutions are very similar. This was definitely a tough one to get some clean code.

How did you know the max value?

I guessed tbh. I initially started with something much larger but once I saw the solution had 12 in the interval I changed the max to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment