wolfhammer
  • Member for 8 years, 7 months
  • Last seen more than a month ago
55 answers
326 votes
108k views
Tweetable Mathematical Art
31 votes

JavaScript var can = document.createElement('canvas'); can.width=1024; can.height=1024; can.style.position='fixed'; can.style.left='0px'; can.style.top='0px'; can.onclick=function(){ document.body....

View answer
7 answers
49 votes
4k views
MS Paint is underrated
7 votes

JavaScript Canvas Update Excellent suggestions in the comments. It's now faster and doesn't slow down the ui! function previewFile() { var srcImage = document.getElementById('srcImage'); ...

View answer
28 answers
7 votes
9k views
Generate a 5-pointed star
6 votes

HTML5, 37 bytes <svg><path d="M4,0 7,8 0,3 8,3 1,8"/>

View answer
2 answers
13 votes
1k views
ASCII Art Generation
6 votes

JavaScript 752,701 function Z(I,a,b){ var C=document.createElement('canvas') var W=C.width=I.width,H=C.height=I.height,X=C.getContext('2d') X.drawImage(I,0,0) a*=2,b*=2,W/=a,H/=b ...

View answer
31 answers
25 votes
9k views
Draw the rainbow
4 votes

JavaScript 271 251 c=document.body.appendChild(document.createElement('canvas')) x=c.getContext('2d') c.width=400 r=c.height=200 for(i=0;i<8;x.beginPath(),x.arc(r,r,r-i*10,0,7),x.fillStyle=...

View answer
28 answers
87 votes
28k views
Rearrange pixels in image so it can't be recognized and then get it back
4 votes

JavaScript (+bonus) - pixel divide swap repeater The function takes an image element and Divides the pixels by 8. Does a reversible swap of pixel groups. Recurses swapping if the pixel ...

View answer
15 answers
25 votes
3k views
Create an ASCII-to-hex table for Mark Watney
3 votes

JavaScript ES6 432 405 398 385 o="Dec Hex " o=`${o} ${o} ${o+o+o+o} ${o} ${o}\n` for(i=0;i<16;i++){for(j=0;j<8;j++){k=i+j*16 o+=k>9&&k<16?' ':k<96||k>99?' ':' ' o+=k+" ...

View answer
87 answers
103 votes
21k views
Draw the national flag of France
3 votes

JavaScript 206 175 c=c.getContext('2d') d=c.createImageData(w=78,h=52),a=Int32Array(d.data.buffer) for(i=w*h;i--;)a[i]=-[6007552,1,13286929][i%w/26|0] c.putImageData(d,0,0) <canvas id=c>...

View answer
21 answers
55 votes
5k views
Add a feature to a programming language
3 votes

JavaScript foreach var arr = ["Seattle", "WA", "New York", "NY", "Chicago", "IL"]; function foreach(fn, arr) { var s = fn.toString(); var args = s.substring(s.indexOf('(')+1,s.indexOf(')'))....

View answer
29 answers
28 votes
11k views
Convert short month names to their longer counterparts [Ended]
3 votes

JavaScript - Optimized Node cluster with Branches, Leaves, and string barrels. // fullMon - Converts month key names to full names using a highly optimized tree for fast traversal. function fullMon(...

View answer
5 answers
-1 votes
542 views
Fastest algorithm to output array containing all integers in range excluding duplicate digits
2 votes

JavaScript 0.185 Seconds function fact(x) { x+="" var rL=1,rI=0,i=0 if(x.length <2)return [x] for(i;i<x.length;i++)rL*=(i+1); var r = new Array(rL); function loop(p, s) { ...

View answer
13 answers
-6 votes
2k views
Substitution cipher
2 votes

JavaScript 89 for(i=prompt,x=i(),n='';p=i();n+=p.replace(/./g,m=>x[m.charCodeAt(0)-97])+"\n"); alert(n)

View answer
13 answers
18 votes
2k views
Expand an encoded string
2 votes

JavaScript 112 alert(prompt().replace(/.*?\d+/g,function(m){for(i=n=m.length-1,o="";i--;){j=m[n];while(j--)o=m[i]+o}return o}))

View answer
31 answers
46 votes
11k views
Pixel-art, episode 1: display Super Mario
2 votes

Tcl 298 package require base64 set d [base64::decode AVUABVVUCr7ALv78Lr+/K/6oA//wCmoAKmmoqlWq+ddv/VV/9VVfBUFQKgCoqgCq] binary scan $d B* z set i 0 foreach {a b} [split $z ""] { if {$i % 12 == 0} {...

View answer
59 answers
31 votes
8k views
Convert a string of binary characters to the ASCII equivalents
2 votes

JavaScript 111 This does the number conversion without parseInt or eval. Reading the string backwards and counting bits it set's bit x if it's a one. When a space is found a the number is converted ...

View answer
47 answers
43 votes
7k views
Produce an unexpected word
2 votes

JavaScript function rgbToHex(rgb) { var r = rgb[0].toString(16); var g = rgb[1].toString(16); var b = rgb[2].toString(16); return '#' + r + g + b; } alert(rgbToHex([176,0,11]));

View answer
35 answers
11 votes
3k views
Converting to Secret Language
2 votes

JavaScript // setup alphabet and secret rotated alphabet // var alpha=' abcdefghijklmnopqrstuvwxyz' var rotor=' cdefghijklmnopqrstuvwxyzab' alpha+=alpha.toUpperCase() rotor+=rotor.toUpperCase() ...

View answer
25 answers
18 votes
3k views
Capitalize String
2 votes

Javascript 102 prompt().split(o=q='').map(function(c){o+=(q)?c.toLowerCase():c.toUpperCase(),q=('A'>c)?0:1}) alert(o)

View answer
17 answers
29 votes
4k views
Decipher a Vigenère ciphertext
2 votes

JavaScript 248 var v= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' function d(k,c){var a,b,o,x a=k.charAt(0) x=v.indexOf(a) b=v.substr(x)+v.substring(0,x) o= v.charAt(b.indexOf(c....

View answer
18 answers
6 votes
6k views
Convert JSON string to Key / Value Arrays
2 votes

Tcl 69,69 first attempt 132 keys+vals proc j {x n} { regsub -all {(".*?"):(".*?")} $x "\[lappend o \\$n\]" x subst $x set o $o } proc keys x {j $x 1} proc vals x {j $x 2} second try 69 keys, 69 ...

View answer
64 answers
40 votes
4k views
Fibonacci-orial
1 votes

Tcl, 110 bytes set a 0 set b [incr x] time {set c [expr $a+$b] set a $b set x [expr $x*[set b $c]]} [expr {*}$argv-1] puts $x Try it online! Was able to take off 9 bytes thanks to sergiol!

View answer
27 answers
23 votes
3k views
Code-Golf: Permutations
1 votes

JavaScript 143 136 134 123 function p(s,a="",c="",i,z=[]){a+=c,i=s.length !i?z.push(a):0 for(;i--;s.splice(i,0,c))p(s,a,c=s.splice(i,1),0,z);return z} var perms = p([1,2,3]); document....

View answer
7 answers
8 votes
662 views
Write a compact spelling checker
1 votes

JavaScript 4737 4378 alert(is(prompt("enter word"))) function is(w){if(w=="I")return true;w=w.toLowerCase();var key='/345I_abcdefghijklmnopqrstuvwxyz',x = "...

View answer
47 answers
44 votes
9k views
A single pixel moving in a circular path
1 votes

javascript/html/css 343 202 182 s=document.getElementById('c').style i=0 setInterval(function(){s.left=52+50*Math.cos(i+=.005)+'px' s.top=52+50*Math.sin(i)+'px'},50) b{color:#800080;position:...

View answer
7 answers
36 votes
3k views
Numbers as Circular Graphics
1 votes

JavaScript 342 334 308 function R(n){var v=document,o=[],x=1,c=v.body.appendChild(v.createElement('canvas')).getContext('2d') while(n)v=n%10,y=x+2,o=[[],[x],[x,x],[x,x,x],[x,y],[y],[y,x],[y,x,x],...

View answer
18 answers
27 votes
1k views
Right-align text
1 votes

JavaScript 174 136 function R(s,x){return s.replace(new RegExp(".{"+x+"}","g"),"$&\n").replace(/[^\n]*/g,function(m){ while(m.length<x)m=" "+m;return m;})}

View answer
15 answers
47 votes
6k views
Generate the Stack Overflow logo
1 votes

JavaScript var c=document.getElementById('c'),x=c.getContext('2d'),i=0 c.width=c.height=140 x.scale(5,5) x.fillStyle="#999" x.fillRect(3,26,14,2) x.fillRect(1,18,2,10) x.fillRect(17,18,2,10)...

View answer
39 answers
14 votes
10k views
Hexadecimal Counter
1 votes

JavaScript 74 72 65 60 //for(i=0,a="0123456789ABCDEF";i++<49;)console.log(a[i>>4]+a[i%16]) for(i=0;i++<48;)console.log((i>>4)+"0123456789ABCDEF"[i%16])

View answer
16 answers
20 votes
2k views
Write a program that finds the most occurring paired letter in a string
1 votes

JavaScript 156 153 var x=prompt(),f={},a=0,o x.toUpperCase().replace(/([A-Z])\1+/g,function(m,s){m=f[s]=-~f[s] if(a==m)o.push(s) if(a<m)a=m,o=[s]}) alert(o.sort().join(""))

View answer
45 answers
51 votes
21k views
Outputting ordinal numbers (1st, 2nd, 3rd)
1 votes

Javascript, 75 function s(i){return i+'thstndrd'.substr(~~(i/10%10)-1&&i%10<4?i%10*2:0,2)}

View answer