• API
• FAQ
• Tools
• Archive
daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest May 16th, 2018 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Input  : [5,5,5,5,5] 100
2. Output : 5*5*5-5*5
3.
4. Input  : [1,2,3,4,5] 0
5. Output : 12-3-4-5
6.
7. fqeQvTms.ihQd^"+-*/"lth
8.
9. DECLARE @ varchar(max)= '5,5,5'
10. DECLARE @a varchar(20) = '125'
11.
12. ,@ varchar(max)='';WITH D as(SELECT @a a UNION ALL SELECT STUFF(a,charindex(',',a),1,value)FROM STRING_SPLIT('*,+,./,-,',',')x,d WHERE a like'%,%')SELECT @+=a+','''+REPLACE(a,'.','')+'''),('FROM D WHERE a not like'%,%'EXEC('SELECT y FROM(values('+@+'null,null))g(x,y)WHERE x='+@b)
13.
14. DECLARE @a varchar(max)= '5,5,5'
15. DECLARE @b varchar(20) = '5'
16.
17. ,@ varchar(max)=''
18. ;WITH D as
19. (
20.   SELECT @a a
21.   UNION ALL
22.   SELECT STUFF(a,charindex(',',a),1,value)
23.   FROM STRING_SPLIT('*,+,./,-,',',')x,d
24.   WHERE a like'%,%'
25. )
26. SELECT @+=a+','''+REPLACE(a,',','')+'''),('
27. FROM D
28. WHERE a not like'%,%'
29.
30. EXEC('SELECT y FROM(values('+@+'null,null))g(x,y)WHERE x='+@b)
31.
32. a=>o=>(c=[],i=c=>{for(j=0;!((c[j]?++c[j]:c[j]=1)%5);)c[j++]=0},eval(`while(eval(e=(a+'').replace(/,/g,(_,j)=>'+-*/'.charAt(c[~-j/2])))!=o)i(c);e`))
33.
34. n=length(x)-1
35. k=n*2+2
36. p=unique(nchoosek(repmat('*-+/',1,n),n),'rows')
37. p=[p char(' '*~~p(:,1))]'
38. c=char(x'*~~p(1,:))
39. o=p(:,r==cellfun(@eval,mat2cell(reshape([c(:) p(:)]',k,[]),k,0|p(1,:))))
40. reshape([repmat(x',size(o,2),1) o(:)]',k,[])'
41.
42. 1*2*3+4+5
43. 1+2+3+4+5
44. 1-2*3+4*5
45.
46. n=length(x)-1;
47. p=unique(nchoosek(repmat(['*','-','+','/'],1,n),n),'rows');
48. l=length(p);
49. p=[p repmat(' ',l,1)]';
50. c=reshape([repmat(x',l,1) p(:)]',n*2+2,[]);
51. o = p(:,r == cellfun(@eval, mat2cell(c,n*2+2,ones(l,1))));
52. reshape([repmat(x',size(o,2),1) o(:)]',n*2+2,[])'
53.
54. from itertools import*
55. def f(n,o):print({k for k in[''.join(map(str,sum(j,())))[1:]for j in[zip(x,n)for x in product('+-*/',repeat=len(n))]]if eval(k)==o})
56.
57. def x(i,r):
58.  t=""
59.  from random import choice as c
60.  while True:
61.   for j in i:
62.    t+=str(j)
63.    if c([0,1]):t+="."+c("+-/*")
64.   t=t.strip("+-*/.")+"."
65.   v=eval(t)
66.   if v == r:print t
67.   t=""
68.
69. a=>o=>eval(`while(eval(e=(a+'').replace(/,/g,_=>'+-*/'.charAt(Math.random()*5)))!=o);e`)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top