घड़ी हाथ Syzygy


16

(मुझे इस के लिए डिजाइन परीक्षण मामलों में मदद करने के लिए एल'एंडिया स्टैट्रान और Sp3000 के लिए बड़े पैमाने पर धन्यवाद!)

एक सकारात्मक पूर्णांक nऔर कई घड़ी हाथ (सेकंड में) के लिए सकारात्मक पूर्णांक घूर्णी अवधियों की एक सूची को देखते हुए , सबसे छोटा सकारात्मक पूर्णांक आउटपुट करता है, xजहां xघड़ी को हाथों के सभी के साथ शुरू करने के बाद सेकंड, ठीक nहाथों से गठबंधन किया जाता है। उन्हें प्रारंभिक स्थिति में गठबंधन करने की आवश्यकता नहीं है - कोई भी स्थिति ठीक है, जब तक कि xएक पूर्णांक नहीं है और कम से कम है। इसके अलावा, सभी हाथों को एक ही स्थिति में संरेखित नहीं करना पड़ता है - इसके लिए n=4, एक समाधान जहां 2 हाथों के 2 समूह संरेखित होते हैं। समूहों का आकार 2 या उससे अधिक होना चाहिए - दो बिना हाथ वाले हाथ 1 संरेखित हाथ के 2 समूहों का गठन नहीं करते हैं, और इस प्रकार एक वैध समाधान नहीं है।

आप मान सकते हैं कि केवल इनपुट जहां संभव है कि nपूर्णांक संरेखित होने के बाद हाथों को कुछ सेकंड के लिए दिया जाएगा - 2, [3,3,3]कोई मान्य इनपुट नहीं है, क्योंकि सेकंड की किसी भी संख्या के बाद, सभी 3 हाथ संरेखित होंगे, और इसलिए यह असंभव है ठीक 2 गठबंधन करने के लिए।

उदाहरण:

2, [3,4] -> 12
(the only option is a multiple of 12, so we pick 12 - 4 and 3 full rotations, respectively)

3, [3,5,6,9,29] -> 18
(picking 3, 6, and 9, the hands would align after 6, 3, and 2 rotations, respectively)

2, [1,1,4,5,10] -> 1
(picking 1 and 1 - note that 0 is not a valid answer because it is not a positive integer)

3, [2,2,6,7,11] -> 3
(picking 2, 2, and 6 - the 2s would be halfway through their second revolution, and the 6 would be halfway through its first revolution)

2, [2,7,5,3,3] -> 1
(picking 3 and 3, they are always aligned, so 1 is the minimum)

5, [4, 14, 36, 50, 63, 180, 210] -> 45
(after 45 seconds, the first, third, and sixth are aligned, as well as the second and seventh, for a total of 5)

परीक्षण डेटा:

7, [10, 22, 7, 6, 12, 21, 19] -> 87780
6, [25, 6, 2, 19, 11, 12] -> 62700
6, [23, 1, 8, 10, 9, 25] -> 41400
7, [6, 4, 1, 8, 10, 24, 23] -> 920
3, [18, 5, 23, 20, 21] -> 180
5, [10, 8, 14, 17, 5, 9] -> 2520
6, [1, 18, 12, 9, 8, 10, 23] -> 360
6, [12, 11, 6, 23, 25, 18, 13] -> 118404
4, [18, 11, 2, 9, 12, 8, 3] -> 8
7, [18, 25, 9, 13, 3, 5, 20] -> 11700
2, [17, 20, 15, 8, 23, 3] -> 15
3, [16, 3, 24, 13, 15, 2] -> 24
5, [7, 23, 24, 8, 21] -> 1932
6, [16, 10, 12, 24, 18, 2, 21] -> 720
6, [1, 17, 16, 13, 19, 4, 15] -> 53040
2, [3, 4, 20] -> 5
3, [9, 4, 16, 14, 1, 21] -> 16
5, [5, 17, 10, 20, 12, 11] -> 330
2, [21, 5, 22, 18] -> 90
4, [7, 25, 2, 8, 13, 24] -> 84
4, [13, 19, 2, 20, 7, 3] -> 420
5, [4, 14, 36, 50, 63, 180, 210] -> 45
5, [43, 69, 16, 7, 13, 57, 21] -> 27664
3, [22, 46, 92, 43, 89, 12] -> 276
4, [42, 3, 49, 88, 63, 81] -> 882
6, [2, 4, 7, 10, 20, 21, 52, 260] -> 65
6, [2, 3, 4, 7, 10, 20, 21, 52, 260] -> 35
2, [3, 4] -> 12
3, [3, 5, 6, 9, 29] -> 18
2, [1, 1, 4, 5, 10] -> 1
3, [2, 2, 6, 7, 11] -> 3
3, [41, 13, 31, 35, 11] -> 4433
3, [27, 15, 37, 44, 20, 38] -> 540
5, [36, 11, 14, 32, 44] -> 22176
3, [171, 1615, 3420] -> 3060
3, [46, 36, 12, 42, 28, 3, 26, 40] -> 36
5, [36, 25, 20, 49, 10, 27, 38, 42] -> 1350
4, [40, 28, 34, 36, 42, 25] -> 2142
5, [24, 26, 47, 22, 6, 17, 39, 5, 37, 32] -> 1248
4, [9, 27, 12, 6, 44, 10] -> 108

नियम:

  • मानक खामियों को मना किया जाता है
  • यह , इसलिए सबसे छोटा कोड जीतता है!

लीडरबोर्ड

इस पोस्ट के निचले हिस्से में स्टैक स्निपेट उत्तर से लीडरबोर्ड उत्पन्न करता है) a) प्रति भाषा सबसे छोटे समाधान की सूची के रूप में और बी) एक समग्र लीडरबोर्ड के रूप में।

यह सुनिश्चित करने के लिए कि आपका उत्तर दिखाई दे रहा है, कृपया अपना उत्तर शीर्षक मार्कडाउन टेम्पलेट का उपयोग करके शीर्षक के साथ शुरू करें:

## Language Name, N bytes

Nआपके सबमिशन का आकार कहां है। यदि आप अपने स्कोर में सुधार करते हैं, तो आप पुराने अंकों को हेडलाइन में रख सकते हैं , उनके माध्यम से स्ट्राइक करके। उदाहरण के लिए:

## Ruby, <s>104</s> <s>101</s> 96 bytes

यदि आप अपने हेडर में कई संख्याओं को शामिल करना चाहते हैं (जैसे कि आपका स्कोर दो फ़ाइलों का योग है या आप दुभाषिया ध्वज दंड को अलग से सूचीबद्ध करना चाहते हैं), तो सुनिश्चित करें कि हेडर में वास्तविक स्कोर अंतिम संख्या है:

## Perl, 43 + 2 (-p flag) = 45 bytes

आप भाषा के नाम को एक लिंक भी बना सकते हैं जो बाद में स्निपेट में दिखाई देगा:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes


5
वाह, मुझे भी नहीं पता था कि यह एक शब्द है । क्या एक भयानक, जल्लाद-विजेता, स्क्रैबल-विजेता शब्द!
डिजिटल ट्रामा

@DigitalTrauma 3 Yटाइल्स को पाने का सौभाग्य ।
SuperJedi224

जवाबों:


7

पायथ, 28 27 24 बाइट्स

fqs-hMrS.RR7%R1cLTQ8 1vz

इसे Pyth Compiler में ऑनलाइन आज़माएँ

यह काम किस प्रकार करता है

fqs-hMrS.RR7%R1cLTQ8 1vz

                          (implicit) Save the input number in z (as string).
                          (implicit) Save the input list in Q.

f                         Find the first positive integer T such that:
               cLTQ         Compute T/α for each α in Q.
            %R1             Get the fractional part of each result.
        .RR7                Round each fractional part to 7 decimal digits.
       S                    Sort the resulting numbers.
      r            8        Perform run-length encoding.
    hM                      Get the lengths of the runs.
   -                 1      Discard runs of length 1.
  s                         Add the remaining runs.
 q                    vz    Check is the sum matches the input number.
                          If it does, break and return T.

परीक्षण के मामलों

$ cat input
7\n[10, 22, 7, 6, 12, 21, 19]\n87780
6\n[25, 6, 2, 19, 11, 12]\n62700
6\n[23, 1, 8, 10, 9, 25]\n41400
7\n[6, 4, 1, 8, 10, 24, 23]\n920
3\n[18, 5, 23, 20, 21]\n180
5\n[10, 8, 14, 17, 5, 9]\n2520
6\n[1, 18, 12, 9, 8, 10, 23]\n360
6\n[12, 11, 6, 23, 25, 18, 13]\n118404
4\n[18, 11, 2, 9, 12, 8, 3]\n8
7\n[18, 25, 9, 13, 3, 5, 20]\n11700
2\n[17, 20, 15, 8, 23, 3]\n15
3\n[16, 3, 24, 13, 15, 2]\n24
5\n[7, 23, 24, 8, 21]\n1932
6\n[16, 10, 12, 24, 18, 2, 21]\n720
6\n[1, 17, 16, 13, 19, 4, 15]\n53040
2\n[3, 4, 20]\n5
3\n[9, 4, 16, 14, 1, 21]\n16
5\n[5, 17, 10, 20, 12, 11]\n330
2\n[21, 5, 22, 18]\n90
4\n[7, 25, 2, 8, 13, 24]\n84
4\n[13, 19, 2, 20, 7, 3]\n420
5\n[4, 14, 36, 50, 63, 180, 210]\n45
5\n[43, 69, 16, 7, 13, 57, 21]\n27664
3\n[22, 46, 92, 43, 89, 12]\n276
4\n[42, 3, 49, 88, 63, 81]\n882
6\n[2, 4, 7, 10, 20, 21, 52, 260]\n65
6\n[2, 3, 4, 7, 10, 20, 21, 52, 260]\n35
2\n[3, 4]\n12
3\n[3, 5, 6, 9, 29]\n18
2\n[1, 1, 4, 5, 10]\n1
3\n[2, 2, 6, 7, 11]\n3
3\n[41, 13, 31, 35, 11]\n4433
3\n[27, 15, 37, 44, 20, 38]\n540
5\n[36, 11, 14, 32, 44]\n22176
3\n[171, 1615, 3420]\n3060
3\n[46, 36, 12, 42, 28, 3, 26, 40]\n36
5\n[36, 25, 20, 49, 10, 27, 38, 42]\n1350
4\n[40, 28, 34, 36, 42, 25]\n2142
5\n[24, 26, 47, 22, 6, 17, 39, 5, 37, 32]\n1248
4\n[9, 27, 12, 6, 44, 10]\n108
$ while read -r; do echo -e "$REPLY" | pyth -c 'qvwfqs-hMrS.RR7%R1cLTQ8 1vz'; done < input
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True

3

जेली , 19 16 बाइट्स

P:×ⱮP%PĠẈḟ1Sʋ€iƓ

सरणी को तर्क के रूप में लेता है, STDIN से पूर्णांक।

अधिकांश धीमी गति से और स्मृति परीक्षण के अधिकांश मामलों के लिए भूख लगी है।

इसे ऑनलाइन आज़माएं!

वैकल्पिक संस्करण, 14 बाइट्स

P÷€%1ĠẈḟ1Sʋ€iƓ

यह सिद्धांत रूप में काम करता है, लेकिन फ्लोटिंग-पॉइंट अशुद्धियों के कारण यह विफल हो सकता है।

इसे ऑनलाइन आज़माएं!

यह काम किस प्रकार करता है

P:×ⱮP%PĠẈḟ1Sʋ€iƓ  Main link. Argument: A (array)

P   P P           Yield the product of A.
 :                Divide the product by each n in A.
  ×Ɱ              Multiply the quotients by each k in [1, ..., prod(A)].
     %            Take the results modulo the product.
             €    Map the link to the left over the array of remainders.
            ʋ       Combine the links to the left into a dyadic chain.
       Ġ              Group indices of identical elements.
        Ẉ             Widths; yield the lengths of the groups.
         ḟ1           Filterfalse; remove all copies of 1.
           S          Take the sum.
               Ɠ  Read an integer j from STDIN.
              i   Find the first index of j in the array of sums.

2

CJam, 42 34 33 बाइट्स

0{)_eas~@d\f/1f%7fmO$e`0f=1m1b-}g

CJam दुभाषिया में इस फिडेल या इस परीक्षण सूट की कोशिश करें

यह काम किस प्रकार करता है

0       e# Push 0 (accumulator).
{       e# Do:
  )_    e#   Increment the accumulator and push a copy.
  eas~  e#   Push the command-line args, flatten and evaluate.
        e#   This pushes a number and an array.
  @d    e#   Rotate the accumulator copy on top and cast to Double.
  \f/   e#   Divide it by each of the integers in the array.
  1f%   e#   Get the fractional part of each result.
  7fmO  e#   Round all fractional parts to seven decimal digits.
  $e`   e#   Sort and perform run-length encoding.
  0f=   e#   Select the lengths of the runs.
  X-    e#   Discard runs of length 1.
  Xb    e#   Compute the sum of the remaining runs.
  -     e#   Subtract the sum from the input number (target).
}g      e# If this pushes a non-zero value, we've missed the target;
        e# repeat the loop.

हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.