Ẇa6ḌạÐṂ⁸Ṫ
Monadik bir bağlantı.
Çevrimiçi deneyin! - Bu linkte neredeyse hiçbir nokta yok (aşağıya bakınız)!
Nasıl?
Gerçek golfçü tarzında bu gerçekten verimsiz - 365 test vakası için TIO'da 60'ların zaman aşımına uğradı ! Yerel olarak bu 37'lerde biter.
Ẇa6ḌạÐṂ⁸Ṫ - Main link: n
Ẇ - all sublists - this has an implicit make_range on it's input
- so, for example, an input of 3 yields [[1],[2],[3],[1,2],[2,3],[1,2,3]]
- the important things are: that it contains both a list of the length of the
- decimal number, and a list 1 shorter; and that it's lists only contain
- non-zero numbers and are monotonically increasing in length.
6 - literal 6
a - and (vectorises), this changes all the values to 6s
- so, the example above becomes [[6],[6],[6],[6,6],[6,6],[6,6,6]]
Ḍ - convert to decimal (vectorises) [ 6, 6,, 6, 66, 66, 666 ]
⁸ - link's right argument, n
ÐṂ - filter keep those with minimal:
ạ - absolute difference (for 366 this keeps 66 AND 666; same goes for 3666; etc.)
Ṫ - tail - get the rightmost result (for 366 keeps 666, since it's longer)
60'lar için sınırlamak içinde bir yama aynı algoritma çalışmasını sağlamak için 365 ve 366 TIO üzerinde örtülü vectorisation kaçınmaktır Ḍile Ẇa6Ḍ€ạÐṂ⁸Ṫ( yani deneyin ) Ancak bu artık bir girdi için seg-arıza olacak, 999 ( Triangle (999) sadece 499.500, ancak her biri bir tam sayı listesidir, toplam Tetrahedral yapar (999) = 166,666,500 tam sayı, hafıza etkin değil, en azından Python'da).