Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. [0,0,0,0] -> 0
  2. [12,312,33,12] -> 4
  3. [1,2,3,4,5,6,7] -> 4
  4. [22,33,1,2,4] -> 3
  5. [1000,2,2,2] -> 2
  6. [23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42] -> 20
  7.  
  8. +/⊢≥⍋∘⍒
  9.  
  10. f←+/⊢≥⍋∘⍒
  11. f¨(4⍴0)(12 312 33 12)(⍳7)(22 33 1 2 4)(1000 2 2 2)(23 42 12 92 39 46 23 56 31 12 43 23 54 23 56 73 35 73 42 12 10 15 35 23 12 42)
  12. 0 4 4 3 2 20
  13.  
  14. tf<l-QUTT1
  15.  
  16. i=0
  17. for z in sorted(input())[::-1]:i+=z>i
  18. print i
  19.  
  20. l~{~}${W):W>},,
  21.  
  22. [:+/i.@#<:~
  23.  
  24. f=:[:+/i.@:#<:~
  25. f 0,0,0,0
  26. 0
  27. f 12,312,33,12
  28. 4
  29. f 1,2,3,4,5,6,7
  30. 4
  31. f 22,33,1,2,4
  32. 3
  33. f 1000,2,2,2
  34. 2
  35. f 23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42
  36. 20
  37.  
  38. LengthWhile[i=0;SortBy[#,-#&],#>i++&]&
  39.  
  40. In: LengthWhile[i=0;SortBy[#,-#&],#>i++&]&@{1,2,3,4,5,6,7}
  41. Out: 4
  42.  
  43. SELECT COUNT(R)FROM(SELECT ROW_NUMBER()OVER(ORDER BY V DESC)R,V FROM I)A WHERE R<=V
  44.  
  45. l~:I,),W%{_If>:!:+>}$0=
  46.  
  47. [23 42 12 92 39 46 23 56 31 12 43 23 54 23 56 73 35 73 42 12 10 15 35 23 12 42]
  48.  
  49. [0 0 0 0]
  50. [12 312 33 12]
  51. [1 2 3 4 5 6 7]
  52. [22 33 1 2 4]
  53. [1000 2 2 2]
  54. [23 42 12 92 39 46 23 56 31 12 43 23 54 23 56 73 35 73 42 12 10 15 35 23 12 42]]
  55. {:I,),W%{_If>:!:+>}$0=N}/
  56.  
  57. l~:I,),W%{_If>:!:+>}$0=
  58. l~:I "Read input, evaluate, store in I.";
  59. , "Get length of input N.";
  60. ),W% "Create range from 0 to N, reverse.";
  61. { }$ "Sort stably.";
  62. _I "Duplicate candidate h, push input list.";
  63. f> "Map each number to 1 if it's less or 0 otherwise.";
  64. :! "Invert all results.";
  65. :+ "Sum them up.";
  66. > "Check if the sum is less than the candidate h.";
  67. 0= "Pick the first element.";
  68.  
  69. #!perl -pa
  70. $_=grep$_>$i++,sort{$b<=>$a}@F
  71.  
  72. perl hidx.pl <<<'1 2 3 4 5 6 7'
  73.  
  74. lambda x:sum(a>b for a,b in zip(sorted(x)[::-1],range(len(x))))
  75.  
  76. f=->a,n=0{a.count{|x|x>n}<n+1?n:f[a,n+1]}
  77.  
  78. f=->a{a.size.downto(0).find{|x|a.count{|y|y>=x}>=x}}
  79.  
  80. sort -nr|nl -s>|bc|grep -c 0
  81.  
  82. $ for i in {23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42}; do echo $i; done | ./atleasth.sh
  83. 20
  84. $ for i in {1,2,3,4,5,6,7}; do echo $i; done | ./atleasth.sh
  85. 4
  86. $
  87.  
  88. s=sort(i);sum(s>=length(s):1)
  89.  
  90. > i=c(23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42)
  91. > s=sort(i);length(s[s>=length(s):1])
  92. [1] 20
  93. > i=c(0,0,0,0)
  94. > s=sort(i);length(s[s>=length(s):1])
  95. [1] 0
  96.  
  97. f s=[x-1|x<-[1..],x>sum[1|r<-s,r>=x]]!!0
  98.  
  99. [0, 0, 0, 0] 0
  100. [12, 312, 33, 12] 4
  101. [1, 2, 3, 4, 5, 6, 7] 4
  102. [22, 33, 1, 2, 4] 3
  103. [1000, 2, 2, 2] 2
  104. [23, 42, 12, 92, 39, 46, 23, 56, 31, 12, 43, 23, 54, 23, 56, 73, 35, 73, 42, 12, 10, 15, 35, 23, 12, 42] 20
  105.  
  106. NỤỤ<’S
  107.  
  108. N Negate (so that repeated elements won't mess up the second grade down)
  109. Ụ Grade down
  110. Ụ Twice.
  111. <’ Predicate, check for each element if the new one (after grading) is lower than original array (minus 1 on each element)
  112. S Sum
  113.  
  114. q~:Q,),{Q{1$>},,>!},W=
  115.  
  116. [23 42 12 92 39 46 23 56 31 12 43 23 54 23 56 73 35 73 42 12 10 15 35 23 12 42]
  117.  
  118. 20
  119.  
  120. $-1%0{1$>+}/
  121.  
  122. Input L1:1:While Ans≤sum(Ans≥L1:Ans+1:End:Ans
  123.  
  124. DC 5D 00 3E 31 3E D1 72 6D B6 72 6C 5D 00 3E 72 70 31 3E D4 3E 72
  125.  
  126. #include <iostream>
  127. #include <list>
  128. using namespace std;int main(int c,char** v){list<int>n(--c);int h=c;for(int&m:n)m=atoi(*(v+(h--)));n.sort();for(auto r=n.rbegin();r!=n.rend()&&*r++>++h;);cout<<(h==c?h:--h)<<endl;}
  129.  
  130. 0SJC{Sd@>+1}/S
  131.  
  132. 0 Push the number 0 (the counter)
  133. SJC Swap to array, sort and reverse
  134. {Sd@>+1}/ For each item in the array, add 1 to counter if counter is less than item
  135. S Swap counter to top of stack
  136.  
  137. [:+/#<::~
  138.  
  139. ([:+/#<::~) 1 2 3 4 5 6 7
  140. 4
  141.  
  142. */ (([:+/#<::~) = ([:+/i.@#<:~))"1 ?100 100$100
  143. 1
  144.  
  145. 1#xk#yaïí'1ø ~n-1$
  146. 1+)x(%:1,%1ex+y1-?^#y#x
  147.  
  148. 1#xk#yaïí'1ø
  149.  
  150. 1+)x(%:1,%1ex+y1-?^#y#x
  151.  
  152. Command | Stack
  153. --- | a, b
  154. % | a/b
  155. : | a/b, a/b
  156. 1 | a/b, a/b, 1
  157. , | a/b, (a/b)%1
  158. e | (a/b) == ((a/b)%1)
  159.  
  160. ~n-1$
  161.  
  162. FirstCase[Range[Length@#,0,-1],h_/;Count[#,k_/;k>=h]>=h]&
  163.  
  164. FirstCase[Range[Length@#,0,-1],h_/;Count[#,k_/;k>=h]>=h]&@{1,2,3,4,5,6,7}
  165.  
  166. FirstCase[Range[Length@#,0,-1],h_/;Count[#,k_/;k>=h]>=h]& /@ {
  167. {0, 0, 0, 0},
  168. {12, 312, 33, 12},
  169. {1, 2, 3, 4, 5, 6, 7},
  170. {22, 33, 1, 2, 4},
  171. {1000, 2, 2, 2},
  172. {23, 42, 12, 92, 39, 46, 23, 56, 31, 12, 43, 23, 54, 23, 56, 73, 35,
  173. 73, 42, 12, 10, 15, 35, 23, 12, 42}
  174. }
  175.  
  176. def h(a:Int*)=Range(a.size,-1,-1).find(b=>a.count(b<=)>=b).get
  177.  
  178. long f(java.util.ArrayList<Long>l){for(int i=0;;){long x=i++;l.removeIf(j->j<x);if(l.size()<x)return x-1;}}
  179.  
  180. long f(java.util.ArrayList<Long> l) {
  181. for(int i = 0;;) {
  182. long x = i;
  183. i++;
  184. l.removeIf(j -> j<x);
  185. if(l.size() < x)
  186. return x-1;
  187. }
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement