Skip to main content
scriptblock case added
Source Link
mazzy
  • 7.2k
  • 2
  • 12
  • 22

Powershell, 63 bytes

$m,$n=$args;$t='h';'<table>';1..$m|%{'<tr>'+"<t$t>A"*$n;$t='d'}

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output (extra spaces are optional):

<table>
<tr><th>A<th>A<th>A
<tr><td>A<td>A<td>A
<table>
<tr><th>A<th>A<th>A
<table>
<tr><th>A<th>A
<tr><td>A<td>A
<tr><td>A<td>A
<tr><td>A<td>A
<table>
<tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A
<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

Powershell, 65 bytes, -replace

case with -replace:

'<table>h'+'d'*--$args[0]-replace'h|d',('<tr>'+'<t$0>A'*$args[1])

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output:

<table><tr><th>A<th>A<th>A<tr><td>A<td>A<td>A
<table><tr><th>A<th>A<th>A
<table><tr><th>A<th>A<tr><td>A<td>A<tr><td>A<td>A<tr><td>A<td>A
<table><tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

How it work:

  1. '<table>h'+'d'*--$args[0] - create a string like <table>hddd...
  2. 'h|d'- search h or d chars in the string for replacing
  3. '<tr>'+'<t$0>A'*$args[1] - replace each char with string like <tr><t$0>A<t$0>A...
  4. where $0 is a captured group[0] - the char in the -replace.

Powershell, 65 bytes, scriptblock

$m,$n=$args;'<table>';&($r={'<tr>'+"<t$args>A"*$n})h;(&$r d)*--$m

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output:

<table>
<tr><th>A<th>A<th>A
<tr><td>A<td>A<td>A
<table>
<tr><th>A<th>A<th>A

<table>
<tr><th>A<th>A
<tr><td>A<td>A<tr><td>A<td>A<tr><td>A<td>A
<table>
<tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A
<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

Powershell, 63 bytes

$m,$n=$args;$t='h';'<table>';1..$m|%{'<tr>'+"<t$t>A"*$n;$t='d'}

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output (extra spaces are optional):

<table>
<tr><th>A<th>A<th>A
<tr><td>A<td>A<td>A
<table>
<tr><th>A<th>A<th>A
<table>
<tr><th>A<th>A
<tr><td>A<td>A
<tr><td>A<td>A
<tr><td>A<td>A
<table>
<tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A
<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

Powershell, 65 bytes

case with -replace:

'<table>h'+'d'*--$args[0]-replace'h|d',('<tr>'+'<t$0>A'*$args[1])

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output:

<table><tr><th>A<th>A<th>A<tr><td>A<td>A<td>A
<table><tr><th>A<th>A<th>A
<table><tr><th>A<th>A<tr><td>A<td>A<tr><td>A<td>A<tr><td>A<td>A
<table><tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

How it work:

  1. '<table>h'+'d'*--$args[0] - create a string like <table>hddd...
  2. 'h|d'- search h or d chars in the string for replacing
  3. '<tr>'+'<t$0>A'*$args[1] - replace each char with string like <tr><t$0>A<t$0>A...
  4. where $0 is a captured group[0] - the char in the -replace.

Powershell, 63 bytes

$m,$n=$args;$t='h';'<table>';1..$m|%{'<tr>'+"<t$t>A"*$n;$t='d'}

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output (extra spaces are optional):

<table>
<tr><th>A<th>A<th>A
<tr><td>A<td>A<td>A
<table>
<tr><th>A<th>A<th>A
<table>
<tr><th>A<th>A
<tr><td>A<td>A
<tr><td>A<td>A
<tr><td>A<td>A
<table>
<tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A
<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

Powershell, 65 bytes, -replace

'<table>h'+'d'*--$args[0]-replace'h|d',('<tr>'+'<t$0>A'*$args[1])

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output:

<table><tr><th>A<th>A<th>A<tr><td>A<td>A<td>A
<table><tr><th>A<th>A<th>A
<table><tr><th>A<th>A<tr><td>A<td>A<tr><td>A<td>A<tr><td>A<td>A
<table><tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

How it work:

  1. '<table>h'+'d'*--$args[0] - create a string like <table>hddd...
  2. 'h|d'- search h or d chars in the string for replacing
  3. '<tr>'+'<t$0>A'*$args[1] - replace each char with string like <tr><t$0>A<t$0>A...
  4. where $0 is a captured group[0] - the char in the -replace.

Powershell, 65 bytes, scriptblock

$m,$n=$args;'<table>';&($r={'<tr>'+"<t$args>A"*$n})h;(&$r d)*--$m

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output:

<table>
<tr><th>A<th>A<th>A
<tr><td>A<td>A<td>A
<table>
<tr><th>A<th>A<th>A

<table>
<tr><th>A<th>A
<tr><td>A<td>A<tr><td>A<td>A<tr><td>A<td>A
<table>
<tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A
<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A
new case
Source Link
mazzy
  • 7.2k
  • 2
  • 12
  • 22

Powershell, 63 bytes

$m,$n=$args;$t='h';'<table>';1..$m|%{'<tr>'+"<t$t>A"*$n;$t='d'}

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output (extra spaces are optional):

<table>
<tr><th>A<th>A<th>A
<tr><td>A<td>A<td>A
<table>
<tr><th>A<th>A<th>A
<table>
<tr><th>A<th>A
<tr><td>A<td>A
<tr><td>A<td>A
<tr><td>A<td>A
<table>
<tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A
<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

Powershell, 65 bytes

case with -replace:

'<table>h'+'d'*--$args[0]-replace'h|d',('<tr>'+'<t$0>A'*$args[1])

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output:

<table><tr><th>A<th>A<th>A<tr><td>A<td>A<td>A
<table><tr><th>A<th>A<th>A
<table><tr><th>A<th>A<tr><td>A<td>A<tr><td>A<td>A<tr><td>A<td>A
<table><tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

How it work:

  1. '<table>h'+'d'*--$args[0] - create a string like <table>hddd...
  2. 'h|d'- search h or d chars in the string for replacing
  3. '<tr>'+'<t$0>A'*$args[1] - replace each char with string like <tr><t$0>A<t$0>A...
  4. where $0 is a captured group[0] - the char in the -replace.

Powershell, 65 bytes

'<table>h'+'d'*--$args[0]-replace'h|d',('<tr>'+'<t$0>A'*$args[1])

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

How it work:

  1. '<table>h'+'d'*--$args[0] - create a string like <table>hddd...
  2. 'h|d'- search h or d chars in the string for replacing
  3. '<tr>'+'<t$0>A'*$args[1] - replace each char with string like <tr><t$0>A<t$0>A...
  4. where $0 is a captured group[0] - the char in the -replace.

Powershell, 63 bytes

$m,$n=$args;$t='h';'<table>';1..$m|%{'<tr>'+"<t$t>A"*$n;$t='d'}

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output (extra spaces are optional):

<table>
<tr><th>A<th>A<th>A
<tr><td>A<td>A<td>A
<table>
<tr><th>A<th>A<th>A
<table>
<tr><th>A<th>A
<tr><td>A<td>A
<tr><td>A<td>A
<tr><td>A<td>A
<table>
<tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A
<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

Powershell, 65 bytes

case with -replace:

'<table>h'+'d'*--$args[0]-replace'h|d',('<tr>'+'<t$0>A'*$args[1])

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

output:

<table><tr><th>A<th>A<th>A<tr><td>A<td>A<td>A
<table><tr><th>A<th>A<th>A
<table><tr><th>A<th>A<tr><td>A<td>A<tr><td>A<td>A<tr><td>A<td>A
<table><tr><th>A<th>A<th>A<th>A<th>A<th>A<th>A<th>A<tr><td>A<td>A<td>A<td>A<td>A<td>A<td>A<td>A

How it work:

  1. '<table>h'+'d'*--$args[0] - create a string like <table>hddd...
  2. 'h|d'- search h or d chars in the string for replacing
  3. '<tr>'+'<t$0>A'*$args[1] - replace each char with string like <tr><t$0>A<t$0>A...
  4. where $0 is a captured group[0] - the char in the -replace.
Source Link
mazzy
  • 7.2k
  • 2
  • 12
  • 22

Powershell, 65 bytes

'<table>h'+'d'*--$args[0]-replace'h|d',('<tr>'+'<t$0>A'*$args[1])

save it as new-mntable.ps1. Test script:

.\new-mntable.ps1 2 3
.\new-mntable.ps1 1 3
.\new-mntable.ps1 4 2
.\new-mntable.ps1 2 8

How it work:

  1. '<table>h'+'d'*--$args[0] - create a string like <table>hddd...
  2. 'h|d'- search h or d chars in the string for replacing
  3. '<tr>'+'<t$0>A'*$args[1] - replace each char with string like <tr><t$0>A<t$0>A...
  4. where $0 is a captured group[0] - the char in the -replace.