Skip to main content
-1 byte thanks to Veskah
Source Link
AdmBorkBork
  • 43.7k
  • 5
  • 107
  • 288

PowerShell, 21 bytes

PowerShell, 21 20 bytes

1.."$args"|%{'*'*$_} 
1..$args[0]|%{'*'*$_} 

Try it online!

Loops from 1 to input $args[0]$args, each iteration using string multiplication to construct a string of that many $_ asterisks. Default behavior for the implicit Write-Output at the end is with a newline for separator, so we get that for free.

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 5 * ** *** **** ***** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 2 * ** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 7 * ** *** **** ***** ****** ******* 
PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 5 * ** *** **** ***** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 2 * ** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 7 * ** *** **** ***** ****** ******* 

-1 byte thanks to Veskah.

PowerShell, 21 bytes

1..$args[0]|%{'*'*$_} 

Loops from 1 to input $args[0], each iteration using string multiplication to construct a string of that many $_ asterisks. Default behavior for the implicit Write-Output at the end is with a newline for separator, so we get that for free.

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 5 * ** *** **** ***** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 2 * ** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 7 * ** *** **** ***** ****** ******* 

PowerShell, 21 20 bytes

1.."$args"|%{'*'*$_} 

Try it online!

Loops from 1 to input $args, each iteration using string multiplication to construct a string of that many $_ asterisks. Default behavior for the implicit Write-Output at the end is with a newline for separator, so we get that for free.

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 5 * ** *** **** ***** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 2 * ** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 7 * ** *** **** ***** ****** ******* 

-1 byte thanks to Veskah.

Source Link
AdmBorkBork
  • 43.7k
  • 5
  • 107
  • 288

PowerShell, 21 bytes

1..$args[0]|%{'*'*$_} 

Loops from 1 to input $args[0], each iteration using string multiplication to construct a string of that many $_ asterisks. Default behavior for the implicit Write-Output at the end is with a newline for separator, so we get that for free.

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 5 * ** *** **** ***** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 2 * ** PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 7 * ** *** **** ***** ****** *******