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
/* | |
Objective | |
Today, we're learning about the Array data structure. Check out the Tutorial tab for learning materials and an instructional video! | |
Task | |
Given an array of integers, print 's elements in reverse order as a single line of space-separated numbers. | |
Input Format |
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
# base64 encode / decode | |
$bytes = [System.Text.Encoding]::UTF8.GetBytes( "Write-Host Hello World") | |
$base64 = [Convert]::ToBase64String( $bytes ) | |
Write-Host "Base64 encoded: "( $base64 ) | |
$base64Decoded = [Convert]::FromBase64String( $base64 ) | |
Write-Host "Base64 decoded: "( $base64Decoded ) | |
$decodedText = [System.Text.Encoding]::UTF8.GetString( $base64Decoded ) |
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
# Date format | |
Write-Host "Date: "( Get-Date -f 'yyyy-MM-dd HH:mm:ss' | Out-String ) | |
Write-Host "Date: "( Get-Date -f 'dddd dd MMMM yyyy HH:mm' | Out-String ) | |
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
# Create and print xml document | |
[System.Xml.XmlDocument] $xml = | |
@' | |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<root> | |
<a><b><c><d text="Hello" /> </c></b></a> | |
<a><b><c><d text=" " /> </c></b></a> | |
<a><b><c><d text="World" /> </c></b></a> | |
</root> |
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
/* | |
Objective | |
Today, we're learning about Key-Value pair mappings using a Map or Dictionary data structure. Check out the Tutorial tab for learning materials and an instructional video! | |
Task | |
Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each queried, print the associated entry from your phone book on a new line in the form name=phoneNumber; if an entry for is not found, print Not found instead. | |
Note: Your phone book should be a Dictionary/Map/HashMap data structure. |
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
# Hashtable | |
[Hashtable] $hTable = @{ | |
mykey = "myvalue" | |
} | |
Write-Host "Table: " ( $hTable | Format-Table | Out-String ) | |
#Write-Host "Enumerator: " ( | Format-Table | Out-String ) |
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
#!/usr/bin/env groovy | |
// for logging: #!/usr/bin/env JAVA_OPTS=-Dgroovy.grape.report.downloads=true groovy | |
@Grab(group='commons-codec', module='commons-codec', version='1.10') | |
@Grab(group='org.sonatype.plexus', module='plexus-cipher', version='1.7') | |
import java.nio.file.Paths | |
import org.apache.commons.codec.binary.Base64 | |
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher |
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
#!/usr/bin/env groovy | |
import java.util.Base64 | |
import java.util.Base64.Decoder | |
import java.util.Base64.Encoder | |
import java.util.regex.Matcher | |
import java.util.regex.Pattern | |
import java.nio.charset.StandardCharsets; | |
final Decoder decoder = Base64.getDecoder() |
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
#!/usr/bin/env groovy | |
print "enter number: " | |
System.in.eachLine() { line -> | |
n = line.trim().toInteger() | |
(1..10).each{ | |
int res = n * it | |
println "${n} x ${it} = ${res}" | |
} |
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
#!/usr/bin/env groovy | |
@Grapes([ | |
@Grab(group='org.apache.poi', module='poi', version='3.16'), | |
@Grab(group='net.sf.opencsv', module='opencsv', version='2.3') | |
]) | |
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |
import org.apache.poi.hssf.usermodel.HSSFSheet; | |
import org.apache.poi.hssf.usermodel.HSSFRow; |