Lua Code Golf
#101
Posted 15 November 2013 - 11:06 AM
Also, an important change of rules: Challenges may now allow for other languages. Of course, this does not apply to challenges that are ComputerCraft specific or that the author does not allow for.
#102
Posted 15 November 2013 - 02:58 PM
Bubba, on 15 November 2013 - 11:06 AM, said:
Also, an important change of rules: Challenges may now allow for other languages. Of course, this does not apply to challenges that are ComputerCraft specific or that the author does not allow for.
Edit: 206 Chars
t = term function m(a) w,h = t.getSize() s = (k == 200 and s-1 or k == 208 and s+1 or s or 1) % #a t.clear() for i = 1, #a do p = s == i-1 and ">"..a[i] or a[i] t.setCursorPos((w-#p)/2,(h-#a)/2+i) write(p) end _,k = os.pullEvent() return k==28 and s or m(a) end
theoriginalbit, on 15 November 2013 - 08:02 AM, said:
Edited by Symmetryc, 15 November 2013 - 04:05 PM.
#103
Posted 15 November 2013 - 07:23 PM
Edited by jay5476, 16 November 2013 - 01:06 AM.
#104
Posted 22 November 2013 - 05:05 PM
Bubba, on 15 November 2013 - 11:06 AM, said:
Also, an important change of rules: Challenges may now allow for other languages. Of course, this does not apply to challenges that are ComputerCraft specific or that the author does not allow for.
#105
Posted 05 April 2014 - 03:51 AM
KIDDING, lol.
Challenge: Make a pastebin-like program that can download, upload, and run pastes.
MUST be shorter than the default one with no loss in functionality.
#106
Posted 05 April 2014 - 07:05 PM
Code:
Public Class Form1 Private Sub GoButton_Click(sender As Object, e As EventArgs) Handles GoButton.Click WebBrowser1.Navigate(TextBox1.Text) End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click WebBrowser1.GoBack() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click WebBrowser1.GoForward() End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click WebBrowser1.GoHome() End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click WebBrowser1.Refresh() End Sub Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click WebBrowser1.GoSearch() End Sub End ClassWithout whitespace: 738 characters!
Aww.. I just overwrote my challenge..
Lua challenge:
Create a disk formatter!
#108
Posted 05 April 2014 - 07:36 PM
Anavrins, on 05 April 2014 - 07:10 PM, said:
Bubba, on 15 November 2013 - 11:06 AM, said:
Also, an important change of rules: Challenges may now allow for other languages. Of course, this does not apply to challenges that are ComputerCraft specific or that the author does not allow for.
#109
Posted 05 April 2014 - 07:40 PM
#110
Posted 07 April 2014 - 01:31 AM
H = http E = textutils.urlEncode O = fs.open R = shell.resolve x,y,z = ... if x == "put" then print(H.post("http://pastebin.com/api/api_post.php", "api_option=paste&api_dev_key=c09548865c8dd0c2bf57d0d060b5e96a&api_paste_code=" .. E(O(R(y), "r").readAll())).readAll():match("[^/]+$")) else w = H.get("http://pastebin.com/raw.php?i=" .. E(y)).readAll() if x == "run" then loadstring(w)(select(3, ...)) else O(R(z), "w").write(w) end end
392 chars
This duplicates the external interface of the original, without doing any error-checking or printing anything except the paste ID when successfully uploaded.
Oh, and you'll need to reboot to see the contents of any pastes you download. I think it has to do with not closing file handles and garbage collection cycles.
Edited by AgentE382, 07 April 2014 - 01:43 AM.
#111
Posted 07 April 2014 - 02:25 AM
H = http E = textutils.urlEncode O = fs.open R = shell.resolve x,y,z = ... p = "http://pastebin.com/" r = "readAll" if x == "put" then print(H.post(p.."api/api_post.php", "api_option=paste&api_dev_key=c09548865c8dd0c2bf57d0d060b5e96a&api_paste_code=" .. E(O(R(y), "r")[r]()))[r]():match"[^/]+$") else w = H.get(p.."raw.php?i=" .. E(y))[r]() if x == "run" then loadstring(w)(({...})[3]) else O(R(z), "w").write(w) end endCharacters: 373
Edit: Updated code, 389 -> 375
Edit2: 375 -> 373
Edited by Symmetryc, 07 April 2014 - 02:35 AM.
#112
Posted 08 November 2015 - 07:55 PM
Grim Reaper, on 16 August 2013 - 11:27 PM, said:
233 Characters without white space.
EDIT: The path to folder should be the first argument to the program.
s=... t={} function f (s, t) n = fs.getName (s) if fs.isDir (s) then t[n] = {} x = fs.list (s) for i = 1, #x do f (s .. '/' .. x[i], t[n]) end else x = fs.open (s, 'r') t[n] = x.readAll() x.close() end end f (s, t) z = fs.open (s.."_", 'w') z.write (textutils.serialize (t)) z.close()
#113
Posted 08 November 2015 - 08:24 PM
Luca0208, on 08 November 2015 - 07:55 PM, said:
(if your code works; haven't tested your code.)
s=... t={} d=fs function f (s, t) n = d.getName (s) if d.isDir (s) then t[n] = {} x = d.list (s) for i = 1, #x do f (s .. '/' .. x[i], t[n]) end else x = d.open (s, 'r') t[n] = x.readAll() x.close() end end f (s, t) z = d.open (s.."_", 'w') z.write (textutils.serialize (t)) z.close()
- You can save 1 character when using a placeholder for fs
you don't need that functionactually, forget that.
Edited by H4X0RZ, 08 November 2015 - 08:28 PM.
#114
Posted 09 November 2015 - 02:05 PM
s=...part, coz Grim's code is currently the leading I thought it has to work, I will test later.
#115
Posted 04 January 2016 - 06:15 AM
g=string.gsub S=loadstring(g(g(g(g(g(g(g(g(g(g('`R=32`a=2^R`b=a-1`&c(d)`mt={}`e=setmetatable({},mt)&mt:__index(f)`g=d(f)e[f]=g@g$@e$`&h(e,i)`&j(k,l)`m,o=0,1 while k~=0 and l~=0 do`p,q=k%i,l%i m=m+e[p][q]*o k=(k-p)/i l=(l-q)/i o=o*i$m=m+(k+l)*o@m$@j$`&r(e)`s=h(e,2^1)`t=c(&(k)@c(&(l)@s(k,l)$)$)@h(t,2^e.n or 1)$`u=r({[0]={[0]=0,[1]=1},[1]={[0]=1,[1]=0},n=4})`&v(k,l,w,...)`x=nil if l;k=k%a l=l%a x=u(k,l)if w;x=v(x,w,...)$@x elseif k;@k%a else@0$$`&y(k,l,w,...)`x if l;k=k%a l=l%a x=(k+l-u(k,l))/2 if w;x=bit32_band(x,w,...)$@x elseif k;@k%a else@b$$`&z(A)@(-1-A)%a$`&a9(k,C)if C<0;@Y(k,-C)$@math.floor(k%2^R/2^C)$`&D(A,C)if C>31 or C<-31;@0$@a9(A%a,C)$`&Y(k,C)if C<0;@D(k,-C)$@k*2^C%2^R$`&E(A,C)A=A%a C=C%R`a5=y(A,2^C-1)@D(A,C)+Y(a5,R-C)$`f={0x428a2f98?71374491?b5c0fbcf?e9b5dba5?3956c25b?59f111f1?923f82a4?ab1c5ed5?d807aa98?12835b01?243185be?550c7dc3?72be5d74?80deb1fe?9bdc06a7?c19bf174?e49b69c1?efbe4786?0fc19dc6?240ca1cc?2de92c6f?4a7484aa?5cb0a9dc?76f988da?983e5152?a831c66d?b00327c8?bf597fc7?c6e00bf3?d5a79147?06ca6351?14292967?27b70a85?2e1b2138?4d2c6dfc?53380d13?650a7354?766a0abb?81c2c92e?92722c85?a2bfe8a1?a81a664b?c24b8b70?c76c51a3?d192e819?d6990624?f40e3585?106aa070?19a4c116?1e376c08?2748774c?34b0bcb5?391c0cb3?4ed8aa4a?5b9cca4f?682e6ff3?748f82ee?78a5636f?84c87814?8cc70208?90befffa?a4506ceb?bef9a3f7?c67178f2}`&G(H)@Fgsub(H,".",&(w)@Fformat("%02x",Fbyte(w))$)$`&I(J,n)`H=""for K=1,n do`L=J%256 H=Fchar(L)..H J=(J-L)/256$@H$`&M(H,K)`n=0 for K=K,K+3 do n=n*256+Fbyte(H,K)$@n$`&N(O,P)`a6=64-(P+9)%64 P=I(8*P,8)O=O.."\128"..Frep("\0",a6)..P assert(#O%64==0)@O$`&a7(S)S[1B6a09e667 S[2Bbb67ae85 S[3B3c6ef372 S[4Ba54ff53a S[5B510e527f S[6B9b05688c S[7B1f83d9ab S[8B5be0cd19@S$`&T(O,K,S)`U={}for V=1,16 do U[V]=M(O,K+(V-1)*4)$for V=17,64 do`g=U[V-15]`W=v(E(g,7),E(g,18),D(g,3))g=U[V-2]U[V]=U[V-16]+W+U[V-7]+v(E(g,17),E(g,19),D(g,10))$`k,l,w,X,Y,d,Z,_=S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[8]for K=1,64 do`W=v(E(k,2),E(k,13),E(k,22))`a0=v(y(k,l),y(k,w),y(l,w))`a1=W+a0`a2=v(E(Y,6),E(Y,11),E(Y,25))`a3=v(y(Y,d),y(z(Y),Z))`a4=_+a2+a3+f[K]+U[K]_,Z,d,Y,X,w,l,k=Z,d,Y,X+a4,w,l,k,a4+a1$S[1Q1]+k)S[2Q2]+l)S[3Q3]+w)S[4Q4]+X)S[5Q5]+Y)S[6Q6]+d)S[7Q7]+Z)S[8Q8]+_)$`&S(O)O=N(O,#O)`S=a7({})for K=1,#O,64 do T(O,K,S)$@G(I(S[1|2|3|4|5|6|7|8],4))$@S',"`"," local "),"%$"," end "),"&","function "),"@"," return "),";"," then "),"?",",0x"),"|","],4)..I(S["),"F","string."),"Q","]=y(S["),"B","]=0x"))()I've been trying to get it as small as possible to put a checksum on a self-extracting archive. I bet someone here can do better
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users