এএসসিআইআই আর্কিটেক্ট


15

আপনি ব্যয়বহুল আর্কিটেকচারাল প্রোগ্রামের জন্য অর্থ দিতে চান না, তাই আপনি নিজের রোল করার সিদ্ধান্ত নেন। আপনি আপনার বিল্ডিংগুলি ডিজাইনের জন্য ASCII ব্যবহার করার সিদ্ধান্ত নিয়েছেন। আপনার প্রোগ্রামটি একটি নির্দিষ্ট উপায়ে ফর্ম্যাট করা একক স্ট্রিং নেবে এবং প্রোগ্রামটি বিল্ডিংকে আউটপুট দেবে।

ইনপুট

ইনপুটটিতে অক্ষরের একক লাইন থাকে। এটি কেবল অক্ষর a-j, সংখ্যা 1-9এবং চিহ্ন -এবং থাকতে পারে বলে ধরে নেওয়া যেতে পারে +

আউটপুট বিবরণ

প্রতিটি বর্ণের জন্য a-j, প্রোগ্রামটি নীচে উল্লম্ব লাইন আউটপুট দেবে। আমরা এটিকে একটি কলাম বলব।

         .
        ..
       ...
      ****
     *****
    ******
   -------
  --------
 +++++++++
++++++++++
abcdefghij

উদাহরণস্বরূপ, ইনপুট abcdefgfedefghgfedcআউটপুট হবে:

             .
      *     ***
     ***   *****
    ***** *******
   ---------------
  -----------------
 ++++++++++++++++++
+++++++++++++++++++

একটি চিঠি ইতিবাচক পূর্ণসংখ্যার সাথে উপসর্গযুক্ত করা যেতে পারে n, যা nকলামের নীচে সাদা স্পেস অক্ষর যুক্ত করবে । আমরা এটিকে অফসেট বলব। উদাহরণস্বরূপ, Sএকটি সাদা স্থান চিহ্নিত করতে ব্যবহার করে , ইনপুটটি 3b2b3bআউটপুট দেয়:

+ +
+++
S+S
SSS
SSS

একটি চিঠিটি একটি নেতিবাচক পূর্ণসংখ্যার সাথেও উপস্থাপিত হতে পারে -m, যা কলামের নীচের অদ্বিতীয় স্থানগুলিকে মুছে ফেলবে (তাদের সাদা অংশের সাথে প্রতিস্থাপন করবে না, পুরোপুরি মুছে ফেলবে)। আমরা এটিকে একটি স্লাইস বলব। উদাহরণস্বরূপ, ইনপুট আউটপুট হবে:m -1j-2j-3j-4j-5j-6j-7j-8j

.
..
...
*...
**...
***...
-***...
--***...
+--***..

একটি অফসেট এবং একটি স্লাইস একই লাইনে প্রয়োগ করা যেতে পারে তবে অফসেটটি প্রথমে যেতে হবে। অন্য কথায়, চিঠিটি উপসর্গের আকার n-m, যেখানে nঅফসেটের mআকার এবং স্লাইসের আকার with উদাহরণস্বরূপ, Sএকটি সাদা স্থান চিহ্নিত করতে ব্যবহার করে , ইনপুট '2-4j' আউটপুট দেয়:

.
.
.
*
*
*
S
S

শেষ অবধি, +দুটি কলামের মধ্যে ব্যবহৃত অপারেটরটি ইঙ্গিত দেয় যে তাদের পৃথক কলামগুলির পরিবর্তে একই কলামে একে অপরের শীর্ষে স্ট্যাক করা উচিত। উদাহরণস্বরূপ, ইনপুট `2-4ja 'আউটপুটগুলি:

.
.
.
*
*
*
S
S+

ইনপুট 2-4j+aআউটপুটস যেখানে :

+
.
.
.
*
*
*
S
S

এখানে একটি নমুনা ইনপুট:

abiehef+ehfhabc

এবং ফলাফল আউটপুট:

      *
      -
  .   -
  . . +. .
  * * +* *
  * * ****
  ********
  --------
  --------  -
 +++++++++ ++
+++++++++++++

দেখতে কোনও পুরানো ধ্বংসপ্রাপ্ত দুর্গ টাওয়ারের মতো tower

এখানে আরও একটি নমুনা ইনপুট রয়েছে:

6b5b+a6b1-2d+3-4f1-2d+-2c+2-4f+1-2d+-2c2-2d+1-4g+1-2c+b+-2c+-4e2-7j+-4g+d+-2c+-4f2-7j+-5h+b+-2c+a+-3f2-7j+-7i+-4e+b+b+a+-4f2-7i+a+-7h+-4f+b+b+a+-4f2-7j+-7h+-4f+a+-7h+a+-7i+-4f2-7j+-7i+-6h+a+-7i+b+-4e3-7i+a+-7h+-4e+a+-7h+b+1-7h3-7j+1-4f+-7h+b+-4f+a3-7j+2-4f+a+-4f+b3-2d+-2d+3-4g+b3-2d+-2d+-2c

এবং ফলাফল আউটপুট:

      ****** +++
     ******+.*++
     ---++.+ ***
    -+-+++..++**
    -+--+++.+++*
    --++++.+..*
      +++++.+**
+++****.******  -
+++*****.**..  --
 +   ***....+..--
      ...+.....--
    --.........--
   ---......
   --

(এটি মারিও হওয়ার কথা ছিল তবে খুব ভাল ফল দেয়নি ...)

স্পেসিফিকেশনটি এখনও স্পষ্ট না হলে আমার কাছে পাইথন ২.7 -তে একটি নন-গল্ফ প্রয়োগ রয়েছে । আপনি এটি চালাতে পারেন এবং স্পেসিফিকেশন কীভাবে কাজ করে তার অনুভূতি পেতে পরীক্ষা করতে পারেন। আপনি আমার প্রোগ্রামিং দক্ষতায় হাসতে পছন্দ করতে পারেন।

এটি কোড-গল্ফ, তাই স্বল্পতম এন্ট্রি জয়। অস্পষ্ট হলে মন্তব্যে প্রশ্ন জিজ্ঞাসা করুন।


দুটি বেশি টাওয়ার স্ট্যাকিং বৈধ? আমি আপনার উদাহরণগুলির মধ্যে একটিতে "2 সি + বি + -2 সি" দেখতে পাচ্ছি, তবে আপনি কীভাবে সেগুলি সজ্জিত করেছেন তা আমি খুঁজে বের করতে পারছি না।
অ্যান্ডোডান

1
@ অ্যান্ডোডাউন টাওয়ারগুলি + ব্যবহার করে অসীম স্ট্যাক করা যায়। উদাহরণস্বরূপ a+a+a+a+aএকে অপরের উপরে পাঁচটি সংকেত আউটপুট আউটপুট হবে।
অ্যাবসিন্থে


@ হুয়ার্ড হু, আপনি ঠিক বলেছেন, এগুলি আশ্চর্যজনকভাবে একই রকম (টাওয়ারটি কেটে ফেলতে এবং টাওয়ারগুলি সজ্জিত করতে সক্ষম হওয়ার একমাত্র সংযোজন)।
মার্টিন এন্ডার

@ হুয়ার্ড হু আপনি যখন নিজের শিরোনামটি টাইপ করেন তখন আপলোড হওয়া সেই সমকালীন প্রশ্নগুলির উপরে এটি প্রদর্শিত হয় নি। হোয়াইটস্পেসের বাস্তবায়ন যদিও কিছুটা আলাদা। আমি আমার পোস্টটিকে সদৃশ হিসাবে পতাকাঙ্কিত করব এবং মোডগুলি কী ভাবছে তা দেখতে পাবো।
অ্যাবসিংহে

উত্তর:


10

রুবি, 223 214 বাইট

g=$*[0].split(/(?<=[a-j])(?!\+)/).map{|r|r.scan(/(\d*)(-\d+)?([a-j])/).map{|a,b,c|' '*a.to_i+'++--***...'[-b.to_i..c.ord-97]}*''}
puts g.map{|s|s.ljust(g.map(&:size).max).chars.reverse}.transpose.map(&:join).join$/

ঐটা মজা ছিল. :)

যদিও এটি বেশ স্পষ্ট হওয়া উচিত, আমি এই চ্যালেঞ্জগুলি করার একটি নতুন উপায় আবিষ্কার করেছি যেখানে কলামগুলি থেকে স্ট্রিংগুলি নির্মিত হয়েছে: কেবল সারিগুলিতে এটি করুন, এবং সমস্ত কিছুর সাথে যোগ দেওয়ার আগে অক্ষরের অ্যারে স্থানান্তরিত করুন।

g=$*[0].split(/(?<=[a-j])(?!\+)/)               # Split into columns.
       .map{|r|                                 # For each column
            r.scan(/(\d*)(-\d+)?([a-j])/)       # Split into components.
             .map{|a,b,c|                       # For each component
                ' '*a.to_i+                     # Prepend spaces if any.
                '++--***...'[-b.to_i..c.ord-97] # Select the appropriate slice of the tower.
            }*''                                # Join all components together.
        }
puts g.map{|s|                                  # For each column
            s.ljust(g.map(&:size).max)          # Pad with spaces on the right such that. 
                                                # all columns are the same height.
            .chars.reverse                      # Turn into character array and reverse.
      }
      .transpose                                # Mirror in the main diagonal.
      .map(&:join)                              # Join lines.
      .join$/                                   # Join columns.

চূড়ান্ত লাইনের আলাদা শৈলী চেষ্টা ছিল এবং বের হয়ে এল puts (0..z=g.map(&:size).max-1).map{|i|g.map{|y|(v=y[z-i])?v:?\ }*''}। তবে সম্ভবত ট্রান্সপোজ ছাড়া এত মজা হয় না।
ভেক্টরাইজড

@ বিটপউনার ধন্যবাদ, আমি পরে এটি দেখতে এবং পরীক্ষা করব।
মার্টিন ইন্ডার

2

কোবরা - 473

আমি মনে করি না কোবরা কখনই এর মধ্যে একটিও জিততে পারে: /

use System.Text.RegularExpressions
class P
    def main
        r=Regex.matches(Console.readLine,r'(?<=^|[a-j])(([^a-j]*[a-j])+?)(?=[^+]|$)')
        z,l=0String[](r.count)
        for m in r.count,for n in'[r[m]]'.split('+'),l[m]+=' '.repeat(int.parse('0[Regex.match(n,r'(?<!-)\d+')]'))+'++--***...'[int.parse('0[Regex.match(n,r'(?<=-)\d+')]'):' abcdefghij'.indexOf(n[-1:])]
        for y in l,if y.length>z,z=y.length
        for x in-z+1:1
            for y in l,Console.write(if(-x<y.length,y[-x],' '))
            print

সমস্ত সুন্দর এবং মন্তব্য:

সম্পাদনা: ঠিক বুঝতে পেরেছি এটি সন্দেহজনকভাবে রুবি সমাধানের সাথে সাদৃশ্যপূর্ণ। বিখ্যাত মন সর্বদাই অন্যরকম চিন্তা করে?

use System.Text.RegularExpressions
class P
    def main
        r=Regex.matches(Console.readLine,r'(?<=^|[a-j])(([^a-j]*[a-j])+?)(?=[^+]|$)')
        # Split into columns
        z,l=0,String[](r.count)
        # Assign the column-array
        for m in r.count
        # Loop through columns
            for n in'[r[m]]'.split('+')
            # Loop through individual letter instructions
            # - within columns
                l[m]+=
                # Add characters to the last column
                    ' '.repeat(int.parse('0[Regex.match(n,r'(?<!-)\d+')]'))+
                    # Any spaces, plus
                    '++--***...'[:' abcdefghij'.indexOf(n[-1:])]
                    # The default column string
                        [int.parse('0[Regex.match(n,r'(?<=-)\d+')]'):]
                        # Sliced to the right length
        for y in l,if y.length>z,z=y.length
        # Determine the maximum length of any column
        for x in-z+1:1
            for y in l
            # Loop through columns so that they rotate to the left
                Console.write(if(-x<y.length,y[-x],' '))
                # Write the character in the current position
            print
            # Insert newlines

2

লুয়া - 451

a=arg[1]j='++--***...'I=io.write M=string.match U=string.sub T=table.insert n=''y=0 t={}m=0 for i in a:gmatch('[%-%d]*[a-j]%+?')do b=M(i,'-(%d)')b=b or 0 s=M(U(i,1,1),'%d')s=s or 0 n=n..(' '):rep(s)..U(U(j,1,M(U(i,-2),'[a-j]'):byte()-96),1+b,-1)if U(i,-1,-1)~="+"then T(t,n)m=m<#n and #n or m n=""y=y+1 end end T(t,n)n=''for k,v in pairs(t)do n=#v<m and n..v..(' '):rep(m-#v)or n..v end for i=m,1,-1 do for k=0,m*y-1,m do I(U(n,i+k,i+k))end I'\n'end

বিশেষ কিছু না. একবারের জন্য ফাংশনগুলির বোতাম-লোডটির নামকরণ করা মজাদার ছিল। আমি পরে অবারিত কোড সম্পাদনা করব।

এখানে চেষ্টা করে দেখুন। নমুনা আউটপুট:

SampleOutput


1

পাওয়ারশেল , 214 212 209 206 200 বাইট

-৩ বাইট ধন্যবাদ @ ভেস্কাহ

switch -r($args-split'(-?.)'){\+{$c=1}\d{sv('ps'[0-gt$_])$_}[a-j]{if(!$c){$t+=,''}$t[-1]+=' '*$p+-join'++--***...'[-$s..($_[0]-97)];$c=$p=$s=0}}($t|% Le*|sort)[-1]..1|%{-join($t|% *ht $_|% ch*($_-1))}

এটি অনলাইন চেষ্টা করুন!

কম গল্ফ সংস্করণ:

# make table with lines instead columns
switch -r($args-split'(-?.)'){
    \+ {$c=1}
    \d {set-variable ('ps'[0-gt$_]) $_}
    [a-j] {
        if(!$c){$t+=,''}
        $t[-1]+=' '*$p+-join'++--***...'[-$s..($_[0]-97)]
        $c=$p=$s=0
    }
}
# transpose
($t|% Length|sort)[-1]..1|%{
    -join($t|% padRight $_|% chars($_-1))
}


অসাধারণ! ধন্যবাদ।
mazzy

0

পাইথন 3, 268 বাইট

import re
q,t=[(p,' '*int(o or 0)+'++--***...'[-int(s or 0):ord(l)-96])for p,o,s,l in re.findall('(\+?)(\d?)(-\d)?(.)',input())],[]
while q:p,s=q.pop(0);t+=[t.pop()+s if p else s]
t=[*zip(*[[*c.ljust(max(map(len,t)))]for c in t])][::-1]
for l in t:print(*l,sep='')

মূলত:

# import the regex module
import re

# array to store initial input
q = []
# array to store translated output
t = []

# split string from stdin into column groups, like: ('plus or blank', 'offset or blank', 'slice or blank', 'letter')
# ex: 6b1-2d+a would become:
# [('','6','','b'), ('', '1', '-2', 'd'), ('+', '', '', 'a')]
i = re.findall('(\+?)(\d?)(-\d)?(.)',input())

# iterate through the groups returned by the regex
for p,o,s,l in i:
    # create offset string
    # int() cannot parse '', but empty strings are falsey,
    # so (o or 0) is equivalent to 'parse the string as an int, or return 0 if it is empty'
    offset = ' ' * int(o or 0)

    # get the starting point of the slice
    # since the regex returns the minus, it must be negated after converting the string to an int
    # as before, (s or 0) ensures that the slice is converted to an int properly
    start = -int(s or 0)
    # since 'a' is ordinal 97, this ensures that the end position will be 1-9
    end = ord(l) - 96
    # slice the largest possible column string with the calculated start and end positions
    a = '++--***...'[start:end]
    # add the space offset
    a = offset + a
    # add the plus sting and the column string to the array
    q.append( (p, a) )

# while q is not empty
while q:
    # remove the first item from the list and separate it into a plus variable and a column string
    p, s = q.pop(0)

    # if p is not blank, it is a '+'
    # if p is truthy, remove the last item added and add s to it
    # otherwise just return s
    # append the resulting item to the ongoing list
    t += [t.pop()+s if p else s]

temp = []
for c in t:
    # call len() on all items in t, then return the maximum length
    m = max(map(len, t))
    # left justify c by adding spaces to the right, up to m total characters
    c = c.ljust(m)
    # unpack c into a list
    # this is equivalent to list(c), but shorter
    c = [*c]
    # add the list of characters to the array
    temp.append(c)

t = temp

# t is currently a list of rows, and needs to be rotated so that it displays correctly
# input: 'abcdefghij'
# before:
#
# +
# ++
# ++-
# ++--
# ++--*
# ++--**
# ++--***
# ++--***.
# ++--***..
# ++--***...
#
# after:
#
#  ++++++++++
#   +++++++++
#    --------
#     -------
#      ******
#       *****
#        ****
#         ...
#          ..
#           .
# 
t = [*zip(*t)]
# t is currently upside down, reverse the list
t = t[::-1]

# for each line (currently a list of characters)
for l in t:
    # unpack the list into print as arguments, do not add a space between arguments
    print(*l,sep='')
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.