পাওয়ারশেল, ১০২ বাইট
param($s,$i)$l=$s.Length;$s+' '*($i%$l)-split"(.{$i})"|?{$_}|%{$r=-not$r;@($_,($_[$l..0]-join''))[$r]}
নিম্নলিখিত হিসাবে অনুরোধ করা হয়েছে (যদি ফাইলটিতে সংরক্ষণ করা হয় CodeGolf55051.ps1
)
.\CodeGolf55051.ps1 -s '1234567890' -i 4
পূর্ববর্তী প্রচেষ্টা
(দীর্ঘ বা অবৈধ)
পাওয়ারশেল, 110 বাইট
param($s,$i)$l=$s.Length;$s+' '*(($i-$l%$i)%$i)-split"(.{$i})"|?{$_}|%{$r=-not$r;@($_,($_[$l..0]-join''))[$r]}
পাওয়ারশেল, 111 বাইট
param($s,$i)$s+' '*(($i-$s.Length%$i)%$i)-split"(.{$i})"|?{$_}|%{$r=-not$r;@($_,($_[$_.length..0]-join''))[$r]}
ব্যাখ্যা
param($s,$i) #Take input text (s) and column width (i)
$s #take the user entered string
+ ' ' * (($i - $s.Length % $i) % $i) #add the least number of spaces required to make its length divisible by i
-split"(.{$i})" #break it into chunks of i characters in length
| ?{$_} #skip any blank lines created in the process
| %{ #for each line
$r = -not $r; # toggle a boolean value
@( # define an array
$_ # index 0 = the string going forwards
,($_[$_.length..0] -join '') # index 1 = the string reversed (by taking each character from the last to the first, then joining them)
)[$r] # if our boolean value is false take the forward string (index 0), if true take the backwards one (index 1)
} #next
পাওয়ারশেল, 180 বাইট
param($s,$i)$x="`${0}|{1}|`${2}";$w=$x;1..$i|%{$w=$w-f$_,$x,($i+$_)};$w=$w-replace'\||\${.*}';$r=$w-replace'\$\d+','(.)?';$s+' '*($i-$s.Length%$i)-replace$r,$w-split"(.{$i})"|?{$_}
পাওয়ারশেল, 196 বাইট
param($s,$i)$x="{0}|{1}|{2}";$w=$x;1..$i|%{$w=$w-f$_,$x,($i+$_)};$w=$w-replace'(\d+)','$$$1'-replace'\||{.*}';$r=$w-replace'\$\d+','(.)?';$s+' '*($i-$s.Length%$i)-replace$r,$w-split"(.{$i})"|?{$_}
ব্যাখ্যা
param ($s, $i) #Take input text (s) and column width (i)
$x = "{0}|{1}|{2}" #Define string format which takes 3 entries and pipe delimits them
$w = $x #initialise our replacement regex with this format
1..$i | %{ #for 1 to the specified column width
$w = $w -f $_, $x, ($i + $_) #update the regex 1|{...}|5, 1|2|{...}|6|5, etc
} #resulting in w = 1|2|3|4|{...}|8|7|6|5
$w = $w -replace '(\d+)', '$$$1' #now prefix the numbers with a dollar (so they're regex replacement variables)
-replace '\||{.*}' #and remove the delimiters and superfluous `{...}` left from our middle insertion routine
$r = $w -replace '\$\d+', '(.)?' #then create the match pattern by replacing the variables with optional single character captures
$s #now take the user entered string
+ ' ' * ($i - $s.Length % $i) #add the least number of spaces required to make its length divisible by i
-replace $r, $w #perform a replacement using the regex match and replace patterns created above
-split "(.{$i})" #then split the string into blocks of length i
| ?{$_} #removing any blank lines created in the process
( {...}
উপরের মন্তব্যগুলিতে আসলে {0}|{1}|{2}
; আমি {...}
উন্নত পাঠযোগ্যতার জন্য রেখেছি)
পাওয়ারশেল, 120 বাইট
(অবৈধ)
param($s,$i)$s + ' ' * ($i-$s.Length%$i) -replace '(.{4})?(.)(.)(.)(.)',"`$1`n`$5`$4`$3`$2`n" -split "`n" | ?{$_ -ne ""}