What time is it? (Obfuscation)

1

Your goal is to write an obfuscated program that displays the current time.

Guidelines: The program can print local or global time. You are allowed to draw ASCII numbers, display an analog clock, etc. No input should be needed. Whether you include 12 or 24 hour, including AM/PM, milliseconds and seconds or not, it all doesn't matter. This is a popularity contest.

Inspired by sykes2.c, an impressive display of confusing naming, obscure language features, and clever tricks.

qwr

Posted 2014-05-02T21:41:01.217

Reputation: 8 929

Question was closed 2014-05-13T18:40:44.523

Why does the search feature on "Mark as duplicate" never work? – TheDoctor – 2014-05-02T21:48:39.977

@TheDoctor Find me a duplicate, and I will delete or modify. – qwr – 2014-05-02T21:50:01.590

It is just not a very interesting challenge. No restrictions on using built-in time functions. – TheDoctor – 2014-05-02T21:57:19.253

@TheDoctor That's subjective, and I think you missed the point of obfuscation. The purpose is to be creative in the display, not the method of getting the time. – qwr – 2014-05-02T22:00:46.663

1I would retract my downvote if that were stated clearly in the question; i misunderstood. – TheDoctor – 2014-05-02T22:02:59.760

Why the downvote again? When you downvote please tell us why – DankMemes – 2014-05-03T02:06:22.233

3This question appears to be off-topic because it doesn't have an objective spec. One person's "obfuscated" is another person's "I just prefer this style". – Peter Taylor – 2014-05-06T22:14:28.217

Answers

5

Analog clock, JS

Analog clock? Challenge accepted.

Golfed/Obfuscated into the zone of not-exactly-understanding-what-it-does-even-after-reading-through-a-few-times:

for(var a=new Date,b=a.getMinutes(),c=a.getHours()+b/60,d=[],e=Math.round,f=Math.PI,g=Math.sin,h=Math.cos,k=0;11>k;k++)d[k]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(var l=0;l<f;l+=0.05){var m=e(17/11*5*h(2*l)),n=e(5*g(2*l));d[n+5][m+8]=1}for(var p=0;2.5>=p;p+=0.5){var q=e(17/11*p*h(-(c*f/6)+f/2)),r=e(p*g(-(c*f/6)+f/2));d[r+5][q+8]=2}for(p=0;4.5>=p;p+=0.5){var s=e(17/11*p*h(-(b*f/30)+f/2)),t=e(p*g(-(b*f/30)+f/2));d[t+5][s+8]=3}d[5][8]=1;a="";for(k=d.length-1;-1<k;k--)a+=d[k].join("").replace(/0/g,".").replace(/1/g,"O").replace(/2/g,"h").replace(/3/g,"m")+"\n";console.log(a);

Outputs something like:

.....OOOOOOO......
...OO.......OO....
.OO...........O...
.O...h.........O..
O.....hh.......OO.
O......hOmmmmmmmO.
OO.............OO.
.O.............O..
.OO...........O...
...OO.......OO....
.....OOOOOOO......

...yeah, guess what time it is here. (Hint hint not AM)

Human readable version:

var date = new Date();
var min = date.getMinutes();
var hrs = date.getHours()+(b/60); // set up date
var a=[];
for(var i=0;i<11;i++)a[i]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; // set up array
function putX(x,y,i){a[y+5][x+8]=i;} // just for source neatness; this is expanded out in the obfuscated version
for(var p=0;p<Math.PI;p+=0.05){ // draw clock border
    putX(Math.round((17/11)*5*Math.cos(2*p)), Math.round(5*Math.sin(2*p)), 1);
}
for(var p=0;p<=2.5;p+=0.5){ // draw hour hand (transforming the angle to work)
    putX(Math.round((17/11)*p*Math.cos(-(hrs*2*Math.PI/12)+(Math.PI/2))), Math.round(p*Math.sin(-(hrs*2*Math.PI/12)+(Math.PI/2))), 2);
}

for(var p=0;p<=4.5;p+=0.5){ // draw the minute hand like the hour hand
    putX(Math.round((17/11)*p*Math.cos(-(min*2*Math.PI/60)+(Math.PI/2))), Math.round(p*Math.sin(-(min*2*Math.PI/60)+(Math.PI/2))), 3);
}

putX(0,0,1); // set the center point

date=""; // reuse date for maximum confusion :)
for(var i=a.length-1;i>-1;i--)date+=a[i].join("").replace(/0/g, ".").replace(/1/g, "O").replace(/2/g, "h").replace(/3/g, "m")+"\n"; // output ASCII art to string
console.log(date); // output string to console

DankMemes

Posted 2014-05-02T21:41:01.217

Reputation: 2 769

Whoa, I just realized the hour hand doesn't actually move during the hour. Fixing... – DankMemes – 2014-05-03T02:12:24.373

It's fixed. Hopefully there aren't any more bugs – DankMemes – 2014-05-03T02:19:10.163

3

Python

Might as well.

exec(lambda s:s[::2]+s[1::2])('ipmepno r(t" hwtetbpb:r/o/wtsiemre;.wgeobvb/rHoTwMsLe5r/."o)')

KSab

Posted 2014-05-02T21:41:01.217

Reputation: 5 984

1

JavaScript / HTML (757 bytes)

Prints an analog clock on an HTML5 canvas. There's probably a lot more efficient ways to do this, but I think it turned out looking nice.

<canvas><script>S=150;c=document.currentScript.parentNode;c.width=c.height=2*S;t=c.getContext("2d");z=Math;r=2*z.PI;o=r/4;h=[[1,0.93],[4,0.9],[8,0.7]];m=[0,0,0];function d(){t.clearRect(0,0,c.width,c.height);t.lineWidth=2;t.beginPath();t.moveTo(2*S,S);    t.arc(S,S,0.99*S,0,r);for (i=0;i<60;++i){a=r*(i/60)+o;x=0.99*S*z.cos(a);    y=0.99*S*z.sin(a);t.moveTo(S+x,S+y);s=0.96;if (!(i%5)) s=0.90;t.lineTo(S+s*x,S+s*y);}t.stroke();u=new Date();m[0]=r*u.getSeconds()/60-o;m[1]=r*u.getMinutes()/60-o;m[2]=r*(u.getHours()%12)/12+(m[1]+o)/12-o;for(g=0;g<3;g++){t.beginPath();t.lineWidth=h[g][0];t.strokeStyle="black";if (!g) t.strokeStyle="red";x=h[g][1]*S*z.cos(m[g]);  y=h[g][1]*S*z.sin(m[g]);t.moveTo(S+x,S+y);t.lineTo(S,S);t.stroke();}setTimeout(d,500);}d();</script>

Human readable version on JSFiddle here.

MasterShizzle

Posted 2014-05-02T21:41:01.217

Reputation: 11

0

GolfScript

The ultimate example of a magic number!

230140410535893441750932406053255553

23/`3/{~}%+'"#{'\+'}"'+~

Explanation coming soon.

Doorknob

Posted 2014-05-02T21:41:01.217

Reputation: 68 138

0

CJam

"et phone home"S/_,_@T=~><{_A<{R_,+\+}*':}/;

Prints the local time as HH:mm:ss (24-hour)

Spoilers:

S/ splits by space (S=" ")
_,_ gets the resulting array length (3) twice
@T= extracts the "et" part (T=0)
~ evaluates et, which gives the current date and time in an array
>< extracts the time part (starting at index 3, length 3)
_A< checks if a value is less than 10 (A=10)
R_,+ evaluates to "0" (R="")
\+ prepends "0" to the number
{...}* executes the block if the condition (<10) was true
': is the colon character
{...}/ executes the block for each array element (hour, min, sec)
; pops the last value (a colon)

aditsu quit because SE is EVIL

Posted 2014-05-02T21:41:01.217

Reputation: 22 326

0

SVG + JavaScript (272 937 bytes)

I'm sorry; couldn't help myself. The SVG is probably way too big to fit on StackExchange, so you can access a live demo here (please note, it could lag your browser; do it at your own risk): http://varden.info/~mlindvall/jstime.obf.svg

Viewing the source code might crash your browser; do it at your own risk. Otherwise, downloading it and opening it in Notepad++ should be safe.

Since there are no rules, I'll have to admit I got huge help from an obfuscator, so this is more like a proof of concept rather than a real submission. Still, it was kind of fun to see this work.

Human readable version:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="44" width="110" version="1.1" xmlns="http://www.w3.org/2000/svg">
<text x="10" y="14" style="font-size: 14px;">Current time is:</text>
<text id="id" x="0" y="44" style="font-size: 30px;"></text>
<script type="text/javascript">
function t() {
    var a = new Date(), timeArray=[a.getHours(), a.getMinutes(), a.getSeconds()], delimiter='', result='';
    for (c = 0; c != 3; c++) {
        while (('' + timeArray[c]).length != 2) {
            timeArray[c] = '0' + timeArray[c];
        }
        result += delimiter + b[c];
        delimiter = ':';
    }
    document.getElementById("id").textContent = result;
}
t();
setInterval("t()", 1000); // Run every second for an updating clock
</script>
</svg>

bilde2910

Posted 2014-05-02T21:41:01.217

Reputation: 156