text:
Tic Tac Toe encoder/decoder
James Bond is about to start a new mission and you are his computer scientist friend. As Tic Tac Toe is becoming more and more popular you decide that nothing would be more underhanded than a Tic Tac Toe encoder/decoder™.
For each line the decoder will follow the following steps:

Convert from 'O','X' and ' ' [space] to trinary

' ' -> 0
'O' -> 1
'X' -> 2

Convert from trinary to decimal
Convert from decimal to letter

Example: "XO "

210
21
v

The encoder will do the reverse.
As code is much more precise than words, see the reference answer below in which I give an example (very long) implementation of the problem in Python:
Your decoder should be able to decode all the messages encoded with my encoder correctly and my decoder should be able to decode all the messages encoded with your encoder.
This is code-golf, the shortest wins.
Additional informations

0 must be converted to a, the alphabet ends with a whitespace, so 26-> ' ' [whitespace]
"XXX" is the max, it translates to "222" that translates to 26.
As in Tic Tac Toe the max line lenght is 3.
X -> 2 means X should be replaced by 2
Encoder/Decoder

The encoder goes from plaintext to code.
The decoder goes from code to plaintext.

What happens when the result of the third step in encoding is grater than 26 ?

@optimizer It can't be: "OOO" is the max, it translates to "222" that translates to 26.

Oh, we only get 3 characters at a time ? Nobody mentioned that :)

Yes, as in Tic Tac Toe the max line lenght is 3.

X -> 1 but XO  -> 210 ? instead of 120 ?

Also, 210 in trinary is 21 in decimal, not 19.

Wow acc. to his code, X -> 2. Totally unclear what he means here..

X -> 2 means X should be replaced by 2

Also, should 1 mean a or 0 mean a ? because if 0 means a, then XXX, i.e. 26 means }

@Optimizer 0 means a

@Optimizer The alphabet ends with a whitespace, so 26-> ' ' [whitespace]

You have to put all these things in the questions as the spec. Do you believe that people will read the comments for sure ?

This is a code-golf. Which means that the code with the smallest bytes is the winner. Instead, you chose the one with the largest bytes. What's wrong with you ?

I thought it was called ternary.

BRAINFUCK, 393 bytes (encoder only)
Guys, we're making something for James Bond. Languages like javascript and C are way too readable! If you want something that the russians will never understand,  brainfuck is the only option. It's surly not the shortest or fastest option, but no-one will understand it (and, let's be honest, everyone loves brainfuck)
The code has a couple of limitations though, It only encodes and only one character at a time. Also it doesn't manually stop, you have the stop it after it spits out the output. But hey, it works. This is the code:
>>>,>++++++++[<-------->-]<->+++<[>[->+>+<<]>[-<<-[>]>>>[<[-<->]<[>]>>[[-]>>+<]
>-<]<<]>>>+<<[-<<+>>]<<<]>>>>>[-<<<<<+>>>>>]<<<<[-<<+>>]+++<[>[->+>+<<]>[-<<-[
>]>>>[<[-<->]<[>]>>[[-]>>+<]>-<]<<]>>>+<<[-<<+>>]<<<]>>>>>[-<<<<<+>>>>>]<<<<<<
[->>>+<<<]+[[-]>[-<+<+<+>>>]<[>++++++++++++++++++++++++++++++++++++++++++++++
++++++<[-]]<-[>> ++++++++++++++++++++++++++++++++++++<<[-]]<--[>>>---<<<[-]]>>>.]

If you want to try it: just run the code with one capital letter as input.
If you want it commented just ask me nicely. A lot of things can be done better but I don't feel like optimizing it now (because brainfuck). Maybe I'll make a decoder too as reversing the process probably isn't that difficult.

Bit late to the party, but pretty please comment it?

C++, 168 + 135 = 303 bytes
EDIT: saved one byte by requiring uppercase input
I like doing these in C++ because I get to do all sorts of fun nastiness I would never ever do in C++ code.
Encoder (168):
Takes a string of uppercase letters and spaces as an argument.
#include<cstdio>
int main(int h,char**c){c[0][3]=0;for(c++;h=**c;c[0]++){h=h&32?26:h-65;for(int d=2,e;d+1;d--){h=(h-(e=h%3))/3;c[-1][d]=e&2?88:e*47+32;}printf(c[-1]);}}

Readable:
#include<cstdio>
int main(int h,char**c)
{
    c[0][3]=0;
    for(c++;h=**c;c[0]++)
    {
        h=h&32?26:h-65;
        for(int d=2,e;d+1;d--)
        {
            h=(h-(e=h%3))/3;
            c[-1][d]=e&2?88:e*47+32;
        }
        printf(c[-1]);
    }
}

Decoder (135):
Takes a string of X, O, and space as an argument.
#include<cstdio>
int b=9,v;int main(int h,char**c){for(c++;h=**c;c[0]++){v+=(h&16?2:h&1)*b;b/=3;if(!b)putchar(v==26?32:v+97),v=0,b=9;}}

Readable:
#include<cstdio>
int b=9,v;
int main(int h,char**c)
{
    for(c++;h=**c;c[0]++)
    {
        v+=(h&16?2:h&1)*b;
        b/=3;
        if(!b)putchar(v==26?32:v+97),v=0,b=9;
    }
}

142 bytes and 117 bytes

CJam, 24 + 25 = 49 bytes
Encoder
qN/{:i40f/3b'a+_'{=S@?}%

Decoder
q{_Sc=26@'a-?Zb" OX"f=N}%

Try it online here

Javascript, ES6, 157 chars
Only encoder, 83
f=s=>s=="XXX"?" ":(parseInt(s.replace(/./g,x=>" OX".indexOf(x)),3)+10).toString(36)

Only decoder, 77
g=s=>(parseInt(10+s,36)-10).toString(3).substr(-3).replace(/./g,x=>" OX"[x])

Both, 157
p=parseInt;f=s=>s=="XXX"?" ":(p(s.replace(/./g,x=>" OX".indexOf(x)),3)+10).toString(36);g=s=>(p(10+s,36)-10).toString(3).substr(-3).replace(/./g,x=>" OX"[x])

Test
console.log(x=["   ", "XO ", "XXX"], x=x.map(f), x.map(g))

PS: Tried to perform some optimization, but failed: resulting code was longer then just concatenation. I don't publish it as it also contains a bug, which had already been fixed.

Your encoder/decoder fail for space/XXX

@Optimizer I've fixed this bug. I have to read the task more carefully before posting an answer...

Not your fault. The spec kept on revealing itself in parts.

Maybe my stupid actions will inspire you to improve something else:
n=[36,3];r=s=>s.replace(/./g,x=>" OX"[x]||" OX".indexOf(x));f=(s,t,p=a=>(parseInt(a,n[1-t])+10-20*t).toString(n[t]))=>t?r(p(10+s).substr(-3)):s=="XXX"?" ":p(r(s)) usage: console.log(x=["   ", "XO ", "XXX"], x=x.map(z=>f(z,0)), x.map(z=>f(z,1)))

R, 121 + 115 = 236
I think I got the spec correct
Decoder Function 121
d=function(s){i=rev(as.integer(unlist(strsplit(chartr('XO ','210',s),''))));c(letters,' ')[sum(3^(0:(length(i)-1))*i)+1]}

Encoder Function 115
e=function(s){i=which(c(letters,' ')==s)-1;paste(chartr("210","XO ",c(i%/%9%%3,i%/%3%%3,i%%3)),sep='',collapse='')}

This only works on lower case characters.  Is that a requirement?
Quick Test
> mapply(d,c("OO "," OO"," OO","X O","XXX"))
OO   OO  OO X O XXX
"m" "e" "e" "t" " "
> mapply(e,unlist(strsplit('meet ','')))
    m     e     e     t
"OO " " OO" " OO" "X O" "XXX"

187 bytes (84 + 103) with a few golfs...

Go, 372 bytes \$= 29 + 171 + 170\$

Imports = 29 bytes
Decoder = 171 bytes
Encoder = 170 bytes

import(."strings";."strconv")
func d(s string)(k string){for _,l:=range Split(s,"\n"){i,_:=ParseInt(NewReplacer(" ","0","O","1","X","2").Replace(l),3,64)
k+=string('A'+i)}
return ReplaceAll(k,"["," ")}
func e(s string)(k string){q:=ReplaceAll(s," ","[")
for _,r:=range q{k+=NewReplacer("0"," ","1","O","2","X").Replace(FormatInt(int64(r-'A'),3))+"\n"}
return Trim(k,"\n")}

Attempt This Online!
Explanation
Decoder
import(."strings";."strconv")
func d(s string)(k string){
for _,l:=range Split(s,"\n"){            // for each line...
i,_:=ParseInt(                           // turn the string into an int
    NewReplacer(" ","0","O","1","X","2") // define the replacements
    .Replace(l),                         // replace the chars
    3,64)                                // turn it into trinary
k+=string('A'+i)}                        // append to the output string
return ReplaceAll(k,"["," ")}            // replace `[` with spaces

Encoder
import(."strings";."strconv")
func e(s string)(k string){
q:=ReplaceAll(s," ","[")                // replace `[` with spaces
for _,r:=range q{                       // for each character...
k+=NewReplacer("0"," ","1","O","2","X") // define the replacements...
    .Replace(                           // and apply onto...
    FormatInt(int64(r-'A'),3))          // the character, turned into trinary
    +"\n"}                              // and add a newline
return Trim(k,"\n")}                    // trim the final newline

Excel, 81 + 87 = 168 bytes
Encoder:
=CONCAT(SWITCH(0+MID(BASE(TEXT(CODE(A1)-97,"[=63]26"),3,3),{1,2,3},1),2,"X",1,"O"," "))

Decoder:
=CHAR(97+TEXT(MMULT(SWITCH(MID(A1,{1,2,3},1),"X",2,"O",1,),3^{2;1;0}),"[=26]63"))

Input in cell A1 in both cases.

Nibbles, 12 + 14 = 26 bytes
Encoder, 12 bytes
.@.`@3%-$6 91=$"OX "

Attempt This Online!
-1 byte thanks to Dominic van Essen
.@.`@3%-%$32~27=$"OX "
.                      For each character c in
 @                      the input as a string
  .                     for each digit d in
   `@3                   convert to base 3
        %$32              ord(c) mod 32
       -    ~             minus 1
      %      27           mod 27
               =$        take the d-th character (1-indexed, wrapping)
                 "OX "    from "OX "

Decoder, 14 bytes
*" "`%.;@+`@3.$%/$10 3'a'"{"

Attempt This Online!
*" "`%.;@+`@3.$%/$10 3'a'"{"
*" "                         Join by spaces
    `%                   "{"  split on '{' characters
      .                        for each line l in
       ;@                       the input as a list of lines
         +            'a'        add the character code of 'a' to
          `@3                     convert from base 3
             .                     for each character c in
              $                     l
                /$10                ord(c) divided by 10
               %     3              modulo 3

I realized later that I could've simply used ?"OX"$ instead of %/$10 3. The byte count is equal.

12 bytes for the encoder using minus-6-modulo-91...

@DominicvanEssen Thanks!

Reference answer, completely ungolfed:
# Tic-Tac-Toe code encoder

def from_letter_to_decimal(letter):
    alphabet = "abcdefghijklmnopqrstuvwxyz "
    return alphabet.index(letter)

def from_decimal_to_trinary(decimal):
    digits = []
    while decimal:
        digits.append(str(decimal % 3))
        decimal //= 3
    return ''.join(list(reversed((digits))))

def from_trinary_to_line(trinary):
    replace_dict = {"0": " ",
                  "1": "O",
                  "2": "X"}
    for char in replace_dict:
        trinary = trinary.replace(char,replace_dict[char])
    return trinary

def encode_letter(letter):
    decimal = from_letter_to_decimal(letter)
    trinary = from_decimal_to_trinary(decimal)
    line = from_trinary_to_line(trinary)
    return line

def encode_text(text):
    return '\n'.join([encode_letter(letter) for letter in text])

print(encode_text("meet me under the red bridge"))

# Tic-Tac-Toe code decoder

boards = """
OO
OO
OO
X O
XXX
OO
OO
XXX
X X
OOO
O
OO
OXX
XXX
X O
XO
OO
XXX
OXX
OO
O
XXX
O
OXX
XX
O
X
OO

"""

def from_line_to_trinary(line):
    replace_dict = {" ": "0",
                  "O": "1",
                  "X": "2"}
    for char in replace_dict:
        line = line.replace(char,replace_dict[char])
    return line

def from_trinary_to_decimal(n):
    result = 0
    for position,i in enumerate(reversed(n)):
        result += int(i) * 3**position
    return result

def from_decimal_to_letter(n):
    alphabet = "abcdefghijklmnopqrstuvwxyz "
    return alphabet[n]

def decode_line(line):
    trinary = from_line_to_trinary(line)
    decimal = from_trinary_to_decimal(trinary)
    letter = from_decimal_to_letter(decimal)
    return letter

def decode_boards(boards):
    return ''.join([decode_line(line) for line in boards.splitlines() if not line==""])

print(decode_boards(boards))

I think you lost the leading spaces in the boards string in your decoder.

@optimizer: over here the first few lines show up as OO_ OO OO X_O, which would be mmmt.

@optimizer: oh wait, they're supposed to be right-aligned. duh.

Ruby, 44 + 54 = 98 bytes
Encoder
->s{[*?A..?Z," "][s.tr(" OX","012").to_i 3]}

Attempt This Online!
Decoder
->c{((c<?A??[:c).ord-65).digits(3).join.tr"012"," OX"}

Attempt This Online!

Japt v1.4.5, 12 + 17 = 29 bytes
Encoder
;C+S gUn" OX

Try it
Decoder
;C+S aU s" OX" ù3

Try it
I tried some options that worked with codepoints rather than indexing into C+S, but they always ended up being longer in order to handle the space.
Explanations:
;C+S gUn" OX
;            # C = "abcdefghijklmnopqrstuvwxyz"
 C+S         # Add a space to the end of C
     g       # Get the character at index:
      U      #  Input string
       n" OX #  Converted to base 10 from base " OX"

;C+S aU s" OX" ù3
;                 # C = "abcdefghijklmnopqrstuvwxyz"
 C+S              # Add a space to the end of C
     aU           # Find the index of the input string
        s" OX"    # Convert to base " OX"
               ù3 # Left pad with spaces to length 3

Scala, 90+107=197 bytes
Port of @Jordan's Ruby answer in Scala.

Encoder
Golfed version. Attempt This Online!
s=>(('A'to'Z')++Seq(' '))(Integer.parseInt(s.map{case'O'=>'1'case'X'=>'2'case' '=>'0'},3))

Ungolfed version. Attempt This Online!
object Main {
  def main(args: Array[String]): Unit = {
    def f(s: String): Char = {
      val alphabet = ('A' to 'Z') ++ Seq(' ')
      val mapped = s.map {
        case 'O' => '1'
        case 'X' => '2'
        case ' ' => '0'
      }
      val idx = Integer.parseInt(mapped, 3)
      alphabet(idx)
    }

    println("["++f("XO ").toString++"]")
    println("["++f("XXX").toString++"]")
  }
}

Decoder
Golfed version. Attempt This Online!
c=>{val n=if(c<'A')26 else c-'A';Integer.toString(n,3).map{case'0'=>' ';case'1'=>'O';case'2'=>'X'}.reverse}

Ungolfed version. Attempt This Online!
object Main {
  def F(c: Char): String = {
    val n = if (c < 'A') 26 else (c - 'A').toInt
    val base3 = Integer.toString(n, 3)
    base3.map {
      case '0' => ' '
      case '1' => 'O'
      case '2' => 'X'
    }.reverse
  }

  def main(args: Array[String]): Unit = {
    println(F('V'))
    println(F(' '))
  }
}

APL (Dyalog Unicode), 18 + 18 = 36 bytes
Decoder:
(⊂3⊥⍉' O'⍳⎕)⌷27↑⎕A

Encoder:
' OX'[⍉3 3 3⊤⎕A⍳⎕]

Try it online!


text:
Return the clock emoji closest to the current time when run
I can have a large if/else condition for each 30 minutes but I'm looking for more math and Unicode based solution.
Here are clock emojis:
. If you lack proper rendering support, you can see them below (they're not in the same order and they may look different to what you see) or at the Unicode chart, page 4. They correspond to Unicode codepoints U+1F550 (CLOCK FACE ONE OCLOCK) through U+1F567 (CLOCK FACE TWELVE-THIRTY).
Your challenge is to write a program that outputs to STDOUT the closest clock face emoji to the current system time (AM and PM should be treated the same). For example if the time t is [5:15 ≤ t < 5:45), you would display the 5:30 emoji .
This is code-golf, so shortest code in bytes wins. You may want to include a way to easily specify the time to test your code.
Edge test cases
Time   Output  Written
----------------------
11:48         12:00
3:15          3:30
9:45          10:00

This question isn't currently on-topic here but it's probably an easy fix. You need an objective win condition, but if you tag the question [tag:code-golf] the winner will be whoever writes the shortest program. It's also a bit under specified, but you could say "a script that outputs the clock emoji closest to the current time when run" and that should be enough. Also, while not technically required, I'd recommend that you allow submissions in other languages. (Someone will probably do one in Bash anyway.)

Windows Command prompt doesn't support emojis :(

https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/emoji-clock/emoji-clock.plugin.zsh

@undergroundmonorail Fair point. Updated

I've edited your post to attempt to have it meet our standards by clarifying the rules and making it code golf. Feel free to edit it if I misinterpreted anything.

What if the languages I am writing in does not print the emoji clock face at all, but instead, a box with the hex code in it ?

How should xx:15 and xx:45 be rounded?

@PeterTaylor As seen in the test cases, they should be rounded up (i.e. 1:45 => 2:00)

@Optimizer As long as it's the same character as the emoji, how it looks doesn't matter.

Who even has a programming environment that enables these to be printed and seen?

I have a font that supports N:00 but not N:30, lol.

@feersum I have that on both my phone and my PC. Seems to be common.

Is JavaScript alert or console.log allowed instead of stdout?

@Pietu1998 Yes, alert is allowed as it is javascript's closest alternative.

Ruby — 61 54 bytes
Python 3 — 79 77 75 74 bytes
edit: Turns out this is much shorter in Ruby, because Time doesn't need to be imported and integer division is the default.
a=(Time.now.to_i/900-3)/2%24
puts""<<128336+a/2+a%2*12

Arithmetic:

Time.now.to_i: Seconds since epoch.
/900: Combine time into 15-minute segments.
-3: -4 because characters start at 1 o'clock, +1 so that rounding is done to nearest half hour, rather than downwards.
/2: Combine into half-hour segments.
%24: Get current half-hour segment out of 12 hours.
a/2 + a%2*12: Account for the fact that whole-hour characters come in a block before half-hour characters.

Local time version, 69 bytes:
n=Time.now
a=((n.to_i+n.gmtoff)/900-3)/2%24
puts""<<128336+a/2+a%2*12

Original Python 3 version:
import time
a=int((time.time()/900-3)/2%24)
print(chr(128336+a//2+a%2*12))

Prints the current time UTC. Python 2's chr only accepts 0-255, and unichr only 0-65535. In Python 3, / is always floating-point division and // is always integer division.

You can cut the parens from 12*(a%2) if you do it in the other order: a%2*12.

Bash + Coreutils, 60 47
date +%I\ 60*%M+45-30/24%%2~C*+16iF09F9590+P|dc

Try it online!
Emojis render fine on the OSX terminal, but for Linux (Ubuntu 14.04) you'll have to sudo apt-get install ttf-ancient-fonts
For testing different times, insert -d $time into the date command.  e.g for testing 12:59:
date -d 12:59 +%I\ 60*%M+45-30/24%%2~C*+16iF09F9590+P|dc

JavaScript – 137 117 107 102 95 bytes
This is going to get easily beaten, but I'll just try my best here.
EDIT 1: Now prints in UTC like the Python answer to save 20 bytes.
EDIT 2: Changed new Date().getTime() to Date.now() to save 10 bytes.
EDIT 3: Changed Math.round(x) to ~~(x+.5) to save 5 bytes.
EDIT 4: Removed unnecessary ( and &1023) left from some old development version where I did a more universal UTF-16 encoding to save 7 bytes.

d=~~(Date.now()/18e5+.5)%24;d+=d<2?24:0;alert(String.fromCharCode(55357,56655+(d%2?23+d:d)/2));

JavaScript does allow for emojis, but in UTF-16 which encodes them as two characters. Luckily, we can simply define them as two characters; the first character is also constant (0xD83D), while the other changes.
Alternative, prints in local time, 137 132 125:

a=new Date();d=~~(a.getHours()%12*2+a.getMinutes()/30+.5);d+=d<2?24:0;alert(String.fromCharCode(55357,56655+(d%2?23+d:d)/2));

Isn't (d%2?23+d:d) the same as d+d%2*23?

CJam, 31 bytes
"")et5<60b675+30/24%2mdC*++

You can change the time in the following program to test it:
"")[2014 12 19 22 14 1 901 5 -28800000]5<60b675+30/24%2mdC*++

CJam, 50 bytes
"":i~et3=C%60*et4=+30d/mo2m24+24%_2%24*+2/+]:c

The algorithm is simple, round the time to nearest 30 minutes, count how many 30 minutes have passed since 12 AM/PM, if the number is odd, then add 24 to it, floor divide by 2 and increment the initial unicode by that many code points to get the right clock face.
Also, make sure that you start with 1 AM/PM instead of 12 so take an offset there.
For testing purposes, use the following code:
3:H;45:M;"":i~HC%60*M+30d/mo2m48+48%_2%24*+2/+]:c

Where the 3:H; part is the current hour and the 45:M; part is the current minute of the hour. Simply replace 3 and 45 with the desired value.
Try it online here
Not all unicode characters might print correctly on the online version depending upon your browser and OS and installed fonts. But for me, all print fine on Firefox with Windows 7.

@user23013 Nice!. I think you should post that as a new answer as I did not do any golfing in that :)

C (gcc) with -m32, 104 100 98 bytes

-6 thanks to ceilingcat

*t;f(i){char a[]="";time(&i);i=1[t=gmtime(&i)]/15;a[3]=144+(t[2]+11+i/4)%12+(i-1U<2)*12;puts(a);}

Try it online!
Ungolfed:
*t; // broken-down time structure ([1]=minutes, [2]=hours)
f(i){ // time
  char a[]=""; // base emoji in modifiable UTF-8 string
  time(&i); // get time and convert into structure
  i=1[t=gmtime(&i)]/15; // get granular 15-minute chunks
  a[3]=
    144+ // base 4th byte of emoji
    (t[2]+11+i/4)%12+ // convert [0..23] to [1..24]-1 for hour, adding [0:45..1:00)
    (i-1U<2)*12; // add [0:15..0.45) as half-hour
  puts(a);
}

there might be an error, I got `` at 12:57

Go, 265 bytes, function
import."time"
func f()rune{N,H:=Now(),Hour/2
e,l:=N.Truncate(H),N.Round(H)
if e.Sub(N).Abs()<l.Sub(N).Abs(){N=e}else{N=l}
return []rune("")[N.Hour()%12*2+N.Minute()/30]}

Attempt This Online!
Gets the current time, rounds up and down to the nearest half hour, finds the closer one, and returns the emoji that represents it.
Go, 285 bytes, full program
package main
import."time"
func main(){N,H:=Now(),Hour/2
e,l:=N.Truncate(H),N.Round(H)
if e.Sub(N).Abs()<l.Sub(N).Abs(){N=e}else{N=l}
print(string([]rune("")[N.Hour()%12*2+N.Minute()/30]))}

Attempt This Online!

You have a rogue ) at the end of your first answer. Remove it for 265 bytes

05AB1E, 30 bytes
ža60*žb+45-30÷24%2‰`12*+Žü¤·+ç

Port of @jimmy23013's CJam answer, so make sure to upvote him as well!
Try it online or verify some manual test times.
Explanation:
Uses the following formula to calculate the clock codepoint based on the given \$h\$ours and \$m\$inutes:
$$d(h,m) = \left\lfloor\frac{60h+m-45}{30}\right\rfloor\bmod{24} \\
C(h,m) = \left\lfloor\frac{d(h,m)}{2}\right\rfloor+12(d(h,m)\bmod{2})+128336$$
ža                              # Push the current hours
  60*                           # Multiply them by 60
     žb+                        # Add the current minutes
        45-                     # Subtract 45
           30÷                  # Integer-divided by 30
              24%               # Modulo 24
                 2‰             # Divmod by 2: [n//2,n%2]
                   `            # Pop and push n//2 and n%2 separated to the stack
                    12*         # Multiply n%2 by 12
                       +        # Add it to the n//2
                        Žü¤     # Push compressed integer 64168
                           ·    # Double it to 128336
                            +   # Add it as well
                             ç  # Convert it to a character with this codepoint
                                # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Žü¤ is 64168 (compressed 128336 directly is 1 byte longer: •1ùθ•).

Julia, 81 bytes
using Dates
n=now()
M=minute(n)
print(''+mod1(hour(n)+(M>44),12)+12(14<M<45))

Attempt This Online!
Julia is generally picky with types, but some common arithmetic statements involving Char, Int, and Bool are permitted. The Int values of the clock emojis are the range 128336:128359. The emojis are encoded in ascending order, with all the twelve that are on the hour coming before the twelve half-past emojis. In this algorithm, the preceding character '' is incremented by the 12-hour number (plus 1 if it's more than 44 minutes past the hour), and another 12 is added if the minute hand needs to be adjusted.
-17 bytes (!!) thanks to MarcMush: just use Dates.minute instead of parsing the time string

81 bytes also fixes an error with 12:50

Pascal, 134 characters
This program requires a processor supporting the time-related features defined by ISO standard 10206 “Extended Pascal”.
Furthermore the implementation-defined set of char values must include said Unicode characters.
program t(output);var t:timeStamp;begin getTimeStamp(t);write(('')[t.hour mod 12*2+round(t.minute/30)+1])end.

Ungolfed:
program clock(output);
    var
        ts: timeStamp;
    begin
        getTimeStamp(ts);
        { This `program` presumes `ts.timeValid` is set to `true`.
          Otherwise `getTimeStamp` sets the clock to midnight. Insert

            ts.hour := 11;
            ts.minute := 48;

          here to test the functionality of this `program`. }
        writeLn(('')
            [ts.hour mod 12 * 2 + round(ts.minute / 30) + 1]);
    end.

Wolfram Language (Mathematica), 98 bytes
Print@FromCharacterCode[128336+Quotient[#,2]+12Mod[#,2]&[Mod[Quotient[UnixTime[]-2700,900]/2,24]]]

Original Code is
a = Mod[Quotient[UnixTime[] - 3 * 900, 900] / 2, 24];
result = FromCharacterCode[128336 + Quotient[a, 2] + Mod[a, 2] * 12];
Print[result]

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Computer: you do the math
This challenge is partly an algorithms challenge, involves some math and is partly simply a fastest code challenge.
For some positive integer n, consider a uniformly random string of 1s and 0s of length n and call it A.   Now also consider a second uniformly chosen random string of length n whose values are -1, 0, or 1 and call it B_pre.   Now let B be B_pre+B_pre. That is B_pre concatenated to itself.
Now consider the inner product of A and B[j,...,j+n-1] and call it Z_j and index from 1.
Task
The output should be a list of n+1 fractions. The ith term in the output should be the exact probability that all of the first i terms Z_j with j <= i equal 0.
Score
The largest n for which your code gives the correct output in under 10 minutes on my machine.
Tie Breaker
If two answers have the same score, the one submitted first wins.
In the (very very) unlikely event that someone finds a method to get unlimited scores, the first valid proof of such a solution will be accepted.
Hint
Do not try to solve this problem mathematically, it's too hard. The best way in my view is to go back to basic definitions of probability from high school and find smart ways to get the code to do an exhaustive enumeration of the possibilities.
Languages and libraries
You can use any language which has a freely available compiler/interpreter/etc. for Linux and any libraries which are also freely available for Linux.
My machine
The timings will be run on my machine. This is a standard ubuntu install on an AMD FX-8350 Eight-Core Processor. This also means I need to be able to run your code. As a consequence, only use easily available free software and please include full instructions how to compile and run your code.

Some test outputs. Consider just the first output for each n. That is when i=1. For n from 1 to 13 they should be.
 1: 4/6
 2: 18/36
 3: 88/216
 4: 454/1296
 5: 2424/7776
 6: 13236/46656
 7: 73392/279936
 8: 411462/1679616
 9: 2325976/10077696
10: 13233628/60466176
11: 75682512/362797056
12: 434662684/2176782336
13: 2505229744/13060694016

You can also find a general formula for i=1 at http://oeis.org/A081671 .
Leaderboard (split by language)

n = 15. Python + parallel python + pypy in 1min49s by Jakube
n = 17. C++ in 3min37s by Keith Randall
n = 16. C++ in 2min38s by kuroi neko

@Knerd How can I say no. I will try to work out how to run your code in linux but any help much appreciated.

Ok, sorry for deleting comments. For all that didn't read, it was if F# or C# are allowed :)

The other question again, do you maybe have an example of a valid input output?

What is your graphic card ? Looks like a job for a GPU.

@Knerd I added a table of probabilities to the question instead. I hope it is helpful.

@Mig PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780/RS880 PCI to PCI bridge (PCIE port 1)  . This may be disappointing news for you, sorry.

http://oeis.org/A081671

@KennyTM Thanks I'll add that to the question.

@Lembik could you please add the execution time on your machine to the leaderboard? I'm really curious to see what your 8 cores can make of my code.

@kuroineko It only runs on one core!  Have you tried it in your ubuntu install?

@Lembik Pfff... I can't get VirtualBox to allocate more than 1 CPU to my VM, so I can't test that. The horrible processor affinity code does not help either. Would you kindly comment out the lock_on_core() call and see if the scheduler does make some use of your 8 cores when left to its own initiative?

I know nothing about windows but http://askubuntu.com/questions/365615/how-do-i-enable-multiple-cores-in-my-virtual-enviroment seems related to your problem. Maybe there is a windows version of this. I also commented out lock_on_core(index); but it seems to have made no difference.

Pfff (bis)... VirtualBox does not allow me to change the settings despite what the article claims, and frankly I'm getting tired of this. Now about you native Ubuntu environment, I wonder what use threads are if the bloody OS and/or compiler does not manage to run them on all available cores? Is there some Linux magic to invoke to make that possible at all?

It really should work. Could you make a minimal example for me to test and possibly post on SO?

If it helps, https://bpaste.net/show/ee23472615c3 works and uses all my cores and I have to compile it with g++ -O3 -std=c++0x -pthread -Wl,--no-as-needed Stefan.cpp -o Stefan

C++, n=18 in 9 min on 8 threads
(Let me know if it makes it under 10 minutes on your machine.)
I take advantage of several forms of symmetry in the B array.  Those are cyclic (shift by one position), reversal (reverse the order of the elements), and sign (take the negative of each element).  First I compute the list of Bs we need to try and their weight.  Then each B is run through a fast routine (using bitcount instructions) for all 2^n values of A.
Here's the result for n==18:
> time ./a.out 18
 1: 16547996212044 / 101559956668416
 2:  3120508430672 / 101559956668416
 3:   620923097438 / 101559956668416
 4:   129930911672 / 101559956668416
 5:    28197139994 / 101559956668416
 6:     6609438092 / 101559956668416
 7:     1873841888 / 101559956668416
 8:      813806426 / 101559956668416
 9:      569051084 / 101559956668416
10:      510821156 / 101559956668416
11:      496652384 / 101559956668416
12:      493092812 / 101559956668416
13:      492186008 / 101559956668416
14:      491947940 / 101559956668416
15:      491889008 / 101559956668416
16:      449710584 / 101559956668416
17:      418254922 / 101559956668416
18:      409373626 / 101559956668416

real    8m55.854s
user    67m58.336s
sys 0m5.607s

Compile the program below with g++ --std=c++11 -O3 -mpopcnt dot.cc
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <thread>
#include <mutex>
#include <chrono>

using namespace std;

typedef long long word;

word n;

void inner(word bpos, word bneg, word w, word *cnt) {
    word maxi = n-1;
    for(word a = (1<<n)-1; a >= 0; a--) {
        word m = a;
        for(word i = maxi; i >= 0; i--, m <<= 1) {
            if(__builtin_popcount(m&bpos) != __builtin_popcount(m&bneg))
                break;
            cnt[i]+=w;
        }
    }
}

word pow(word n, word e) {
    word r = 1;
    for(word i = 0; i < e; i++) r *= n;
    return r;
}

typedef struct {
    word b;
    word weight;
} Bentry;

mutex block;
Bentry *bqueue;
word bhead;
word btail;
word done = -1;

word maxb;

// compute -1*b
word bneg(word b) {
    word w = 1;
    for(word i = 0; i < n; i++, w *= 3) {
        word d = b / w % 3;
        if(d == 1)
            b += w;
        if(d == 2)
            b -= w;
    }
    return b;
}

// rotate b one position
word brot(word b) {
    b *= 3;
    b += b / maxb;
    b %= maxb;
    return b;
}

// reverse b
word brev(word b) {
    word r = 0;
    for(word i = 0; i < n; i++) {
        r *= 3;
        r += b % 3;
        b /= 3;
    }
    return r;
}

// individual thread's work routine
void work(word *cnt) {
    while(true) {
        // get a queue entry to work on
        block.lock();
        if(btail == done) {
            block.unlock();
            return;
        }
        if(bhead == btail) {
            block.unlock();
            this_thread::sleep_for(chrono::microseconds(10));
            continue;
        }
        word i = btail++;
        block.unlock();

        // thread now owns bqueue[i], work on it
        word b = bqueue[i].b;
        word w = 1;
        word bpos = 0;
        word bneg = 0;
        for(word j = 0; j < n; j++, b /= 3) {
            word d = b % 3;
            if(d == 1)
                bpos |= 1 << j;
            if(d == 2)
                bneg |= 1 << j;
        }
        bpos |= bpos << n;
        bneg |= bneg << n;
        inner(bpos, bneg, bqueue[i].weight, cnt);
    }
}

int main(int argc, char *argv[]) {
    n = atoi(argv[1]);

    // allocate work queue
    maxb = pow(3, n);
    bqueue = (Bentry*)(malloc(maxb*sizeof(Bentry)));

    // start worker threads
    word procs = thread::hardware_concurrency();
    vector<thread> threads;
    vector<word*> counts;
    for(word p = 0; p < procs; p++) {
        word *cnt = (word*)calloc(64+n*sizeof(word), 1);
        threads.push_back(thread(work, cnt));
        counts.push_back(cnt);
    }

    // figure out which Bs we actually want to test, and with which weights
    bool *bmark = (bool*)calloc(maxb, 1);
    for(word i = 0; i < maxb; i++) {
        if(bmark[i]) continue;
        word b = i;
        word w = 0;
        for(word j = 0; j < 2; j++) {
            for(word k = 0; k < 2; k++) {
                for(word l = 0; l < n; l++) {
                    if(!bmark[b]) {
                        bmark[b] = true;
                        w++;
                    }
                    b = brot(b);
                }
                b = bneg(b);
            }
            b = brev(b);
        }
        bqueue[bhead].b = i;
        bqueue[bhead].weight = w;
        block.lock();
        bhead++;
        block.unlock();
    }
    block.lock();
    done = bhead;
    block.unlock();

    // add up results from threads
    word *cnt = (word*)calloc(n,sizeof(word));
    for(word p = 0; p < procs; p++) {
        threads[p].join();
        for(int i = 0; i < n; i++) cnt[i] += counts[p][i];
    }
    for(word i = 0; i < n; i++)
        printf("%2lld: %14lld / %14lld\n", i+1, cnt[n-1-i], maxb<<n);
    return 0;
}

Good, that dispenses me of working further on my own pet monster...

Thanks for this. You have the current winning entry. We do have to remember -pthread again. I get to  n=17 on my machine.

Oops.. You should have got the full bounty. Sorry I missed the deadline.

@Lembik: no problem.

Python 2 using pypy and pp: n = 15 in 3 minutes
Also just a simple brute force. Interesting to see, that I nearly get the same same speed as kuroi neko with C++. My code can reach n = 12 in about 5 minutes. And I only run it on one virtual core.
edit: Reduce search space by a factor of n
I noticed, that a cycled vector A* of A produces the same numbers as probabilities (same numbers) as the original vector A when I iterate over B.
E.g. The vector (1, 1, 0, 1, 0, 0) has the same probabilities as each of the vectors (1, 0, 1, 0, 0, 1), (0, 1, 0, 0, 1, 1), (1, 0, 0, 1, 1, 0), (0, 0, 1, 1, 0, 1) and (0, 1, 1, 0, 1, 0) when choosing a random B. Therefore I don't have to iterate over each of these 6 vectors, but only about 1 and replace count[i] += 1 with count[i] += cycle_number.
This reduces the complexity from Theta(n) = 6^n to Theta(n) = 6^n / n. Therefore for n = 13 it's about 13 times as fast as my previous version. It calculates n = 13 in about 2 minutes 20 seconds. For n = 14 it is still a little bit too slow. It takes about 13 minutes.
edit 2: Multi-core-programming
Not really happy with the next improvement. I decided to also try to execute my program on multiple cores. On my 2 + 2 cores I now can calculate n = 14 in about 7 minutes. Only a factor of 2 improvement.
The code is available in this github repo: Link. The multi-core programming makes is a little bit ugly.
edit 3: Reducing search space for A vectors and B vectors
I noticed the same mirror-symmetry for the vectors A as kuroi neko did. Still not sure, why this works (and if it works for each n).
The reducing of the search space for B vectors is a bit cleverer. I replaced the generation of the vectors (itertools.product), with an own function. Basically, I start with an empty list and put it on a stack. Until the stack is empty, I remove a list, if it has not the same lenght as n, I generate 3 other lists (by appending -1, 0, 1) and pushing them onto the stack. I a list has the same length as n, I can evaluate the sums.
Now that I generate the vectors myself, I can filter them depending on if I can reach the sum = 0 or not. E.g. if my vector A is (1, 1, 1, 0, 0), and my vector B looks (1, 1, ?, ?, ?), I know, that I cannot fill the ? with values, so that A*B = 0. So I don't have to iterate over all those 6 vectors B of the form (1, 1, ?, ?, ?).
We can improve on this, if we ignore the values for 1. As noted in the question, for the values for i = 1 are the sequence A081671. There are many ways to calculate those. I choose the simple recurrence: a(n) = (4*(2*n-1)*a(n-1) - 12*(n-1)*a(n-2)) / n. Since we can calculate i = 1 in basically no time, we can filter more vectors for B. E.g. A = (0, 1, 0, 1, 1) and B = (1, -1, ?, ?, ?). We can ignore vectors, where the first ? = 1, because the A * cycled(B) > 0, for all these vectors. I hope you can follow. It's probably not the best example.
With this I can calculate n = 15 in 6 minutes.
edit 4:
Quickly implemented kuroi neko's great idea, which says, that B and -B produces the same results. Speedup x2. Implementation is only a quick hack, though. n = 15 in 3 minutes.
Code:
For the complete code visit Github. The following code is only a representation of the main features. I left out imports, multicore programming, printing the results, ...
count = [0] * n
count[0] = oeis_A081671(n)

#generating all important vector A
visited = set(); todo = dict()
for A in product((0, 1), repeat=n):
    if A not in visited:
        # generate all vectors, which have the same probability
        # mirrored and cycled vectors
        same_probability_set = set()
        for i in range(n):
            tmp = [A[(i+j) % n] for j in range(n)]
            same_probability_set.add(tuple(tmp))
            same_probability_set.add(tuple(tmp[::-1]))
        visited.update(same_probability_set)
        todo[A] = len(same_probability_set)

# for each vector A, create all possible vectors B
stack = []
for A, cycled_count in dict_A.iteritems():
    ones = [sum(A[i:]) for i in range(n)] + [0]
    # + [0], so that later ones[n] doesn't throw a exception
    stack.append(([0] * n, 0, 0, 0, False))

    while stack:
        B, index, sum1, sum2, used_negative = stack.pop()
        if index < n:
            # fill vector B[index] in all possible ways,
            # so that it's still possible to reach 0.
            if used_negative:
                for v in (-1, 0, 1):
                    sum1_new = sum1 + v * A[index]
                    sum2_new = sum2 + v * A[index - 1 if index else n - 1]
                    if abs(sum1_new) <= ones[index+1]:
                        if abs(sum2_new) <= ones[index] - A[n-1]:
                            C = B[:]
                            C[index] = v
                            stack.append((C, index + 1, sum1_new, sum2_new, True))
            else:
                for v in (0, 1):
                    sum1_new = sum1 + v * A[index]
                    sum2_new = sum2 + v * A[index - 1 if index else n - 1]
                    if abs(sum1_new) <= ones[index+1]:
                        if abs(sum2_new) <= ones[index] - A[n-1]:
                            C = B[:]
                            C[index] = v
                            stack.append((C, index + 1, sum1_new, sum2_new, v == 1))
        else:
            # B is complete, calculate the sums
            count[1] += cycled_count  # we know that the sum = 0 for i = 1
            for i in range(2, n):
                sum_prod = 0
                for j in range(n-i):
                    sum_prod += A[j] * B[i+j]
                for j in range(i):
                    sum_prod += A[n-i+j] * B[j]
                if sum_prod:
                    break
                else:
                    if used_negative:
                        count[i] += 2*cycled_count
                    else:
                        count[i] += cycled_count

Usage:
You have to install pypy (for Python 2!!!). The parallel python module isn't ported for Python 3. Then you have to install the parallel python module pp-1.6.4.zip. Extract it, cd into the folder and call pypy setup.py install.
Then you can call my program with
pypy you-do-the-math.py 15
It will automatically determine the number of cpu's. There may be some error messages after finishing the program, just ignore them. n = 16 should be possible on your machine.
Output:
Calculation for n = 15 took 2:50 minutes

 1  83940771168 / 470184984576  17.85%
 2  17379109692 / 470184984576   3.70%
 3   3805906050 / 470184984576   0.81%
 4    887959110 / 470184984576   0.19%
 5    223260870 / 470184984576   0.05%
 6     67664580 / 470184984576   0.01%
 7     30019950 / 470184984576   0.01%
 8     20720730 / 470184984576   0.00%
 9     18352740 / 470184984576   0.00%
10     17730480 / 470184984576   0.00%
11     17566920 / 470184984576   0.00%
12     17521470 / 470184984576   0.00%
13     17510280 / 470184984576   0.00%
14     17507100 / 470184984576   0.00%
15     17506680 / 470184984576   0.00%

Notes and ideas:

I have a i7-4600m processor with 2 cores and 4 threads. It doesn't
matter If I use 2 or 4 threads. The cpu-usage is 50% with 2 threads and 100% with 4 threads, but it still takes the same amount of time. I don't know why. I checked, that each thread only has to the the half amout of data, when there are 4 threads, checked the results, ...
I use a lot of lists. Python isn't quite efficient in storing, I have to copy lots of lists, ... So I thought of using an integer instead. I could use the bits 00 (for 0) and 11 (for 1) in the vector A, and the bits 10 (for -1), 00 (for 0) and 01 (for 1) in the vector B. For the product of A and B, I would only have to calculate A & B and count the 01 and 10 blocks. Cycling can be done with shifting the vector and using masks, ... I actually implemented all this, you can find it in some of my older commits on Github. But it turned out, to be slower than with lists. I guess, pypy really optimizes list operations.

On my PC the n=12 run takes 7:25 while my C++ piece of junk takes about 1:23, which makes it about 5 times faster. With only two true cores, my CPU will gain something like a 2.5 factor compared with a mono-threaded application, so a true 8 cores CPU should run something like 3 times faster, and that's not counting with the basic mono-core speed improvement over my ageing i3-2100. Whether going through all these C++ hoops to tackle an exponentially growing computation time is worth the effort is debatable, though.

I'm getting a feeling of http://codegolf.stackexchange.com/questions/41021/find-highest-scoring-matrix-without-property-x... Would de Bruijn sequence be useful?

about multithreading, you could squeeze out a bit more of your 2+2 cores by locking each thread on one. The x2 gain is due to the scheduler shifting around your threads each time a matchstick is moved in the system. With core locking, you would probably get a x2.5 gain instead. No idea if Python allows to set processor affinity, though.

Thanks, I will look into it. But I'm pretty much a newbie in multithreading.

http://nbviewer.ipython.org/gist/minrk/5500077 has some mention of this, albeit using a different tool for the parallelism.

The pypy people would suggest not using itertools. I don't know how much of a speedup this would give however.

I don't think so. It seems quite fast. My own implementation of the product function is slower. One thing, that helps a bit. Is to store all possible vectors B and iterate over them, instead of generating them each time. It reduces the time for n = 14 from 7 minutes to 6 minutes, but it uses 500 MB RAM for each core.

How about numba or cython next?

I suspect you could speed up your inner loop by generating the true B vector (your B variable is actually what Lembik calls Bpre) and iterate over it in a single run. That would reduce indice computation somewhat.

It also seems to me that you would gain quite a bit by interverting the A and B loops, since B computation is the slowest process (you don't want to recompute all B values for each A group). That would probably dispense you of pre-computing the huge B range for equivalent performances.

I actually did a few improvements regarding iterating over the B-loop. I now can do n=15 in 9 minutes on my laptop. Haven't published the changes though.

You may be able to do some bittricks to speed up the inner products themselves. Maybe something like http://stackoverflow.com/questions/19732598/fast-inner-product-of-ternary-vectors ?

Your A-dependent B optimization is very clever and promising. Instead of relying on a brute-force contest where C++ is bound to win, it would be interesting to let the program output the number of inner products actually computed. That would be a pretty reliable metric to compare the optimizations. What do you think?

Thanks for this! I can't test it now but I will do it as soon as possible tomorrow.

@kuroineko That's a very nice idea indeed.

@Jakube now you've done it... I simply must teach your trick to my woolly bully :)

woolly bully - C++  - way too slow
Well since a better programmer took on the C++ implementation, I'm calling quits for this one.
#include <cstdlib>
#include <cmath>
#include <vector>
#include <bitset>
#include <future>
#include <iostream>
#include <iomanip>

using namespace std;

/*
6^^n events will be generated, so the absolute max
that can be counted by a b bits integer is
E(b*log(2)/log(6)), i.e. n=24 for a 64 bits counter

To enumerate 3 possible values of a size n vector we need
E(n*log(3)/log(2))+1 bits, i.e. 39 bits
*/
typedef unsigned long long Counter; // counts up to 6^^24

typedef unsigned long long Benumerator; // 39 bits
typedef unsigned long      Aenumerator; // 24 bits

#define log2_over_log6 0.3869

#define A_LENGTH ((size_t)(8*sizeof(Counter)*log2_over_log6))
#define B_LENGTH (2*A_LENGTH)

typedef bitset<B_LENGTH> vectorB;

typedef vector<Counter> OccurenceCounters;

// -----------------------------------------------------------------
// multithreading junk for CPUs detection and allocation
// -----------------------------------------------------------------
int number_of_CPUs(void)
{
    int res = thread::hardware_concurrency();
    return res == 0 ? 8 : res;
}

#ifdef __linux__
#include <sched.h>
void lock_on_CPU(int cpu)
{
    cpu_set_t mask;
    CPU_ZERO(&mask);
    CPU_SET(cpu, &mask);
    sched_setaffinity(0, sizeof(mask), &mask);
}
#elif defined (_WIN32)
#include <Windows.h>
#define lock_on_CPU(cpu) SetThreadAffinityMask(GetCurrentThread(), 1 << cpu)
#else
// #warning is not really standard, so this might still cause compiler errors on some platforms. Sorry about that.
#warning "Thread processor affinity settings not supported. Performances might be improved by providing a suitable alternative for your platform"
#define lock_on_CPU(cpu)
#endif

// -----------------------------------------------------------------
// B values generator
// -----------------------------------------------------------------
struct Bvalue {
    vectorB p1;
    vectorB m1;
};

struct Bgenerator {
    int n;                 // A length
    Aenumerator stop;      // computation limit
    Aenumerator zeroes;    // current zeroes pattern
    Aenumerator plusminus; // current +1/-1 pattern
    Aenumerator pm_limit;  // upper bound of +1/-1 pattern

    Bgenerator(int n, Aenumerator start=0, Aenumerator stop=0) : n(n), stop(stop)
    {
        // initialize generator so that first call to next() will generate first value
        zeroes    = start - 1;
        plusminus = -1;
        pm_limit  = 0;
    }

    // compute current B value
    Bvalue value(void)
    {
        Bvalue res;
        Aenumerator pm = plusminus;
        Aenumerator position = 1;
        int i_pm = 0;
        for (int i = 0; i != n; i++)
        {
            if (zeroes & position)
            {
                if (i_pm == 0)  res.p1 |= position; // first non-zero value fixed to +1
                else
                {
                    if (pm & 1) res.m1 |= position; // next non-zero values
                    else        res.p1 |= position;
                    pm >>= 1;
                }
                i_pm++;
            }
            position <<= 1;
        }
        res.p1 |= (res.p1 << n); // concatenate 2 Bpre instances
        res.m1 |= (res.m1 << n);
        return res;
    }

    // next value
    bool next(void)
    {
        if (++plusminus == pm_limit)
        {
            if (++zeroes == stop) return false;
            plusminus = 0;
            pm_limit = (1 << vectorB(zeroes).count()) >> 1;
        }
        return true;
    }

    // calibration: produces ranges that will yield the approximate same number of B values
    vector<Aenumerator> calibrate(int segments)
    {
        // setup generator for the whole B range
        zeroes = 0;
        stop = 1 << n;
        plusminus = -1;
        pm_limit = 0;

        // divide range into (nearly) equal chunks
        Aenumerator chunk_size = ((Aenumerator)pow (3,n)-1) / 2 / segments;

        // generate bounds for zeroes values
        vector<Aenumerator> res(segments + 1);
        int bound = 0;
        res[bound] = 1;
        Aenumerator count = 0;
        while (next()) if (++count % chunk_size == 0) res[++bound] = zeroes;
        res[bound] = stop;
        return res;
    }
};

// -----------------------------------------------------------------
// equiprobable A values merging
// -----------------------------------------------------------------
static char A_weight[1 << A_LENGTH];
struct Agroup {
    vectorB value;
    int     count;
    Agroup(Aenumerator a = 0, int length = 0) : value(a), count(length) {}
};
static vector<Agroup> A_groups;

Aenumerator reverse(Aenumerator n) // this works on N-1 bits for a N bits word
{
    Aenumerator res = 0;
    if (n != 0) // must have at least one bit set for the rest to work
    {
        // construct left-padded reverse value
        for (int i = 0; i != 8 * sizeof(n)-1; i++)
        {
            res |= (n & 1);
            res <<= 1;
            n >>= 1;
        }

        // shift right to elimitate trailing zeroes
        while (!(res & 1)) res >>= 1;
    }
    return res;
}

void generate_A_groups(int n)
{
    static bitset<1 << A_LENGTH> lookup(0);
    Aenumerator limit_A = (Aenumerator)pow(2, n);
    Aenumerator overflow = 1 << n;
    for (char & w : A_weight) w = 0;

    // gather rotation cycles
    for (Aenumerator a = 0; a != limit_A; a++)
    {
        Aenumerator rotated = a;
        int cycle_length = 0;
        for (int i = 0; i != n; i++)
        {
            // check for new cycles
            if (!lookup[rotated])
            {
                cycle_length++;
                lookup[rotated] = 1;
            }

            // rotate current value
            rotated <<= 1;
            if (rotated & overflow) rotated |= 1;
            rotated &= (overflow - 1);
        }

        // store new cycle
        if (cycle_length > 0) A_weight[a] = cycle_length;
    }

    // merge symetric groups
    for (Aenumerator a = 0; a != limit_A; a++)
    {
        // skip already grouped values
        if (A_weight[a] == 0) continue;

        // regroup a symetric pair
        Aenumerator r = reverse(a);
        if (r != a)
        {
            A_weight[a] += A_weight[r];
            A_weight[r] = 0;
        }
    }

    // generate groups
    for (Aenumerator a = 0; a != limit_A; a++)
    {
        if (A_weight[a] != 0) A_groups.push_back(Agroup(a, A_weight[a]));
    }
}

// -----------------------------------------------------------------
// worker thread
// -----------------------------------------------------------------
OccurenceCounters solve(int n, int index, Aenumerator Bstart, Aenumerator Bstop)
{
    OccurenceCounters consecutive_zero_Z(n, 0);  // counts occurences of the first i terms of Z being 0

    // lock on assigned CPU
    lock_on_CPU(index);

    // enumerate B vectors
    Bgenerator Bgen(n, Bstart, Bstop);
    while (Bgen.next())
    {
        // get next B value
        Bvalue B = Bgen.value();

        // enumerate A vector groups
        for (const auto & group : A_groups)
        {
            // count consecutive occurences of inner product equal to zero
            vectorB sliding_A(group.value);
            for (int i = 0; i != n; i++)
            {
                if ((sliding_A & B.p1).count() != (sliding_A & B.m1).count()) break;
                consecutive_zero_Z[i] += group.count;
                sliding_A <<= 1;
            }
        }
    }
    return consecutive_zero_Z;
}

// -----------------------------------------------------------------
// main
// -----------------------------------------------------------------
#define die(msg) { cout << msg << endl; exit (-1); }

int main(int argc, char * argv[])
{
    int n = argc == 2 ? atoi(argv[1]) : 16; // arbitray value for debugging
    if (n < 1 || n > 24) die("vectors of lenght between 1 and 24 is all I can (try to) compute, guv");

    auto begin = time(NULL);

    // one worker thread per CPU
    int num_workers = number_of_CPUs();

    // regroup equiprobable A values
    generate_A_groups(n);

    // compute B generation ranges for proper load balancing
    vector<Aenumerator> ranges = Bgenerator(n).calibrate(num_workers);

    // set workers to work
    vector<future<OccurenceCounters>> workers(num_workers);
    for (int i = 0; i != num_workers; i++)
    {
        workers[i] = async(
            launch::async, // without this parameter, C++ will decide whether execution shall be sequential or asynchronous (isn't C++ fun?).
            solve, n, i, ranges[i], ranges[i+1]);
    }

    // collect results
    OccurenceCounters result(n + 1, 0);
    for (auto& worker : workers)
    {
        OccurenceCounters partial = worker.get();
        for (size_t i = 0; i != partial.size(); i++) result[i] += partial[i]*2; // each result counts for a symetric B pair
    }
    for (Counter & res : result) res += (Counter)1 << n; // add null B vector contribution
    result[n] = result[n - 1];                           // the last two probabilities are equal by construction

    auto duration = time(NULL) - begin;

    // output
    cout << "done in " << duration / 60 << ":" << setw(2) << setfill('0') << duration % 60 << setfill(' ')
        << " by " << num_workers << " worker thread" << ((num_workers > 1) ? "s" : "") << endl;
    Counter events = (Counter)pow(6, n);
    int width = (int)log10(events) + 2;
    cout.precision(5);
    for (int i = 0; i <= n; i++) cout << setw(2) << i << setw(width) << result[i] << " / " << events << " " << fixed << (float)result[i] / events << endl;

    return 0;
}

Building the executable
It's a standalone C++11 source that compiles without warnings and runs smoothly on:

Win7 & MSVC2013
Win7 & MinGW - g++4.7
Ubuntu & g++4.8 (in a VirtualBox VM with 2 CPUs allocated)

If you compile with g++, use : g++ -O3 -pthread -std=c++11
forgetting about -pthread will produce a nice and friendly core dump.
Optimizations

The last Z term is equal to the first (Bpre x A in both cases), so the last two results are always equal, which dispenses of computing the last Z value.
The gain is neglectible, but coding it costs nothing so you might as well use it.
As Jakube discovered, all cyclic values of a given A vector produce the same probabilities.
You can compute these with a single instance of A and multiply the result by the number of its possible rotations. Rotation groups can easily be pre-computed in a neglectible amount of time, so this is a huge net speed gain.
Since the number of permutations of an n length vector is n-1, the complexity drops from o(6n) to o(6n/(n-1)), basically going a step further for the same computation time.
It appears pairs of symetric patterns also generate the same probabilities. For instance, 100101 and 101001.
I have no mathematical proof of that, but intuitively when presented with all possible B patterns, each symetric A value will be convoluted with the corresponding symetric B value for the same global outcome.
This allows to regroup some more A vectors, for an approximative 30% reduction of A groups number.
WRONG For some semi-mysterious reason, all patterns with only one or two bits set produce the same result. This does not represent that many distinct groups, but still they can be merged at virtually no cost.
The vectors B and -B (B with all components multiplied by -1) produce the same probabilities.
(for instance [ 1, 0,-1, 1] and [-1, 0, 1,-1]).
Except for the null vector (all components equal to 0), B and -B form a pair of distinct vectors.
This allows to cut the number of B values in half by considering only one of each pair and multiplying its contribution by 2, adding the known global contribution of null B to each probability only once.

How it works
The number of B values is huge (3n), so pre-computing them would require indecent amounts of memory, which would slow down computation and eventually exhaust available RAM.
Unfortunately, I could not find a simple way of enumerating the half set of optimized B values, so I resorted to coding a dedicated generator.
The mighty B generator was a lot of fun to code, though languages that support yield mechanisms would have allowed to program it in a much more elegant way.
What it does in a nutshell is consider the "skeleton" of a Bpre vector as a binary vector where 1s represent actual -1 or +1 values.
Among all these +1/-1 potential values, the first one is fixed to +1 (thus selecting one of the possible B/-B vector), and all remaining possible +1/-1 combinations are enumerated.
Lastly, a simple calibration system ensures each worker thread will process a range of values of approximately the same size.
A values are heavily filtered for regrouping in equiprobable chunks.
This is done in a pre-computing phase that brute-force examines all possible values.
This part has a neglectible O(2n) execution time and does not need to be optimized (the code being already unreadable enough as it is!).
To evaluate the inner product (which needs only be tested against zero), the -1 and 1 components of B are regrouped into binary vectors.
The inner product is null if (and only if) there is an equal number of +1s and -1s among the B values corresponding to non-zero A values.
This can be computed with simple masking and bit count operations, helped by std::bitset that will produce reasonably efficient bit count code without having to resort to ugly intrinsic instructions.
The work is equally divided among cores, with forced CPU affinity (every little bit helps, or so they say).
Example result
C:\Dev\PHP\_StackOverflow\C++\VectorCrunch>release\VectorCrunch.exe 16
done in 8:19 by 4 worker threads
 0  487610895942 / 2821109907456 0.17284
 1   97652126058 / 2821109907456 0.03461
 2   20659337010 / 2821109907456 0.00732
 3    4631534490 / 2821109907456 0.00164
 4    1099762394 / 2821109907456 0.00039
 5     302001914 / 2821109907456 0.00011
 6     115084858 / 2821109907456 0.00004
 7      70235786 / 2821109907456 0.00002
 8      59121706 / 2821109907456 0.00002
 9      56384426 / 2821109907456 0.00002
10      55686922 / 2821109907456 0.00002
11      55508202 / 2821109907456 0.00002
12      55461994 / 2821109907456 0.00002
13      55451146 / 2821109907456 0.00002
14      55449098 / 2821109907456 0.00002
15      55449002 / 2821109907456 0.00002
16      55449002 / 2821109907456 0.00002

Performances
Multithreading should work perfectly on this, though only "true" cores will fully contribute to computation speed. My CPU has only 2 cores for 4 CPUs, and the gain over a single-threaded version is "only" about 3.5.
Compilers
An initial problem with multithreading led me to believe the GNU compilers were performing worse than Microsoft.
After more thorough testing, it appears g++ wins the day yet again, producing approximatively 30% faster code (the same ratio I noticed on two other computation-heavy projects).
Notably, the std::bitset library is implemented with dedicated bit count instructions by g++ 4.8, while MSVC 2013 uses only loops of conventional bit shifts.
As one could have expected, compiling in 32 or 64 bits makes no difference.
Further refinements
I noticed a few A groups producing the same probabilities after all the reduction operations, but I could not identify a pattern that would allow to regroup them.
Here are the pairs I noticed for n=11:
  10001011 and 10001101
 100101011 and 100110101
 100101111 and 100111101
 100110111 and 100111011
 101001011 and 101001101
 101011011 and 101101011
 101100111 and 110100111
1010110111 and 1010111011
1011011111 and 1011111011
1011101111 and 1011110111

I think the last two probabilities should always be the same. This is because the n+1th inner product is actually the same as the first one.

What I meant was that the first n inner products are zero if and only if the first n+1 are.  The very last inner product doesn't provide any new information as you have already done it before. So the number of strings that give n zero products is exactly the same as the number that give n+1 zero products.

Out of interest, what were you computing instead exactly?

Thanks for the update but I don't understand the line "0 2160009216 2176782336". What exactly are you counting in this case?  The probability that the first inner product is zero is much smaller than that.

Could you give some advice on how to compile and run this? I tried g++ -Wall -std=c++11 kuroineko.cpp -o kuroineko and ./kuroineko 12 but it gives
terminate called after throwing an instance of 'std::system_error'   what():  Unknown error -1 Aborted (core dumped)

I ran it through gdb where you get a little more info. It might be worth pasting the output of that too to the SO question.

g++ -Wall kuroineko.cpp -O3 -pthread -std=c++11 -o kuroineko works.

yep, pthread was the culprit... Out of curiosity, does the Linux executable use all 8 of your cores, and how far does it go compared with the python code?

@Sp3000 That seems very odd: on my vintage i3-2100 n=13 takes only a bit more than 5 minutes. What compiler and options did you use?

k, on my Windows 8 four core laptop C++ took 6:32 for n = 13, and Jakube's previous version took 42 min.

Can you just turn the #error to a #warning and define lock_on_core() to be no-op? This allows the code be compiled on OS X.

@KennyTM That should be fixed (along with the infuriating multithreading issue, by the way).

All cores being used now.  I don't have 8 real cores either of course.

Your further refinements part is intriguing. If you group B instead of A, do you see similar patterns?

B vectors are more complicated to observe. Detecting symetries in a binary vector is much simpler than in a 3-valued one. I'll see if I can come up with a representation that can allow "visual" recognition, but I'm not sure that will be either easy or even possible

Also bear in mind that the "symetric" patterns are only representatives of their whole rotation group. It does not seem the mysterious remaining equiprobable vector pairs are reductible by rotation+symetry, though.

I would be interested to know, if you look at all B's with the same number of 1s and -1s, how many different groups do you get?  Say you have 6 1s, 6 -1s and 4 0s, say.

Mmmm.. I see. That should be doable, with a bit of time and efforts :)

B = -B is a brilliant idea. Already implemented ;-)

Your current example output is wrong. The correct data should be http://pastebin.com/BXX4hC1c

Yep, seems like the empiric "2 bits A patterns all produce the same result" rule holds true only until n=15 :). Should be OK now. Thanks for the check.

Don't give up now!  I really like your observations and I am excited you could make more. (I think -mpopcnt is also a big speedup if you can use that.)

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Sum the time durations
Challenge
Write the shortest code that can sum all the time durations that appear in the stdin. The program must only consider the strings that match with one of the following patterns and ignore the rest.
    HH:MM:SS     (it will be interpreted as HH hours, MM minutes and SS seconds)
    H:MM:SS      (it will be interpreted as H hours, MM minutes and SS seconds)
    MM:SS        (it will be interpreted as MM minutes, SS seconds)
    M:SS         (it will be interpreted as M minutes, SS seconds)

examples of strings that match with the enumerated patterns:
    12:00:01
    2:03:22
    00:53
    9:13

The output should be of the form
    HHh MMm SSs      (that means HH hours, MM minutes and SS seconds with non-zero-padding)

Example
STDIN

View the Welcome video.
    Video: 10:37 min.
  View the video introduction to the course.
    Video: 3:30 min.
  View the video of how to use the Lesson Overview.
    Video: 9:13 min.
  View the video overview of how to use the Epsilen system to share your work.
    Video: 03:15 min.
  View the video to learn about the State of Texas Assessment of Academic Readiness (STAAR).
    Video: 1:05:26 min.

STDOUT

1h 32m 1s

What about strings like 10:4:56? According current specification they have to be treated as 4m 56s, part 10 will be ignored. Same question about 10:12:7 does it mean 10m 12s with ignoring of 7? Or handling of such strings can be implementation defined?

The program should only consider time durations with zero-padding in the minute and second fields. In your example the string "10:4:56" will be treated as 4m 56s. Also the string "10:12:7" will be interpreted as 10m 12s.

Strange, but ok :)

How did you get 1h 19m 18s in the output? 37+30+13+15+26==121, 10+3+9+3+5==30, 1==1, so I expect 1h 32m 01s. What's wrong in this logic? Also, such output format is that one which is expected, isn't it?

You are right. Sorry :S

time is a special topic to me... I love this question!

Pyth 105
K"smh"J"\D\D+|\d+:(?=\d:)|:\d\D"W:QJ1=Q:QJd;FN_msdCfn2lTm+*]0</k\:2msbck\:cQ)~k+d+hK_`%+NZ60=Z/N60=KtK;_k

Try it online.
This requires input from STDIN in the same way that the Javascript answer does, as quoted text with newlines as \ns.
Sample:
"View the Welcome video.\nVideo: 10:37 min.\nView the video introduction to the course.\nVideo: 3:30 min. View the video of how to use the Lesson Overview.\nVideo: 9:13 min.\nView the video overview of how to use the Epsilen system to share your work.\nVideo: 03:15 min.\nView the video to learn about the State of Texas Assessment of Academic Readiness (STAAR).\nVideo: 1:05:26 min."

Output
1h 32m 1s

Example working with weirder dates:
"10:10:5 and 5:1:10 and 27 or 16: or 1:1:1 or 11:1\n"

Output
0h 11m 20s

(Only the 10:10 and the 1:10 are legitimate times)
The main reason that this is so long is that Pyth won't let you extract positive matches. This instead matches everything that isn't a valid time, and replaces it with a space character. Then, splitting on whitespace leaves only times and some wayward numbers. The excess numbers are removed by checking for : characters, which will have been removed from non-valid times. This could almost certainly be golfed further ;)

Lucky bastard that Pyth has regex too!

@Optimizer :D It was a real pain though. I'm thinking of suggesting changing the "is match" behaviour to change based on the arg you give it (currently it only checks that it is a non-string)

Javascript ES6, 138 chars
Function, 139
Takes string as an argument and writes output to console:
f=s=>(r=0,s.replace(/(\d\d?):(\d\d)(:(\d\d))?/g,(m,a,b,x,c)=>r+=x?+c+b*60+a*3600:+b+a*60),console.log("%dh %dm %ds",r/3600,r%3600/60,r%60))

Program, 138
prompt(r=0).replace(/(\d\d?):(\d\d)(:(\d\d))?/g,(m,a,b,x,c)=>r+=x?+c+b*60+a*3600:+b+a*60),console.log("%dh %dm %ds",r/3600,r%3600/60,r%60)

Test for function
f("View the Welcome video.\n\
Video: 10:37 min.\n\
View the video introduction to the course.\n\
Video: 3:30 min. View the video of how to use the Lesson Overview.\n\
Video: 9:13 min.\n\
View the video overview of how to use the Epsilen system to share your work.\n\
Video: 03:15 min.\n\
View the video to learn about the State of Texas Assessment of Academic Readiness (STAAR).\n\
Video: 1:05:26 min.")

Output
"1h 32m 1s"

Ok. Works fine in Firefox Developer Edition 36.0a2, formatting fails only in Firefox 34.0.

Promt doesn't allow multiline strings. But I can add version with prompt() call in same number of chars :) I even shorten it 1 symbol)))

@Optimizer How to enter them?

@Optimizer Inserting a new line doesn't work in my FF 35.0.

I cannot get it to work. I tried it on ideone.com
http://ideone.com/56EHgV

@AlfredoDiaz Just run it in Firefox 35+ console.

@Qwertiy Yes. It works even in my Firefox 33 console :)

JavaScript, ES6, 208 200 197 bytes
I know this is super long, but I wanted to explore the latest features of ES6, reverse, map-reduce, arrow functions and array comprehension (spread operator).

alert(prompt().match(/\d\d?:\d\d(:\d\d)?/g).map(x=>[...x.split(":").reverse(),z=0].slice(0,3)).reduce((a,b)=>b.map((y,i)=>+y+ +a[i])).map((x,i)=>(z=(t=x+z|0)/60,t%60+"smh"[i])).reverse().join(" "))

Just run the snippet in a latest Firefox.
How it works (ungolfed a bit)
alert(                              // Alert the final result
  prompt()                          // Take the input via prompt
  .match(/\d\d?:\d\d(:\d\d)?/g)     // Match only correct time formats
  .map(                             // Map all matches using this method
    x=>[                            // Take each element as argument x
      ...x.split(":").reverse(),    // split x on ":" and reverse the array, then spread it
      z=0                           // put 0 as last element of return array
    ].slice(0,3)                    // Take only first 3 elements of the array
  ).reduce(                         // Reduce the result using this method
    (a,b)=>                         // Pairwise elements of the array
    b.map(                          // Map array b
      (y,i)=>~~y+~~a[i]             // Convert b[i] to b[i]+a[i]
    )                               // Now we have array like [SS, MM, HH]
  ).map(                            // Map these three values for carry over calculation
    (x,i)=>(
      t=x+z,                        // z contains carryover amount, add it to this value
      z=(t/60)|0,                   // Carryover is now floor(t/60)
      t%60+"smh"[i]                 // Remove overflow from t and add "s", "m" or "h"
    )                               // Now we have array like ["SSs", "MMm", "HHh"]
  ).reverse().join(" ")             // Reverse it and join by space
)

Bash (with grep, sed, awk and date): 124 bytes, 120 bytes
Just pipe the text into this:
grep -o '[:0-9]*'|sed 's/^[^:]*:[^:]*$/:\0/'|awk -F: '{T+=3600*$1+60*$2+$3}END{print"@"T}'|xargs date +"%Hh %Mm %Ss" -ud

How it works

grep: outputs strings from the input containing only 0123456789:
sed: turns MM:SS and M:SS into :M:SS
awk: calculates the seconds, empty string is 0
xargs: passes input as argument to date
date: converts seconds since epoch (prefixed with @) to the required format

Isn't this hour related to your timezone?

You are right, nice catch :) Added -u flag.

Perl - 228 201
use integer;$h=0,$m=0,$s=0;while(<>){if(/(\d+:){1,2}\d+/){@a=reverse(split(/:/,$&));push @a,(0)x(3-@a);$s+=@a[0];$m+=@a[1];$h+=@a[2];}}$m+=$s/60;$s=$s%60;$h+=$m/60;$m=$m%60;print $h."h ".$m."m ".$s."s"

It happens to be the same algorithm as Optimizer's (grep,split,reverse,add).
I am no Perl expert, so maybe the byte count can be reduced.
Ungolfed
use integer;                              # will do integer division
$h=0,$m=0,$s=0;
while(<>){
    if(/(\d+:){1,2}\d+/) {                # extract date formats
        @a = reverse(split(/:/,$&));      # split by ":" and reverse
        push @a,(0)x(3-@a);               # pad with zeros (minutes and hours)
        $s+=@a[0];                        # sum seconds
        $m+=@a[1];                        # sum minutes
        $h+=@a[2];                        # sum hours
    }
}

# convert seconds as minutes
$m += $s / 60;
$s = $s % 60;

# convert minutes as hours
$h += $m / 60;
$m = $m % 60;

print $h."h ".$m."m ".$s."s";

As for me, it's strange to see perl solution longer than javascript one :)

Well, if even the shebang is counted, is normal to be longer.

@Qwertiy I agree. My hope is that some Perl guru will help me fix that.

@manatwork Why does it count?

@Qwertiy, because coredump forgotten to exclude it from the count. :S Could be just removed (together with all those my keywords).

@manatwork Removed, thanks.

Rebol - 174
n: charset"1234567890"a:[1 2 n]b:[":"2 n]c: 0 parse input[any[copy x[a b b](c: c + do x)| copy x[a b](c: c + do join"0:"x)| skip]]print reword"$1h $2m $3s"[1 c/1 2 c/2 3 c/3]

Ungolfed + annotated:
n: charset "1234567890"                      ; setup \d regex equiv
a: [1 2 n]                                   ; parse rule for \d{1,2}
b: [":" 2 n]                                 ; parse rule for :\d\d
c: 0                                         ; time counter

parse input [                                ; parse the input (STDIN)
                                             ; (no regex in Rebol)

  any [                                      ; match zero or more...
                                             ;
      copy x [a b b] (c: c + do x)           ;  HH:MM:SS or H:MM:SS
                                             ;    - copy match to x
                                             ;    - increment time (c) by x
                                             ; OR
    | copy x [a b] (c: c + do join "0:" x)   ;  MM:SS or M:SS
                                             ;    - copy match to x
                                             ;    - "MM:SS" into "0:MM:SS" (join)
                                             ;    - then increment time (c)
                                             ; OR
    | skip                                   ;   no match so move through input
  ]
]

print reword "$1h $2m $3s" [1 c/1 2 c/2 3 c/3]

Rebol comes with its own time! datatype.   You can see how the above code makes use of this from example below (from within the Rebol console):
>> 0:10:37 + 0:3:30 + 0:9:13 + 0:3:15 + 1:05:26
== 1:32:01

;; Rebol would treat 10:37 as 10 hours & 37 minutes (and not MM:SS)
;; So we have to prefix the "0:"

>> join "0:" 10:37
== "0:10:37"

;; This is a string so we use Rebol DO evaluator to convert to time!

>> do join "0:" 10:37
== 0:10:37

>> type? do join "0:" 10:37
== time!

>> hms: do join "0:" 10:37
== 0:10:37

>> hms/hour
== 0

>> hms/second
== 37

>> hms/minute
== 10

Groovy - 195
M=60
r=(System.in.text=~/((\d?\d):)?(\d\d):(\d\d)/).collect{it[2..4]*.toInteger().inject{s,i->(s?:0)*M+i}}.inject{s,i->s+=i}
f=[];(2..0).each{j=M**it;s=r%j;f<<(r-s)/j;r=s}
printf("%sh %sm %ss",f)

I can't figure out how to compress it more.
Ungolfed
M=60
r=(System.in.text=~/((\d?\d):)?(\d\d):(\d\d)/).collect{  // extract dates
    it[2..4]*.toInteger().inject{ s,i ->                 // convert to seconds
        (s?:0)*M+i
    }
}.inject{s,i ->
    s+=i                                                 // sum seconds
}

f=[];
(2..0).each{                                             // convert to h,m,s
    j=M**it;
    s=r%j;
    f<<(r-s)/j;
    r=s
}

printf("%sh %sm %ss",f)

Mathematica 300 chars
This little exercise took up a lot of code, even for Mathematica.
Surely there are more efficient ways to do this.
Golfed
Assuming that the input is stored in txt,
n=NumberString;
t=ToExpression;
o=TimeObject;

QuotientRemainder[QuantityMagnitude[Plus@@((o[#]-o[{0,0,0}])&/@
(StringSplit[StringCases[w,{(n~~":"~~n~~":"~~n),(n~~":"~~n)}],":"]
/.{{a_,b_}:> {0,t@a,t@b},{a_,b_,c_}:> {t@a,t@b,t@c}}))],60]/.{h_,m_}:>
Row[{h,"h ",IntegerPart@m,"m ",Round[60 FractionalPart[m]],"s "}]

How it works (using unGolfed code):
1-Find the times.
StringCases[txt,{(NumberString~~":"~~NumberString~~":"~~NumberString),
(NumberString~~":"~~NumberString)}];

{"10:37", "3:30", "9:13", "03:15", "1:05:26"}

2-Break into hours, minutes, seconds
StringSplit[%,":"]/.{{a_,b_}:> {0,ToExpression@a,ToExpression@b},{a_,b_,c_}:>
{ToExpression@a,ToExpression@b,ToExpression@c}}

{{0, 10, 37}, {0, 3, 30}, {0, 9, 13}, {0, 3, 15}, {1, 5, 26}}

3-Sum the times.  Time objects are clock times. Subtracting one time object from another returns a duration, in this case 92.0167 minutes.  QuantityMagnitude drops the unit of measure.
q=QuantityMagnitude[Plus@@((TimeObject[#]-TimeObject[{0,0,0}])&/@%)]

92.0167

4-Convert 92.0167 minutes into hours, minutes, seconds.
QuotientRemainder[q,60]/.{h_,m_}:> Row[{h,"h ",IntegerPart@m,"m ",
Round[60 FractionalPart[m]],"s "}]

1h 32m 1s

Perl, 146
My entry prints the output with a trailing space - I hope that's ok
while(<>){for(/(\d?\d(?::\d\d){1,2})/g){$m=1;for(reverse split/:/,$_){$t+=$m*$_;$m*=60}}}for('s','m'){$o=($t%60)."$_ $o";$t/=60}print int$t,"h $o"

If we can assume there will be only one time per line of input, we can chop 4 characters:
while(<>){if(/(\d?\d(:\d\d){1,2})/){$m=1;for(reverse split/:/,$&){$t+=$m*$_;$m*=60}}}for('s','m'){$o=($t%60)."$_ $o";$t/=60}print int$t,"h $o"

These work by accumulating the total seconds elapsed and formatting that value afterwards.


text:
Find pairs of numbers with a particular LCM and GCD
I was working on a math question with a friend of mine, and we decided to write a script that finds the answer. The original question is as follows:

The difference of two natural numbers is 2010 and their greatest common denominator is 2014 times smaller than their lowest common multiply. Find all the possible solutions.

We started writing the program independently of each other, and when it worked we decided to golf it up to get the least amount of bytes we could manage. We ended up with this beautiful line of code at a marvelous 89 bytes.
from fractions import*;print[i for i in range(10**6)if i*(i+2010)/gcd(i,i+2010)**2==2014]

We wanted to see if anyone manages to write a shorter piece of code, that enumerates the first 1 million i's. If you are brave enough to compete, you may use any language you like, but we would prefer Python 2 to be able to compare your code with ours.
Usual rules apply, shortest bytes win.
The standard code golf loopholes apply. Standard "loopholes" which are no longer funny
Have fun!

@Rainbolt: Ok, allowed any language. The python limitation was for comparison purposes. But just do whatever you want :D

Are there answers other than 3 and 5092? Can't find anything else before 10,000,000.

@KennyTM: I got 4 and 5092. And yes, I dont think there are any others.

Hey, I have edited your title to better reflect what you are asking. Feel free to change it if you feel like I missed something.

Removed python tag by the way.

Nice. Your edit was so fast that it didn't even get caught in the original revision. This looks like a fun combo challenge (at least until someone proves that those two numbers are the only solution to the problem).

Can't wait to see all the 20b CJam or Pyth answers :D

How are 4 and 5092 a solution to the problem if the difference between them isn't 2010? 5092 - 4 = 5088. Is there a definition for "difference" that I don't know about?

@Rainbolt: the 4 and 5092 are not a single answer, they are the 'i' for 2 answers.

Oh duh. Thanks for clarifying.

OK I've got a mathematical proof that 4 and 5092 are the only solutions. So the question now is relying on the standard loophole to avoid trivial answers like p[4,5092].

By the way, you can get your code to 88 very easily... I'll give you a hint: multiplication is commutative ;)

Mathematica, 8 bytes
{4,5092}

Proof that 4 and 5092 are the only solutions: The original problem can be rewritten as

x (x + 2010) = 2014 GCD(x, x+2010)2

Let's write x as 2a2 3a3 5a5… and x + 2010 as 2b2 3b3 5b5… Then the equation becomes

2a2+b2 3a3+b3 5a5+b5… = 2014 22min(a2,b2) 32min(a3,b3) 52min(a5,b5)…

Since 2014 = 2 × 19 × 53, we have

ap + bp = 2min(ap, bp) + { 1 if p ∈ {2, 19, 53}, 0 else }

Thus

ap = bp if p ≠ 2, 19, 53
  ap = bp±1 else

Thus

x + 2010 = 2±1 19±1 53±1 x

There are only 8 possible choices, and we could easily check that 4 and 5092 are the only positive integer solutions.
Wait, I hear people screaming standard loophole…
Mathematica, 45 bytes
Select[Range[9^7],2014GCD[#,s=#+2010]^2==s#&]

Pyth 27 25
J2010fq+J4/*T+TJ^iTJ2U^T6

Try it online.
This uses your algorithm fairly naively... I might be able to come up with something better...
Basically filters out values that don't meet the criterion from range(10**6)
Thanks to @xnor for pointing out in chat that gcd(x,x+2010)==gcd(x,2010)

Python 3, 84 bytes
FryAmTheEggman's already suggested how to make your solution 88 bytes so I won't post that. But I thought I'd show how you can get even fewer bytes in Python 3:
from fractions import*
x=10**6
while x:y=x+2010;x*y-gcd(x,y)**2*2014or print(x);x-=1

(Thanks for FryAmTheEggman for tips)
This doesn't work in Python 2 because print's not a function.
I'm not sure if we're allowed, but if we could use 9**9 instead of 10**6 that'd be another byte.

I knew there was a way to do this with and/or... wouldn't have thought of python 3 though ;) More on topic: If order doesn't matter, I think setting x=10**6 and doing while x:x-=1;... is one byte shorter.

@FryAmTheEggman From the looks of the question it doesn't seem like order matters so I'll put that in. Thanks!

GolfScript (41 bytes)

The difference of two natural numbers is 2010 and their greatest common denominator is 2014 times smaller than their lowest common multiple. Find all the possible solutions.

Call the numbers am and bm where gcd(a, b) = 1 and wlog b > a. Then the difference is m(b-a) = 2010, and lcm(am, bm) = abm = 2014m so ab=2014.
Factors of 2014 are
1 * 2014
2 * 1007
19 * 106
38 * 53

and those which have differences that divide into 2010 are
1007 - 2 => m = 2, solution is 4, 2014
53 - 38 => m = 134, solution is 5092, 7102

Since I'm operating in a language which doesn't have built-in GCD or LCM, I think this analysis probably shortens the program:
44,{).2014{.2$/\@%!}:,~\2$- 2010,***}%0-`

where 44 is floor(sqrt(2014)).
It is possible to get quite close using a naïve loop:
10 6?,1>{.2010+.2${.@\%.}do;.*2014*@@*=},`

So @KettyTM's proof that (4,5092) is the only solution is incorrect ?

@Optimizer, you're misreading it. He also proves that there are two solutions, and they're the same as my solutions. His proof is just a lot harder to follow than mine (IMAO).

Ah, true. And yes, yours make more sense than his.

R, 75 chars
for(a in 1:1e6){q=1:a;b=a+2010;if(a*b/max(q[!a%%q&!b%%q])^2==2014)print(a)}

With line breaks:
for(a in 1:1e6){
    q=1:a
    b=a+2010
    if(a*b/max(q[!a%%q&!b%%q])^2==2014)print(a)
    }

Perl6 61 58 56 54 52
A fairly direct translation of your source gives
for ^10**6 ->\i{i.say if i*(i+2010)/(i gcd(i+2010))**2==2014}

gcd is an infix op in Perl6.
^10**6 is short for 0 ..^ 10**6, where the ^ means exclude this number from the range.

Of course i gcd (i+2010) is the same as i gcd 2010 so I can save 3 characters
for ^10**6 ->\i{i.say if i*(i+2010)/(i gcd 2010)**2==2014}

If I use $_ instead of i I can save another couple of characters. ( .say is short for $_.say )
for ^10**6 {.say if $_*($_+2010)/($_ gcd 2010)**2==2014}

I can save another couple of characters by using ... && .say instead of .say if ..., because I don't need a space on both sides of && like I do for if.
for ^10**6 {$_*($_+2010)/($_ gcd 2010)**2==2014&&.say}

Since I did both of the previous "optimizations" I can use the statement modifier form of for, which means I can remove { and }.
$_*($_+2010)/($_ gcd 2010)**2==2014&&.say for ^10**6

I think that is as short as I can go without using a different algorithm.

J, 26 bytes
   I.((*.=+.*4--)2010+])i.1e6
4 5092

Those damned 2-byte verbs... :)

Dyalog APL, 29 characters
      a←⍳10        ⍝ the integers up to 10
      a
1 2 3 4 5 6 7 8 9 10
      2010+a       ⍝ corresponding integers at distance 2010
2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
      a∨2010+a     ⍝ GCD-s between elements of a and 2010+a
1 2 3 2 5 6 1 2 3 10
      ⍝ All APL functions (e.g. + and ∨) are prefix-or-infix, right-associative,
      ⍝ and of the same precedence.
      a∧2010+a     ⍝ LCM-s
2011 2012 2013 4028 2015 2016 14119 8072 6057 2020
      ⍝ For which of them is the LCM 2014 times the GCD?
      (a∧2010+a)=2014×a∨2010+a
0 0 0 1 0 0 0 0 0 0
      ⍝ 0 means false, 1 means true
      ⍝ Filter the elements of "a" corresponding to the 1-s
      ((a∧2010+a)=2014×a∨2010+a) / a
4
      ⍝ Let's abstract this as a function by using curlies.
      ⍝ Omega (⍵) stands for the right argument.
      {((⍵∧2010+⍵)=2014×⍵∨2010+⍵) / ⍵} a
4
      ⍝ Up to a million instead of up to ten:
      {((⍵∧2010+⍵)=2014×⍵∨2010+⍵) / ⍵} ⍳1e6
4 5092
      ⍝ Hey, we can save a few characters by making 2010 the left argument, alpha (⍺)
      2010 {((⍵∧⍺+⍵)=2014×⍵∨⍺+⍵) / ⍵} ⍳1e6
4 5092
      ⍝ Remove a pair of parens by using the switch operator ⍨
      ⍝ An "operator" occurs to the right of a function and modifies its behaviour.
      ⍝ In this case A f⍨ B means the same as B f A
      ⍝ Left and right are swapped, hence "switch".
      2010 {⍵ /⍨ (⍵∧⍺+⍵)=2014×⍵∨⍺+⍵)} ⍳1e6
4 5092
      ⍝ That's 32 characters (modulo whitespace).  Not bad, but we can do better.
      ⍝ A "fork" is a sequence of 3 functions in isolation: f g h
      ⍝ It is evaluated as:  ⍺(f g h)⍵  ←→  (⍺ f ⍵)g(⍺ h ⍵)
      ⍝ If the first item is an array instead of a function: A f g  ←→  {A} f g
      ⍝ Forks are right-associative: f g h k l ←→ f g (h k l)
      2010 {⍵ /⍨ (⍺(⊢∧+)⍵)=2014×(⍺(⊢∨+)⍵)} ⍳1e6
4 5092
      ⍝ The "right tack" function (⊢) simply returns its right argument
      ⍝ Let's abuse forks a little further:
      2010 {⍵ /⍨ ⍺((⊢∧+)=(2014×(⊢∨+)))⍵} ⍳1e6
4 5092
      ⍝ ... and more
      2010 {⍺ (⊢(/⍨)((⊢∧+)=(2014×(⊢∨+)))) ⍵} ⍳1e6
4 5092
      ⍝ But {⍺ f ⍵} is equivalent to f
      2010 (⊢(/⍨)((⊢∧+)=(2014×(⊢∨+)))) ⍳1e6
4 5092
      ⍝ Note that now we are not mentioning ⍺ and ⍵ at all.
      ⍝ This is called "point-free style" or "tacit programming".
      ⍝ Removing some unnecessary parens and whitespace:
      2010(⊢(/⍨)(⊢∧+)=2014×⊢∨+)⍳1e6
4 5092
      ⍝ How many characters?
      ⍴'2010(⊢(/⍨)(⊢∧+)=2014×⊢∨+)⍳1e6'
29

PARI/GP, 42 bytes
[n|n<-[1..8!],2014*gcd(n,t=n+2010)^2==n*t]

I feel that there is an extremely elegant solution using GP's fordiv construct but it couldn't compete with this solution for sheer brevity.

Racket, 72 chars
(filter(λ(i)(=(/(*(+ i 2010)i)(expt(gcd(+ i 2010)i)2))2014))(range 1e6))

Does Racket work with ISO-8859-7? Otherwise I don't think λ counts as 1 byte.

Haskell, 52 chars
show [x|x<-[1..6^8],x*(x+2010)==2014*(gcd x 2010)^2]

Works in the Haskell interactive environment GHCi.

Jelly, 20 19 bytes
g²×⁽¥Æ=×
ȷ6ç+⁽¥µ$$Ƈ

Try it online!
The TIO link has been modified to only search up to \$10^4\$, as the outputs are both below that, in order to finish within 60 seconds on TIO.
And of course, the "cheaty method" is that, as \$4\$ and \$5092\$ are the only two integers (as proven by kennytm) for which this is true, this 5 byter works:
4,⁽Ñ[

Try it online!
How it works
g²×⁽¥Æ=× - Helper link. Takes n on the left and n+2010 on the right
g        - gcd(n, n+2010)
 ²       - gcd(n, n+2010)²
   ⁽¥Æ   - Compressed integer; 2014
  ×      - 2014×gcd(n, n+2010)²
       × - n²+2010n
      =  - Are the two equal?

ȷ6ç+⁽¥µ$$Ƈ - Main link. Takes no input
ȷ6         - Yield 1000000
       $$Ƈ - Yield [1, 2, ..., 1000000] and keep those, i, for which the following is true:
    ⁽¥µ    -   Compressed integer; 2010
   +       -   i+2010
  ç        -   Call the helper link with i on the left and i+2010 on the right

authors: Руслан Мамедов

authors: Швеев Алексей

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Can the maze be solved?
Task

Print 0 if an n*m maze cannot be solved
Print 1 if an n*m maze can  be solved (in 1 or more ways)

(so I'm not asking for paths but if it's possible to solve!!!)
Example
Input array(2d):
[[0,0,0,0,0,0,1],[0,0,0,0,0,1,0],[0,0,0,0,1,0,0],[1,0,0,0,0,0,0]]

XXXXXXXXX
XS     XX
X     X X
X    X  X
XX     FX
XXXXXXXXX

0 = can pass through
1 = can not pass trough
[0][n] is the last block of the first line
[m][0] is the first block of the last line

Rule
The start position is 0,0 and the end position is n,m
You can only move horizontally and vertically
Shortest code wins

Should the input be a string or an array?

whatever is shorter

If there is a 1 (wall) at (n,m) should the code return 0?

(Same for a wall at (0,0)?)

You say it's a n×m maze, but your indexing implies that it's an (n+1)×(m+1) maze.

I am looking forward to the regex solution=)

Dyalog APL, 27 characters
⊃⌽∨.∧⍨⍣≡1≥+/¨|∘.-⍨,(~×⍳∘⍴)⎕
⎕ evaluated input.  APL distinguishes between a matrix and a vector of vectors.  This program assumes that the input is a matrix.
(~×⍳∘⍴)A is a fork equivalent to (~A) × ⍳⍴A.  It's needed to avoid mentioning ⎕ twice or introducing a variable.
⍴A is the shape of A.  For a 4-by-7 matrix the shape is 4 7.
⍳ is the index generator.  ⍳4 is 1 2 3 4.  ⍳4 7 is the vectors (1 1)(1 2)...(4 7) arranged in a 4-by-7 matrix.
~A flips the bits of A.
× by multiplying ⍳⍴A by the flipped bits, we preserve the coordinates of all free cells and turn all walls into 0 0.
, ravels the matrix of coordinate pairs, i.e. linearizes it into a vector.  In this case the vector will consist of pairs.
∘.-⍨A or A∘.-A subtracts elements of A pairwise.  Note that here the elements of A are themselves pairs.
| absolute value
+/¨ sum each pair of absolute values.  This gives us the grid distances between every pair of cells in the maze, save for walls.
1≥ we are only intrested in neighbours at a distance no more than 1, this also excludes walls.  Now we have a graph's adjacency matrix.
∨.∧⍨⍣≡ Floyd--Warshall's transitive closure algorithm
(f⍣n)A (not used here) where n is an integer is the power operator.  It applies f to A n times: f f ... f A.
(f⍣g)A where g is a function, is the fixed point operator, a.k.a. "power limit".  It keeps on computing the series A, f A, f f A, ... until ((f⍣i)A) g ((f⍣(i+1))A) returns true for some i.  In this case we use match (≡) as g.
∨.∧⍨A or A∨.∧A is a step in Floyd's algorithm.  f.g is a generalisation of matrix multiplication (+.×), here we use conjunction (∧) and disjunction (∨) in place of + and ×.
⊃⌽  After ⍣≡ has applied the step enough times and reached a stable state, we must look up the top-right corner of the matrix to get the result, so we flip it (⌽) and take the first, top-left item (⊃).
Visualization of ⍣≡'s steps

CJam, 42 41 39 36 35 bytes
Wq3>~_s,{{[{_2$+0<{e<_}*}*]}%z}*sW=

Based on the ideas in this answer.
4 bytes thanks to Optimizer.
Input format:
[[0 0 0 0 0 0 1] [0 0 0 0 0 1 0] [0 0 0 0 1 0 0] [1 0 0 0 0 0 0]]

@Optimizer Thanks for that. But then I found a shorter way...

q2Wts~_s,{{[{_2$+0<{e<_}*}*]}%z}*sW= - 36. Although it assumes that the first three characters of the input will be [[0

Python, 164 bytes
def s(a):
 d=[(0,0)]
 while d:i,j=d.pop();a[i][j]=2;d+=[(x,y)for x,y in[(i-1,j),(i,j-1),(i+1,j),(i,j+1)]if len(a[0])>y>-1<x<len(a)and a[x][y]<1]
 return a[-1][-1]>1

I was reluctant to post this because it's practically how I'd normally do flood fill, just lightly golfed.  But here it is anyway.

(x,y) is in [(i-1,j),(i,j-1),(i+1,j),(i,j+1)] iff abs(x-i)+abs(y-j)<2, although I'm not sure if that can help

Perl, 73 bytes
69 bytes of code + 4 bytes for -n0E (not sure how the tags where counted in 2014, so I counted them for 4 instead of 2, but it doesn't matter a lot).
/.*/;s/(^0|A)(.{@{+}})?0/A$2A/s||s/0(.{@{+}})?A/A$1A/s?redo:say/A$/+0

Try it online!
(and if you replace the 1111011 line with 1111111, the maze isn't solvable anymore, and the output will be 0 instead of 1 : Try it online!)
Explanations:
This code will find every reachable cell of the maze (and mark them with a A): if a cell touches a cell marked with a A, the it's reachable and we mark it with a A too; and we do that again (redo). That's done thanks to two regex: s/(^0|A)(.{@{+}})?0/A$2A/s checks if a space is on the right or the bottom of a A, while s/0(.{@{+}})?A/A$1A/s checks if a space is on the left or on top of a A. At the end, if the last cell contains a A it's reachable, otherwise it's not (that's what say/A$/+0 checks; the +0 is here to make sure the result will be 0 or 1 instead of empty string and 1).
Note that /.*/ will match an entire line, thus setting @+ to the index of the end of the first line, which happens to be the size of a line, which allow use to use .{@{+}} to match exactly as many character as there are on a line. (@{+} is equivalent to @+, but only the former can be used in regex)

For this test case, your code considers the maze solvable even if the final position is 1.

@Jitse Good catch. Actually, it was because the TIO links were not using the right code (I guess it was some earlier version and I didn't spot it). The answer is still valid, and I've updated the TIO links. Your example works then fine: Try it online!

Oh, right! Thanks for the clarification, I like this approach.

@Jitse thanks, that's one of my favorite golfs :)

Ruby, 133 130 129 characters
a=eval gets
f=->x,y{a[x][y]=1
[[-1,0],[1,0],[0,-1],[0,1]].map{|o|d,e=x+o[0],y+o[1]
f[d,e]if a[d]&&a[d][e]==0}}
f[0,0]
p a[-1][-1]

Input on STDIN, outputs 1 or 0 on STDOUT.
Annoyingly long. It simply does a flood-fill of 1s from (0, 0), and then checks to see whether the "end" square is a 1.

Will this treat the maze as solvable if it already contains a 1 at (n,m)?

Java, 418 bytes
import java.util.Scanner;public class Solvable{static int w,h;public static void main(String[] a){String[]i=new Scanner(System.in).nextLine().split(";");h=i.length+2;w=i[0].length()+2;int[]m=new int[w * h];for(int x=1;x<w-1;x++)for(int y=1;y<h-1;y++)m[y*w+x]=i[y-1].charAt(x-1)<'.'?0:1;f(m,w+1);System.out.println(m[w*h-w-2]>0?0:1);}static void f(int[]m,int i){if(m[i]>0){m[i]--;f(m,i-1);f(m,i+1);f(m,i-w);f(m,i+w);}}}

My first code golf. I don't know why I chose Java - it's so bad for golfing xD
Example maze would be inputted via stdin like this:
......#;.....#.;....#..;#......

Pro tip: name your class something one character long, ditch the space between String[] and a, and take input from command line arguments rather than StdIn, which is allowed.

Python 184 188
def f(a,x=0,y=0,h=[]):s=h+[[x,y]];X,Y=len(a[0]),len(a);return([x,y]in h)==(x>=X)==(y>=Y)==(x<0)==(y<0)==a[y][x]<(x==X-1and y==Y-1or f(a,x-1,y,s)|f(a,x+1,y,s)|f(a,x,y-1,s)|f(a,x,y+1,s))

This got much longer than I thought it would be :( Anyway, I'll add an explanation once I can't golf it any longer.

J, 75 chars
Powering of the adjacency matrix (very time and memory inefficient). (Is it called powering in English?)
   ({.@{:@(+./ .*.^:_~)@(+:/~@,*2>(>@[+/@:|@:->@])"0/~@,@(i.@#<@,"0/i.@#@|:)))

Some test cases:
   m1=. 0 0 0 0 0 0 1,. 0 0 0 0 0 1 0,.  0 0 0 0 1 0 0,. 1 0 0 0 0 0 0
   m2=. 0 1 1 ,. 0 0 0
   m3=. 0 1 0 ,. 1 1 0
   m4=. 0 1 1 0 ,. 0 0 1 0
   ({.@{:@(+./ .*.^:_~)@(+:/~@,*2>(>@[+/@:|@:->@])"0/~@,@(i.@#<@,"0/i.@#@|:))) every m1;m2;m3;m4
1 1 0 0

Python 3, 136 bytes
def f(g,x=0,*p):w=len(g[0])+1;l=w*len(g);return~x%w*(-1<x<l)*~-(x in p)and any(g[x//w][x%w]and f(g,x+a,*p,x)for a in(1,-1,w,-w))or-~x==l

Try it online!
Uses 0 for wall, 1 for free space.
Port of my answer to Find the shortest route on an ASCII road.

Python 3, 184 bytes
f=lambda m,x=0,y=0,n=0:n<len(m)*len(m[0])and m[x][y]<1and((x,y)==(len(m)-1,len(m[0])-1)or any(0<=i<len(m)and 0<=j<len(m[0])and f(m,i,j,n+1)for i,j in[(x-1,y),(x,y-1),(x+1,y),(x,y+1)]))

Try it online!