Ẇa6ḌạÐṂ⁸Ṫ
모나 딕 링크.
온라인으로 사용해보십시오! -이 링크에는 거의 아무 의미가 없습니다 (아래 참조)!
어떻게?
진정한 골퍼 스타일에서는 이것이 비효율적입니다. 365 테스트 케이스의 TIO에서 60 초의 시간을 초과했습니다 ! 국부적으로 이것은 37에서 끝납니다.
Ẇ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 년대가 제한 내에서 패치는 동일한 알고리즘 실행을 만들기 위해 365 및 366 TIO에가의 암시 vectorisation 방지하는 것입니다 Ḍ
와 Ẇa6Ḍ€ạÐṂ⁸Ṫ
( 그 시도를 ) 그러나 이것은 현재의 입력에 대한 독방 감금 - 잘못 것, 999 ( 삼각형 (999)가 아니라 499,500 이지만 각각 정수 목록 으로, 적어도 파이썬에서는 메모리가 효율적이지 않은 총 Tetrahedral (999) = 166,666,500 정수를 만듭니다 ).