জাভাস্ক্রিপ্ট (ES7), 108 বাইট
অক্ষরের ম্যাট্রিক্স হিসাবে ইনপুট নেয়।
f=m=>(g=(y,X,V)=>m.map(r=>r.map((v,x)=>V?v>f&V>'a'>(x-X)**2+y*y-2?r[x]=n--:0:v<f?g(-y,x,v):n++)|y++))(n=0)|n
এটি অনলাইন চেষ্টা করুন!
আমার মূল উত্তরের মতো, তবে V>'a'>(x-X)**2+y*y-2করণটি নীচে বর্ণিত হেক্সা ট্রিকটি ব্যবহার করার চেয়ে 1 বাইট কম খাটো। ¯ \: _ (ツ): _ / ¯
জাভাস্ক্রিপ্ট (ES7), 109 বাইট
অক্ষরের ম্যাট্রিক্স হিসাবে ইনপুট নেয়।
f=m=>(g=(y,X,V)=>m.map(r=>r.map((v,x)=>V?v>f&(x-X)**2+y*y<V-8?r[x]=n--:0:v<f?g(-y,x,'0x'+v):n++)|y++))(n=0)|n
এটি অনলাইন চেষ্টা করুন!
কিভাবে?
Quadrance দুই পয়েন্ট এবং হিসাবে সংজ্ঞায়িত করা হয়:A1=(x1,y1)A2=(x2,y2)
Q(A1,A2)=(x2−x1)2+(y2−y1)2
পূর্ণসংখ্যা স্থানাঙ্ক বিবেচনা করে, এটি নিম্নলিখিত হিসাবে দেখায়:
854585212541∙145212585458
অতএব:
- এ অবস্থিত একটি প্রকারের প্রতিষেধক হলে এ অবস্থিত একটি ভাইরাসকে হত্যা করতে সক্ষম হয়A1A2Q(A1,A2)<2
- এ অবস্থিত একটি টাইপ বি প্রতিষেধক যদি থাকে তবে এ অবস্থিত একটি ভাইরাসকে মেরে ফেলতে সক্ষমA1A2Q(A1,A2)<3
সুবিধামতভাবে, এই একচেটিয়া উপরের বাউন্ড ( বা ) হেক্সাডেসিমাল থেকে অ্যান্টিডোট চরিত্রটিকে দশমিক এবং রূপান্তর দ্বারা প্রাপ্ত করা যেতে পারে :238
- A16−810=210
- B16−810=310
মন্তব্য
f = // named function, because we use it to test if a character
// is below or above 'm'
m => ( // m[] = input matrix
g = ( // g is a recursive function taking:
y, // y = offset between the reference row and the current row
X, // X = reference column
V // V = reference value, prefixed with '0x'
) => //
m.map(r => // for each row r[] in m[]:
r.map((v, x) => // for each value v at position x in r[]:
V ? // if V is defined:
v > f & // if v is equal to 'v'
(x - X) ** 2 + // and the quadrance between the reference point and
y * y // the current point
< V - 8 ? // is less than the reference value read as hexa minus 8:
r[x] = n-- // decrement n and invalidate the current cell
: // else:
0 // do nothing
: // else:
v < f ? // if v is either 'a' or 'b':
g( // do a recursive call:
-y, // pass the opposite of y
x, // pass x unchanged
'0x' + v // pass v prefixed with '0x'
) // end of recursive call
: // else:
n++ // increment n
) | y++ // end of inner map(); increment y
) // end of outer map()
)(n = 0) // initial call to g with y = n = 0
| n // return n