Happy Birthday, Finland!

37

5

Introduction

As is known, in 2017, Finland celebrates its 100 years of independence. To mark the occasion, it is your job to produce a Finnish flag for everyone's enjoyment.

Challenge

Create a program or a function that produces the flag of Finland (the grey border is there for presentation purposes only):

Flag of Finland

Flag specifications

  • The ratio of the flag is 18:11, with the cross being 3 units thick, giving a horizontal ratio set of 5:3:10 and a vertical ratio set of 4:3:4.
  • The picture must be at least 180 x 110 pixels in size, or in case of ASCII art, 90 x 55 characters.
  • There is no official RGB colour for the blue, but use the closest approximation of (0, 53, 128). If your system doesn't support RGB values, use blue.
  • For the white colour, use RGB (255, 255, 255) or white.

Not so fast

As drawing the Finnish national flag would be simpler than last year's Icelandic challenge, we'll have to ramp up the difficulty a bit. Given that Finland's Independence Day is on 6 December, the decimal number 100 must appear somewhere on the flag when the date in Finland (UTC+02:00) is 2017-12-06 or later (your code should not assume that the machine it's running on is set to a particular timezone). Before the date, the number must not be there. The number must be printed in black (RGB (0, 0, 0) or black) but its placement and font parameters are up to you.

An example of such a render (again, ignore the border):

Flag of Finland with 100 on it

For testing purposes, it would be nice to include two additional versions of your solution, one with a fixed date in the past and one in the future.

Rules

Standard loopholes are forbidden, as are built-in flag images/libraries. Also, your code must not take any input.

Finns don't like small talk, and this is , so don't waste characters!

Antti29

Posted 2017-12-04T07:29:39.803

Reputation: 939

Should we just use space and # in case of ASCII art? And then insert the characters 100 somewhere? – Adám – 2017-12-04T09:26:17.430

1Can we take the date in Finland as input for systems lacking an internal wall clock or not implementing the timezone? I'm occasionally posting answers in GFA-Basic (Atari ST, no timezone) or CP-1610 assembly (Intellivision, no date/time at all) and we have answers on some other old-school platforms from time to time which are usually pretty good at drawing things like that but seem to be disqualified here because of the date issue. – Arnauld – 2017-12-04T16:01:26.447

1@Arnauld: Gosh, I never thought anyone would use such systems. I appreciate your predicament but would that leave others at a disadvantage? I think allowing the input would leave you with just a simple integer comparison. Would a non-competing entry without the time aspect be out of the question? – Antti29 – 2017-12-04T16:39:49.387

1@Antti29 Honestly, I can't think of any good solution and it's too late to do any major update to the rules. Unless someone comes with a really satisfying suggestion, I think these systems simply cannot compete here. (I saw the challenge in the sandbox and didn't think about that. My bad.) – Arnauld – 2017-12-04T16:49:55.167

9

Is the other Finnish flag allowed?

– Justin – 2017-12-04T23:58:35.830

Funny that this disqualifies PostScript... there are no dates in PostScript, so it's impossible to what you ask. – wvxvw – 2017-12-05T12:07:39.530

@Arnauld (cc Antti29) a compromise for languages without a built-in clock would be to give the program a time and a corresponding time zone as input. That would put those languages exactly where others are, i.e. they can get the current time, but they don't know what time zone it's in and need to convert it appropriately. – Martin Ender – 2018-02-20T14:27:47.593

Answers

24

C (Windows), 361 bytes

#import<time.h>
#import<windows.h>
C(x){SetConsoleTextAttribute(GetStdHandle(-11),x);}F(I,N,l,a,n,d)time_t n;struct tm*d;{system("mode 90,65");time(&n);d=gmtime(&n);n=d->tm_year<<24|d->tm_mon<<16|d->tm_mday<<8|d->tm_hour;for(a=l=I=15;I++<70;a=l=I<35|I>49?15:9)for(N=n>1963656468&I<17?C(240),printf("100"):0;N++<90;a=N-25?a:9,a=N-40||l==9?a:15)C(a),putchar(70);}

Unrolled:

#import <time.h>
#import <windows.h>

C(x)
{
    SetConsoleTextAttribute(GetStdHandle(-11),x);
}

F(I,N,l,a,n,d) time_t n;struct tm*d;
{
    system("mode 90,65");

    time(&n);
    d = gmtime(&n);
    n = d->tm_year<<24 | d->tm_mon<<16 | d->tm_mday<<8 | d->tm_hour;

    for(a=l=I=15; I++<70; a=l=I<35|I>49?15:9)
        for(N=n>1963656468&I<17?C(240),printf("100"):0; N++<90; a=N-25?a:9,a=N-40||l==9?a:15)
            C(a), putchar(70);
}

Output:

Output when UTC time >= 2017-12-05-22-00:

Add the following in the code after d=gmtime(&n); to try it:

d->tm_year = 117;
d->tm_mon = 11;
d->tm_mday = 5;
d->tm_hour = 21;

Steadybox

Posted 2017-12-04T07:29:39.803

Reputation: 15 798

13Cute variable names! – Adám – 2017-12-04T18:00:09.677

16

PHP + SVG(HTML5), 147 137 123 bytes

SVG code by Neil

https://codegolf.stackexchange.com/a/149850/66061

<svg><path d=180v110 fill=#fff></path><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0 fill=#005580></path><?=time()<1512511200?:'<text x=9 y=15>100';

Update: Thanks to Shaggy for helping me save 10 bytes.

<svg><path d=180v110 fill=#fff /><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0 fill=#005580 /><?=time()<1512511200?:'<text x=9 y=15>100';

Update 2: Smart idea by Ismael Miguel, thanks for saving 14 bytes

<svg><path d=180v110 /><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0 fill=#005580 /><?=time()<1512511200?:'<text y=19>100';

Normal

normal

After 6th Dec +2 hours

after 6th Dec - +2 hours

th3pirat3

Posted 2017-12-04T07:29:39.803

Reputation: 271

So time() gives UTC? – Adám – 2017-12-04T11:20:15.567

When is 1512525600? – Adám – 2017-12-04T11:30:43.643

1512525600 is 2017-12-06T02:00:00+00:00 in ISO 8601 @Adám

and yes, time() is timezone independent. – th3pirat3 – 2017-12-04T11:39:05.607

12

Röda, 252 250 bytes

{s={|w,h|[` width="$w" height="$h" `]}r=`><rect`f=`" fill="#003580"/`
[`<svg`,s(18,11),r,s(18,11),`fill="#fff"/`,r,s(18,3),`y="4$f`,r,s(3,11),`x="5$f>`]
[`<text y="9" font-size="2">100</text>`]if{}|[[exec("date","+%s")]&"">="1512511200
"]
[`</svg>`]}

Try it online!

fergusq

Posted 2017-12-04T07:29:39.803

Reputation: 4 867

25The audacity! You have solved a Finnish challenge with a Swedish-named language. – Antti29 – 2017-12-04T09:08:36.347

@Antti29 I don't know much about the language, but the git site seems to be pretty Finnish. Maybe it's a Finnish-named language after all (and it's just a coincidence that it coincides with the Swedish name for "red"). – Arthur – 2017-12-04T09:54:05.113

1@Arthur It's named after the Swedish word, there is no such word in Finnish. The git contains Finnish because I'm Finnish-speaking. – fergusq – 2017-12-04T10:04:05.430

1@Arthur: I'm afraid you'll need to delve into the Finnish mindset to fully appreciate my comment :) – Antti29 – 2017-12-04T10:07:49.923

1@fergusq Well, if it is from the man who actually named the language, then I guess there is no higher authority. However, even with the knowledge that "röda" isn't a Finnish word, I maintain that my previous comment was plausible. Language names don't have to be actual words. Also, while I may not be on the inside of it, I am well aware of the antagonism that Finns have against Swedes, with the occupation history, and Swedish being mandatory in schools as one of several constant reminders. – Arthur – 2017-12-04T10:09:59.410

@fergusq Why didn't you call it "Punainen" or something? – Adám – 2017-12-04T10:26:13.410

@fergusq How does this handle the time zone offset when run somewhere else than in UTC+2? – Adám – 2017-12-04T10:34:15.720

@fergusq It looks to me like this only inserts the "100" if it is Finland's centennial, and not thereafter. Maybe = should be >=? – Adám – 2017-12-04T11:33:50.007

@Adám Should be now fixed. About naming: "Röda" is shorter and sounds more cool. – fergusq – 2017-12-04T12:53:46.957

@Antti29 Isn't Swedish also an official language in Finnland? – Paŭlo Ebermann – 2017-12-05T21:53:07.383

1@PaŭloEbermann: Unfortunately. – Antti29 – 2017-12-05T21:58:55.193

1@PaŭloEbermann Some people in Finland do indeed antagonize the Swedish language, which in my opinion is pointless. It's a kind of meme to oppose Swedish and in reality most of us are very proud of the rich culture we have, including our national languages. – fergusq – 2017-12-05T22:21:34.227

11

C#, 407 400 277 bytes

Weird how ForegroundColor =0 is allowed

Saved 1 byte thanks to TuukkaX

Saved 67 bytes thanks to Adam

()=>{for(int x=0,y;x<90;x++)for(y=0;y<55;y++){BackgroundColor=(ConsoleColor)15;if(x>24&x<41|(y>19&&y<36))BackgroundColor=(ConsoleColor)9;SetCursorPosition(x,y);Write(' ');}if(new DateTime(2017,12,5,22,0,0)<DateTime.UtcNow){SetCursorPosition(1,1);ForegroundColor=0;Write(100);}}

ungolfed for testing:

using System;
using static System.Console;
class P
{
    static void Main()
    {
        Action func = () =>
        {
            for (int x = 0,y; x < 90; x++) for (y=0; y < 55; y++)
                {
                    BackgroundColor = (ConsoleColor)15;
                    if (x > 24 & x < 41 | (y > 19 && y < 36))
                        BackgroundColor = (ConsoleColor)9;
                    SetCursorPosition(x, y);
                    Write(' ');
                }

            if (new DateTime(2017, 12, 5, 22, 0, 0) < DateTime.UtcNow)
            {
                SetCursorPosition(1, 1); ForegroundColor =0; Write(100);
            }
        };
        func();
        ReadLine();
    }
}

for testing 100:

using System;
using static System.Console;
class P
{
    static void Main()
    {
        Action func = () =>
        {
            for (int x = 0,y; x < 90; x++) for (y=0; y < 55; y++)
                {
                    BackgroundColor = (ConsoleColor)15;
                    if (x > 24 & x < 41 | (y > 19 && y < 36))
                        BackgroundColor = (ConsoleColor)9;
                    SetCursorPosition(x, y);
                    Write(' ');
                }

            if (new DateTime(2017, 12, 2, 22, 0, 0) < DateTime.UtcNow)
            {
                SetCursorPosition(1, 1); ForegroundColor =0; Write(100);
            }
        };
        func();
        ReadLine();
    }
}

LiefdeWen

Posted 2017-12-04T07:29:39.803

Reputation: 3 381

3ForegroundColor = 0 is allowed because the literal 0 is convertible into any enum type, as written in the C# specification. – Joey – 2017-12-06T16:13:00.777

9

Python 2, 247 246 230 210 189 bytes

import time
print'P3',180,110,255
w,b='255 '*3,'0 52 128 ';B=['0 '*3,w][time.gmtime()<(2017,12,5,22)]
a=w*40+b*30+w*100
x=w*10+a;y,z=w+B+w+B*3+w+B*3+a,(w+B)*5+a
print y+z+y+x*37+b*5400+x*40

Try it online!

Prints a .ppm image:

Normal flag

Finland

Flag with 100

Finland100

TFeld

Posted 2017-12-04T07:29:39.803

Reputation: 19 246

Can datetime.utcnow()+timedelta(hours=2)<datetime(2017,12,06) be replaced with datetime.utcnow()>=datetime(2017,12,05,22,0,0) or something similar? – Adám – 2017-12-04T11:30:12.193

Use time.gmtime instead for tuple comparisons (see my answer)! – Antti Haapala – 2017-12-04T20:21:05.257

[time.time()>1512514800] – dieter – 2017-12-08T16:02:46.150

9

Mathematica, 129 bytes

If[AbsoluteTime@Date[]<3721507200,s="",s=100];Graphics@{s~Text~{9,9},RGBColor[0,.2,.5],{0,4}~(R=Rectangle)~{18,7},{5,0}~R~{8,11}}


before..
enter image description here
after..

enter image description here
you can always test it on Wolfram Sandbox
(paste the code and hit Shift-Enter)

J42161217

Posted 2017-12-04T07:29:39.803

Reputation: 15 931

When is 3721507200? – Adám – 2017-12-04T11:31:20.937

@Adám AbsolutimeTime gives the total number of seconds since the beginning of January 1, 1900 – J42161217 – 2017-12-04T11:33:48.723

@Jenny_mathy January 1, 1900 of what timezone? – Daffy – 2017-12-07T05:09:43.853

@Daffy of utc +02:00 – J42161217 – 2017-12-07T09:34:28.430

7

Processing.org / Java 191 188 bytes

-3 bytes thanks to KevinCruijssen

import java.util.*;void setup(){size(180,110);background(-1);fill(0);if(new Date().getTime()>=15125256e6D)text("100",0,9);noStroke();scale(10);fill(#003580);rect(5,0,3,11);rect(0,4,18,3);}

Before After

PrincePolka

Posted 2017-12-04T07:29:39.803

Reputation: 653

>15125255999999L can be >=15125256e6 – Kevin Cruijssen – 2017-12-07T14:51:42.847

@KevinCruijssen perhaps it can be shortended but 15125256e6 is 15125255815168, which is 37 hours too late – PrincePolka – 2017-12-07T15:06:44.533

15125256e6D works, thanks – PrincePolka – 2017-12-07T15:10:07.670

Hmm, 15125256e6 is 15125256000000 when I test it in Java 8. But I don't know Processing.org, so perhaps it's slightly different or using a different version? Here is a TIO with some basic tests of 15125256e6 to verify it works in Java 8. But I'm glad the D after it fixes it. Glad I could help. :)

– Kevin Cruijssen – 2017-12-07T15:22:14.800

7

Excel VBA, 120 118 117 Bytes

Anonymous VBE immediate window function that takes no input and outputs the the Finnish flag and if Finland is greater than 100 years old a 100 on that flag. This is done with respect to the Easter Timezone of the United States, as there is no way for Excel or Excel VBA to determine timezone without add-ins or accessing the internet.

Cells.RowHeight=48:Cells.Interior.Color=-1:[F1:H11,A5:R7].Interior.Color=8402176:If Now>=#12/5/17 19:0#Then[B2]=100

Output

If Finland is younger than 100 years old

Young Finnish

If Finland is older than 100 years old

Old Finnish

-2 Byte for changing If #12/5/17 19:00#<=Now Then[B2]=100 to If Now>=#12/5/17 19:0#Then[B2]=100

-1 Byte for use of Cells rather than [A1:R11]

Taylor Scott

Posted 2017-12-04T07:29:39.803

Reputation: 6 709

2Who'd have thought ol' VBA could do this. Excellent. – Floris – 2017-12-05T03:11:28.177

3

@Floris, I've come to realize that when it comes to pixel art, Excel VBA can do some amazing things. :D

– Taylor Scott – 2017-12-05T03:43:39.920

I am reminded of writing something in the precursor to VBA (a crazy macro language that was written in the cells of the Excel sheet, one line per cell) that did something similar (create a 2D intensity graph of a function I was studying). That must have been 1991. Thanks for the memories. – Floris – 2017-12-05T04:05:07.507

@Floris - you mean Excel 4.0 Macros? Man I have been trying to learn how to write those for a while, but all of the guides for it seem to have dropped off the face of the earth :/ – Taylor Scott – 2017-12-05T04:27:10.210

Yes that's exactly what they were... I am pretty sure I have thrown my guides away, sorry to say. – Floris – 2017-12-05T04:30:22.413

1@Floris well that's a shame - but its good to know that someone else knows what they are :) – Taylor Scott – 2017-12-05T04:31:11.377

1And come to think of it - there was something before 4.0... I remember being annoyed when everything broke. As I have been many times since. Masters of not-backwards-compatible. – Floris – 2017-12-05T04:32:02.377

Yes, yes they were - heaven forbid you should want to move from the 32 Bit version to the 64 Bit version – Taylor Scott – 2017-12-05T04:38:00.307

7

Python 3, 143 141 135 bytes

Uses ANSI escape for colors, uses five spaces or " 100 " as a colored string so that I don't need to specially print "100" somewhere on the flag. Length 5 because of width, because 90/5 == 90//5. The string being used is getting defined in row 1. Then we iterate 55 round (height), on every iteration v is set to string with color [Blue, BrightWhite] and selected index is boolean row<20 or r>34. We multiply that result by 5 again (width dimensions: 25:15:50 so total width is 90). Then we print out v + Blue + Blue + Blue + v + v + Black where v is either Blue or BrightWhite. To clarify printing: width of v is 25 chars, width of Blue (e%44*3) is 15 and width of v*2 is 50. 25+15+50 is 90 which is the width and follows the dimensions required in the task! Quite messy summary but I guess it's better than nothing.

import time;e="\033[30;%dm "+[" "*4,"100 "][time.time()>1512511200]
for r in range(55):v=e%[107,44][19<r<35]*5;print(v+e%44*3+v*2+e%40)

FatalError

Posted 2017-12-04T07:29:39.803

Reputation: 119

2Welcome to the site! – caird coinheringaahing – 2017-12-06T20:43:52.530

2Welcome to PPCG! I've added a language flag to your answer, and I would suggest that you add a basic description of how your program works - but otherwise, great first answer :) – Taylor Scott – 2017-12-06T20:48:20.540

2@TaylorScott Will do! And thank you, I have been lurking here for like year or two but never submitted anything before. Just couldn't resist because of Finland turns 100 years! – FatalError – 2017-12-06T20:59:50.033

5

MATLAB, 133 130 123 bytes

3 10 bytes sabed thanks for @flawr!

r=1:180;r(51:80)=0;imshow(r(11:120)'*r,[0 .2 .5;1 1 1])
if datenum(datetime('now','T','UTC+2'))>=737035 text(9,9,'100'),end

This uses [0, 51, 128] for the blue color. The size of the image is 180×110 pixels.

Sample run:

enter image description here

Sample run with the text (changing 737035 to 0 in the code so that the text is shown on any day):

enter image description here

Luis Mendo

Posted 2017-12-04T07:29:39.803

Reputation: 87 464

4

JavaScript (ES5) + SVG(HTML5), 189 179 bytes

document.write('<svg><path d=M0,0h180v110H0z fill=#fff /><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0Z fill=#005580 />'+(Date.now()<15125112e5?'':'<text x=0 y=30 fill=#000>100'))
<body color=grey bgcolor=silver>

(HTML to show that the colour requirements are being met.) Edit: Saved 10 bytes thanks to @Shaggy. Outputs:

<body color=grey bgcolor=silver>

<svg><path d=M0,0h180v110H0z fill=#fff /><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0Z fill=#005580 />

<body color=grey bgcolor=silver>

<svg><path d=M0,0h180v110H0z fill=#fff /><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0Z fill=#005580 /><text x=0 y=30 fill=#000>100

Neil

Posted 2017-12-04T07:29:39.803

Reputation: 95 035

How does this handle the time zone offset when run somewhere else than in UTC+2? – Adám – 2017-12-04T10:33:05.133

@Adám Date.now() is in UTC, and I compare against the UTC value of 2017/12/06 00:00:00 UTC+2. – Neil – 2017-12-04T10:36:38.240

Is it okay to use your SVG code in my php snippet? – th3pirat3 – 2017-12-04T10:49:09.810

@th3pirat3 Sure, as long as you attribute it. – Neil – 2017-12-04T10:54:42.543

When is 15125112e5? – Adám – 2017-12-04T11:34:58.630

2@Adám I already told you? – Neil – 2017-12-04T12:18:10.280

Sorry, I misunderstood. – Adám – 2017-12-04T12:19:16.643

1Replace <path></path> with <path/> to save a few bytes. – Shaggy – 2017-12-04T13:11:41.723

4

Python 3 with Pillow, 213 212 211 characters (Unix) and 217 216 characters (Portable)

This is the Unix version. I realized after posting that the time returned by time() does not necessarily have its epoch on 1 Jan 1970, so it is not necessarily portable.

b=8402688;from PIL import Image,ImageDraw as d
j=Image.new('RGB',(180,110),~1);r=d.Draw(j);R=r.rectangle
R([50,0,79,109],b);R([0,40,180,69],b);import time
r.text((9,9),'100'*(time.time()>=0x5a273300),0)
j.show()

This is the portable code, 4 bytes more, it uses gmtime with tuple comparison so it should work reliably on Windows too.

import time
from PIL import Image,ImageDraw as d
b=8402688
j=Image.new('RGB',(180,110),~1)
r=d.Draw(j)
R=r.rectangle
R([50,0,79,109],b)
R([0,40,180,69],b)
r.text((9,9),'100'*(time.gmtime()>(2017,12,5,22)),0)
j.show()

The images are displayed in a window. Really difficult to make it consume less characters. Even time.time returns a float so >0x5a273299 would not be quite so correct, or >0x5a273300 would be off by a microsecond.

enter image description here

enter image description here

Antti Haapala

Posted 2017-12-04T07:29:39.803

Reputation: 341

4

Java 342 368 361 321 317 (299+18) bytes

Golfed

import java.awt.*;()->new Frame(){{setBackground(Color.WHITE);setUndecorated(0<1);setSize(180,110);setVisible(0<1);}public void paint(Graphics g){g.setColor(new Color(0,53,128));g.fillRect(50,0,30,110);g.fillRect(0,40,180,30);g.setColor(Color.BLACK);if(System.currentTimeMillis()>15125112e5)g.drawString("100",9,9);}}

Ungolfed

import java.awt.*;
() -> new Frame() {
    {
        setBackground(Color.WHITE);                     //Color Objects ARE just RGB values
        setUndecorated(0 < 1);                          //Get's ride of title bar
        setSize(180, 110);             
        setVisible(0 < 1);
    }
    public void paint(Graphics g) {
        g.setColor(new Color(0, 53, 128));              //The special blue color
        g.fillRect(50, 0, 30, 110);
        g.fillRect(0, 40, 180, 30);
        g.setColor(Color.BLACK);
        if (System.currentTimeMillis() > 15125112e5)    //Time Condition
            g.drawString("100", 9, 9);
    }

Result

Finland

Credits

40 bytes saved by Olivier Grégoire for using lambda.
4 bytes saved by Kevin Cruijssen for Long formatting.
2 bytes saved by user902383 for hex formatting.

jfh

Posted 2017-12-04T07:29:39.803

Reputation: 61

Does Java not support RGB colour values? – Antti29 – 2017-12-04T17:46:23.450

Thanks, thats 1 byte saved. java does but the syntax is new Color(XXX,XXX,XXX) which is very verbose. Even the instantiation of 1 color object wouldn't be worth it due to the lengthy get method due to the omission of a good set method. – jfh – 2017-12-04T18:00:05.577

1@jfhcs: Well, unfortunately, those were the rules. And... that's Java. – Antti29 – 2017-12-04T18:02:01.417

1Ah I see. I will update my answer. I must have misinterpreted the rules. – jfh – 2017-12-04T18:02:56.253

1You can replace the trues with 1>0, args with a, and can remove the spaces around = at P j = new... to save a few bytes. – Justin Mariner – 2017-12-04T19:05:54.653

Good thinking. I kind of hurriedly wrote this answer because I had some Differential Equation homework due in an hour. Also it's my second answer and I appreciate the positive feedback guys. – jfh – 2017-12-04T19:19:24.220

1342 bytes (324 bytes + 18 bytes for import java.awt.*;), with the condition included. – Olivier Grégoire – 2017-12-05T11:44:04.937

1Your current response has several flaws that make it invalid: 1. there is no import at all. 2. the variable names aren't shortened: args can be reduced to a. 3. there are still optional spaces that are contained in the entry. 4. there is no conditional print of "100". – Olivier Grégoire – 2017-12-05T11:51:04.337

That would be the solution I was looking for. Since I have no child class, setBackground(Color.WHITE) now would work. Although Color.BLACK has an rgb value of -1, it actually is longer to say new Color(-1) which makes me sad. Am I to use the solution you posted as my own? – jfh – 2017-12-05T15:26:00.827

@jfhcs I took your solution and only improved it. It's still your solution. – Olivier Grégoire – 2017-12-07T11:24:02.970

1>1512511200000L can be >15125112e5. – Kevin Cruijssen – 2017-12-07T14:54:39.700

1i believe setColor accepts color as int, hence this new Color(0,53,128) could be replaced by this new Color(0x3580) which sould let you save couple bytes – user902383 – 2017-12-08T10:50:29.430

4

Tcl/Tk, 135 bytes

Must be run in the interactive shell

gri [can .c -bg #FFF]
lmap C {"52 2 82 112" "2 42 182 72"} {.c cr r $C -f #003580 -w 0}
if [clock se]>1512518520 {.c cr t 19 9 -te 100}

Before 2017/12/06 02:00 GMT

enter image description here

After 2017/12/06 02:00 GMT

enter image description here

sergiol

Posted 2017-12-04T07:29:39.803

Reputation: 3 055

3

bash and imagemagick, 135

((`date +%s`>1512511199))&&x=100
convert -size 150x80 xc: -background \#003580 -splice 30x30+50+40 -draw "fill black text 9,9 '$x'" x:

enter image description here enter image description here

pacholik

Posted 2017-12-04T07:29:39.803

Reputation: 490

1Better use arithmetic evaluation: ((\date +%s`>=1512511200))&&x=100. Note that I moved the single quotes inside the-draw` parameter, where they need no escaping. – manatwork – 2017-12-07T14:54:32.663

3

vim, 147

I really like this challenge ☺. © is escape.

sy on
set ft=c
hi Normal ctermfg=4 ctermbg=7
hi Number ctermfg=0 ctermbg=7
norm 90i ©26|15r█Y40pMVr█Y14Pk
if localtime()>1512511199
norm R100 

enter image description here

pacholik

Posted 2017-12-04T07:29:39.803

Reputation: 490

2

bash, 198

p()(printf "%-$1b$3" "\e[$2m")
r()(for i in `seq $1`;{ $2;})
a()(p 31 107
p 20 44
p 56 30\;107 "${1:-   }"
p 0 0 '
')
b()(p 95 44
p 0 0 '
')
r 20 a
r 15 b
r 19 a
((`date +%s`>1512511199))&&a 100||a

enter image description here enter image description here

pacholik

Posted 2017-12-04T07:29:39.803

Reputation: 490

2

Imperative Tampio, 239 bytes (non-competing)

Kun iso sivu avautuu,se näyttää tekstin"<svg><path d=180v110 /><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0 fill=#005580 />"ja,jos nykyinen aika millisekunteina on suurempi kuin 1512511200000,niin se näyttää tekstin"<text y=19>100".

Kun iso sivu avautuu,se näyttää tekstin"<svg><path d=180v110 /><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0 fill=#005580 />"ja,jos nykyinen aika millisekunteina on suurempi kuin 1512511200000,niin se näyttää tekstin"<text y=19>100".

Online version

Translation:

When the big page opens, it will show the text "<svg><path d=180v110 /><path d=M0,40h50V0h30v40h100v30H80v40H50V70H0 fill=#005580 />" and, if the current time in milliseconds is greater than 1512511200000, it will show the text "<text y=19>100".

SVG was taken from this answer by th3pirat3 (and Neil, appearently).

This program is written in a new version of Tampio I have been working on. Those of you who know Finnish can see that it is almost readable. I marked the answer as non-competing because this language was published after this challenge.

To run this program, either go to the online version above that contains the compiled JS version of the program or download the compiler from its Github page. To compile the program, run python3 tampio.py -p program.itp >program.html.

Tampio is not a golfing language by any measure, but due to the better svg code, it actually beat Röda... I was a little surprised.

fergusq

Posted 2017-12-04T07:29:39.803

Reputation: 4 867

That's more like it! – Antti29 – 2017-12-12T06:07:51.830

1

HTML + CSS + Javascript, 339 bytes

<style>#f{width:180px;height:110px;position:relative}.b{background-color:#003580;position:absolute}.v{left:27.78%;width:16.67%;height:100%}.h{top:36.36%;height:27.27%;width:100%}</style><div id="f"><div class="b v"></div><div class="b h"></div></div><script>if(Date.now()>1512525600000)document.getElementById('f').innerHTML+=100;</script>

Here's the same solution trimmed down to 260 bytes, which assumes your viewing port has the proper 18:11 ratio.

<style>.b{background-color:#003580;position:absolute}.v{left:27.78%;width:16.67%;height:100%}.h{top:36.36%;height:27.27%;width:100%}</style><div class="b v"></div><div class="b h"></div><script>if(Date.now()>1512525600000)document.body.innerHTML+=100;</script>

You can knock a 0 off of the timestamp in either solution to see the "100" appear.

jstnthms

Posted 2017-12-04T07:29:39.803

Reputation: 181

1

HTML + Javascript, 329 bytes

I shamelessly stole the date-checking part from @jstnthms. Basically I just write crude html table with correct row/col ratios, th being the blue parts. Tested on IE and Chrome, also at mee.fi -site.

<body onload="h=[4,3,4];w=[5,3,10];m=50;s='<style>*{border-spacing:0;padding:0;}th{background:#003580;}</style><table>';for(y in h){s+='<tr height='+(m*h[y])+'>';for(x in w){c=(y==1||x==1)?'h':'d';s+='<t'+c+' width='+(m*w[x])+'>'+(x+y<1&&Date.now()>15125112e5?'100':'')+'</t'+c+'>';}s+='</tr>';}s+='</table>';document.write(s);">

diynevala

Posted 2017-12-04T07:29:39.803

Reputation: 191

Could be further golfed by pure javascript (paste on console)...? – diynevala – 2017-12-05T05:51:56.583

1

Perl 5, 139 bytes

($w,$b,$r)=map"\e[${_}m","47;30",44,0;$_=$w.$"x25 .$b.$"x15 .$w.$"x50 .$r.$/;$_=$_ x12 .s/7/4/gr x9 .$_ x12;time<1512511200||s/   /100/;say

to be launched

perl -E '($w,$b,$r)=map"\e[${_}m","47;30",44,0;$_=$w.$"x25 .$b.$"x15 .$w.$"x50 .$r.$/;$_=$_ x12 .s/7/4/gr x9 .$_ x12;time<1512511200||s/   /100/;say'

capture

ratio was changed because of character ratio height/width = 1.66 (5/3) otherwise with original ratio :

($w,$b,$r)=map"\e[${_}m","47;30",44,0;$_=$w.$"x25 .$b.$"x15 .$w.$"x50 .$r.$/;$_=$_ x20 .s/7/4/gr x15 .$_ x20;time<1512511200||s/   /100/;say

original ratio

Nahuel Fouilleul

Posted 2017-12-04T07:29:39.803

Reputation: 5 582

1

Racket 6.10 with 2htdp/image, 202 bytes

(let*([w 180][h 110][p(λ(w h x y o)(place-image(rectangle w h'solid(color 0 53 128))x y o))][b(p w 30 90 55(p 30 h 60 55(empty-scene w h)))])(if(>(current-seconds)1512536400)(overlay(text"100"9'b)b)b))

Ungolfed:

(let* (
       [flag-width 180]
       [flag-height 110]
       [place-rect (λ (width height x-pos y-pos other-pos)
                     (place-image
                      (rectangle width height 'solid (color 0 53 128))
                      x-pos y-pos other-pos))]
       [flag (place-rect
              flag-width 30 90 55
              (place-rect
               30 flag-height 60 55
               (empty-scene flag-width flag-height)))]
       )
  (if (> (current-seconds) 1512536400)  ; If Finland is 100 years old
      (overlay (text "100" 9 'b) flag)  ; add "100" to the flag
      flag))                            ; otherwise just the flag

with text enter image description here

Julian Zucker

Posted 2017-12-04T07:29:39.803

Reputation: 129

You're the first one to place the 100 on a blue part — almost missed it. – Antti29 – 2017-12-06T16:00:24.603

1

Small Basic, 300 bytes

A Script that takes no input and outputs to the TextWindow object.

GraphicsWindow.BrushColor=0
If Clock.Year*10000+Clock.Month*100+Clock.Day>=20171206Then
GraphicsWindow.DrawText(0,0,"100")
EndIf
GraphicsWindow.Height=275
GraphicsWindow.Width=450
GraphicsWindow.BrushColor="#003580
GraphicsWindow.FillRectangle(0,100,450,75)
GraphicsWindow.FillRectangle(125,0,75,275)

Try it at SmallBasic.com! Requires IE/Silverlight

Output

Shown after the Finland's 100th independence day. Output

Taylor Scott

Posted 2017-12-04T07:29:39.803

Reputation: 6 709

0

the previously made code has been golfed down to the following:

HTML, CSS and JavaScript, 1599 bytes

var d1=new Date(1917,11,6);
var d2=new Date();
var difference = d2.getFullYear()-d1.getFullYear();
if(difference===100 && d2.getDate()===d1.getDate() && d2.getMonth()===d1.getMonth()) {
 document.getElementById("bottom-right").innerHTML=d2.getFullYear()-d1.getFullYear();
}
#flag{
background-color: #FFF;
width: 540px;
height: 330px;
border: 6px solid gray;
margin: 10% auto;
}
.surround{
background-color: #003580;
width: 90px;
height: 120px;
margin: 0px 300px 0px 150px;
}
.middle{
background-color: rgb(0, 53, 128);
width: 540px;
height: 90px;
}
<head>
<title>Happy Birthday, Finland</title>
<link rel="stylesheet" type="text/css" href="decor.css">
</head>
<body>
<div id="flag"><div class="surround"></div><div class="middle"></div><div class="surround"></div></div>
<script type="text/javascript" src="date.js"></script>
</body>

Raunaq Koppikar

Posted 2017-12-04T07:29:39.803

Reputation: 1

Well in my defence, I'd say this is my first time. Will try to make shorter code in future. – Raunaq Koppikar – 2017-12-06T14:09:23.783

As Stephen has already said, this is a code golf, and so your program should aim to be as short as possible. Please keep in mind that if you don't golf your program (i.e. leave it as-is), it is subject to deletion as it currently isn't a serious contender. Finally, welcome to the site! – caird coinheringaahing – 2017-12-06T15:08:58.610

Sure. Will definitely get it golfed asap – Raunaq Koppikar – 2017-12-06T15:20:53.610

Edited as suggested – Raunaq Koppikar – 2017-12-06T17:48:10.880

You can also remove indentation in all, and remove newlines in CSS and HTML. Plus you can remove spaces between symbols in JS (like === and 100). – NoOneIsHere – 2017-12-06T19:53:49.547

Use short CSS color syntax, like #FFF for black. Also, if a CSS class is only used once, it'd be shorter to use inline CSS with the style attribute. – mbomb007 – 2017-12-06T22:36:59.273

Made the suggested edits. By the way, #FFF would be white and #000 would be black. – Raunaq Koppikar – 2017-12-07T03:22:56.850

0

JavaScript ES6, 532 bytes

Decided to try using a Base64 image to see how short I could get it. Not a winner, but interesting nonetheless.

document.write(`${Date.now()>1512525600000?'<i style=position:fixed>100</i>':''}<img src=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAABuAQMAAAC0pqs4AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABlBMVEX///8ANYAaS5LoAAAAAWJLR0QB/wIt3gAAAAd0SU1FB+EMBRcAAPqLykEAAAAxSURBVEjHY2AAA/v///8zYAGj4qPio+KDWfw/VvBhVHxUfEiKD7b8NSo+Kj4qTrQ4AHKtsHq12fKCAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE3LTEyLTA1VDIzOjAwOjAwKzAxOjAwkDJOKAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNy0xMi0wNVQyMzowMDowMCswMTowMOFv9pQAAAAASUVORK5CYI>`)

Jamie Barker

Posted 2017-12-04T07:29:39.803

Reputation: 145

No need for parentheses inside interpolation (${(…)}${…}); no need for double quotes around those HTML attribute values; although invalid, in most cases you can cut off the base64 encoded strings's padding with equal signs (Firefox has certainly no problem decoding it). – manatwork – 2017-12-07T14:42:06.047

0

HTML + JavaScript, 247 bytes

<table cellspacing=0 cellpadding=0><tr height=40><td width=50><td width=30 bgcolor=003580><td width=100><tr height=30><td colspan=3 bgcolor=003580><tr height=40><td><td bgcolor=003580><td><script>Date.now()>15125112e5&&document.write(100)</script>

tsh

Posted 2017-12-04T07:29:39.803

Reputation: 13 072