JSFiddle - React, Tailwind, and code Playground
HTML
find_paths_from_to_with_length(from, to, i):
if i == 1:
if to in neighbors(from) or from == to:
return [[(from, to)]]
return []
all_paths = []
for node in neighbors(from) + [from]:
neighbor_all_paths = find_paths_from_to_with_length(node, to, i - 1)
for path in neigbor_all_paths:
all_paths.append([(from, node)] + neighbor_path
return all_paths
CoffeeScript
t = (p) ->
h = (x) -> -1 != p.indexOf x
s = (x) -> 0 == p.indexOf x
if h "XXXXXXXXXXXX" then "APL" # note that APL does not work on jsFiddle
else if h "<?php" then "PHP"
else if h("<?xml") and h "<html" then "XHTML"
else if h "<html" then "HTML"
else if h "<?xml" then "XML"
else if h("jQuery") or h "document.get" then "JavaScript"
else if h "def __init__(self" then "Python"
else if h "\\documentclass" then "TeX"
else if h("java.") or h "public class" then "Java"
else if s("SELE") or s("UPDATE") or s "DELE" then "SQL"
else if /[-\+\.,\[\]\>\<]{9}/.test p then "Brainfuck"
else if h "NSString" then "Objective-C"
else if h "do |" then "Ruby"
else if h("prototype") or h "$(" then "JavaScript"
else if h "(defun" then "Common Lisp"
else if /::\s*[a-z]+\s*->/i.test p then "Haskell"
else if h "using System" then "C#"
else if h "#include"
if h("iostream") or h "using namespace" then "C++"
else "C"
else "???"
$('#code').on 'keyup keydown change', -> $('#result').val t $('#code').val()