### Factorial In Javascript

Be careful! You were previously implicitly defining a global fact when you really should not have done that. A lot of these problems can be solved by including that "use strict"; at the start of a function, which is especially important when you're starting out.
Also, factorial of 0 is 1, and factorial of negatives is undefined. It's also nice to have proper indentation to make programs a little easier to read.

Code
Diff
• function factorial (n) {
"use strict";
if (n < 0) {
return NaN
}
let i, fact
i = fact = 1
while (i <= n) {
fact *= i
i++
}
return fact
}
•  1 1 function factorial (n) { 2 − if (n <= 0) return 0 3 − 4 − let i = fact = 1 2 + "use strict"; 3 + if (n < 0) { 4 + return NaN 5 + } 6 + let i, fact 7 + i = fact = 1 5 5 while (i <= n) { 6 − fact *= i 7 − i++ 9 + fact *= i 10 + i++ 8 8 } 9 9 return fact 10 − 11 11 }

### Find some confusing error messages

Mathematics
Algorithms
Numbers

What's [Z?

Code
Diff
• public class Kata {
private static Object[] root = {null,
new Object[][]{null, null, null, null, null, null, null, null, null, null, {new Boolean(true)}},
null,
null,
null,
null,
null,
null,
null,
null,
new Object[]{new Boolean(false)}
};
public static boolean isHappy(long current) {
Boolean[] result = {false};
outer:
for (; ; ) {
long next = 0;
Object[] node = root;
while (current > 0) {
int remainder = (int) (current % 10);
current /= 10;
next += remainder * remainder;
if (node[remainder] == null) {
node = (Object[]) (node[remainder] = new Object[remainder == 0 ? 10 : 11]);
while (current > 0) {
remainder = (int) (current % 10);
current /= 10;
next += remainder * remainder;
node = (Object[]) (node[remainder] = new Object[remainder == 0 ? 10 : 11]);
}
node[10] = result;
current = next;
continue outer;
}
node = (Object[]) node[remainder];
}
if (node[10] != null) {
return result[0] = (Boolean) ((Object[]) node[10])[0];
}
node[10] = result;
current = next;
}
}
}

•  1 − def is_happy(h: int) -> bool: 2 − """Returns `True` if `h` is happy, `False` otherwise.""" 3 − seen = set() 4 − while h > 1 and h not in seen: 5 − seen.add(h) 6 − tot = 0 7 − while h > 0: 8 − tot += pow(h % 10, 2) 9 − h //= 10 10 − h = tot 11 − return h == 1 1 + public class Kata { 2 + private static Object[] root = {null, 3 + new Object[][]{null, null, null, null, null, null, null, null, null, null, {new Boolean(true)}}, 4 + null, 5 + null, 6 + null, 7 + null, 8 + null, 9 + null, 10 + null, 11 + null, 12 + new Object[]{new Boolean(false)} 13 + }; 14 + public static boolean isHappy(long current) { 15 + Boolean[] result = {false}; 16 + outer: 17 + for (; ; ) { 18 + long next = 0; 19 + Object[] node = root; 20 + while (current > 0) { 21 + int remainder = (int) (current % 10); 22 + current /= 10; 23 + next += remainder * remainder; 24 + if (node[remainder] == null) { 25 + node = (Object[]) (node[remainder] = new Object[remainder == 0 ? 10 : 11]); 26 + while (current > 0) { 27 + remainder = (int) (current % 10); 28 + current /= 10; 29 + next += remainder * remainder; 30 + node = (Object[]) (node[remainder] = new Object[remainder == 0 ? 10 : 11]); 31 + } 32 + node[10] = result; 33 + current = next; 34 + continue outer; 35 + } 36 + node = (Object[]) node[remainder]; 37 + } 38 + if (node[10] != null) { 39 + return result[0] = (Boolean) ((Object[]) node[10])[0]; 40 + } 41 + node[10] = result; 42 + current = next; 43 + } 44 + } 45 + }

### Find some happiness

Mathematics
Algorithms
Numbers
Code
Diff
• def is_happy(x, *, _trie=[False,10*[False]+[[True]]]+8*[False]+[[False]]):
a = [False]
while True:
z = 0 # wasting some operations when x is in _trie. nobody cares though.
t = _trie
while x:
r = x%10
x //= 10
z += r*r
if t[r]:
t = t[r]
else:
t[r] = (11-(not r))*[False]
t = t[r]
while x:
r = x%10
x //= 10
z += r*r
t[r] = (11-(not r))*[False]
t = t[r]
break
else:
if t[10]:
a[0] = t[10][0]
return a[0]
t[10] = a
x = z

•  1 − class ref: 2 − def __init__(self, data): 3 − self.data = data 4 − 5 − def is_happy(x, *, _trie=[False,10*[False]+[ref(True)]]+8*[False]+[ref(False)]): 6 − a = ref(False) 1 + def is_happy(x, *, _trie=[False,10*[False]+[[True]]]+8*[False]+[[False]]): 2 + a = [False] 7 7 while True: 8 8 z = 0 # wasting some operations when x is in _trie. nobody cares though. 9 9 t = _trie 10 10 while x: 11 11 r = x%10 12 − if not t[r]: 13 − t[r] = (11-(not r))*[False] 14 − t = t[r] 15 15 x //= 10 16 − z += r**2 17 − if t[-1]: 18 − a.data = t[-1].data 19 − return a.data 20 − t[-1] = a 9 + z += r*r 10 + if t[r]: 11 + t = t[r] 12 + else: 13 + t[r] = (11-(not r))*[False] 14 + t = t[r] 15 + while x: 16 + r = x%10 17 + x //= 10 18 + z += r*r 19 + t[r] = (11-(not r))*[False] 20 + t = t[r] 21 + break 22 + else: 23 + if t[10]: 24 + a[0] = t[10][0] 25 + return a[0] 26 + t[10] = a 21 21 x = z

### Find some happiness

Mathematics
Algorithms
Numbers

Tries make me happy.

Code
Diff
• class ref:
def __init__(self, data):
self.data = data

def is_happy(x, *, _trie=[False,10*[False]+[ref(True)]]+8*[False]+[ref(False)]):
a = ref(False)
while True:
z = 0 # wasting some operations when x is in _trie. nobody cares though.
t = _trie
while x:
r = x%10
if not t[r]:
t[r] = (11-(not r))*[False]
t = t[r]
x //= 10
z += r**2
if t[-1]:
a.data = t[-1].data
return a.data
t[-1] = a
x = z

•  1 − def is_happy(h: int, *, _unhappy={0}, _happy={1}) -> bool: 2 − """Returns `True` if `h` is happy, `False` otherwise.""" 3 − seen = set() 1 + class ref: 2 + def __init__(self, data): 3 + self.data = data 4 + 5 + def is_happy(x, *, _trie=[False,10*[False]+[ref(True)]]+8*[False]+[ref(False)]): 6 + a = ref(False) 4 4 while True: 5 − if h in _unhappy or h in seen: 6 − _unhappy.update(seen) 7 − return False 8 − elif h in _happy: 9 − _happy.update(seen) 10 − return True 11 − seen.add(h) 12 − tot = 0 13 − while h > 0: 14 − tot += pow(h % 10, 2) 15 − h //= 10 16 − h = tot 8 + z = 0 # wasting some operations when x is in _trie. nobody cares though. 9 + t = _trie 10 + while x: 11 + r = x%10 12 + if not t[r]: 13 + t[r] = (11-(not r))*[False] 14 + t = t[r] 15 + x //= 10 16 + z += r**2 17 + if t[-1]: 18 + a.data = t[-1].data 19 + return a.data 20 + t[-1] = a 21 + x = z

### Rainbow Indentation

Simple rainbow indentation, like you would use when writing in Python.
The second version is actually quite pointless, as I don't think Codewars users generally actually toggle the theme often, just settling on one and staying on it. Just a simple map function would probably be a lot better, as it would alter the document less to potentially break fewer scripts. That would be boring, though. It's also almost certainly possible to use low opacity to let the background's color change take care of everything, but I couldn't figure it out.
You could probably replace the current .nested-items system with <table>.

Code
Diff
• // make it look a little nicer
\$(".title-container").css("border", "none");

// too bright
(function(xs) {
let rainbowfy = (ix) => function() {
\$(this).css("background-color", xs[ix]); //.css("opacity", 0.5); //good if you hate using codewars
if (\$(this).hasClass("nested-items")) {
\$(this).children().each(rainbowfy((ix + 1) % xs.length));
}
};
\$("#snippet_list").children()
.each(rainbowfy(0));
})(["red", "yellow", "lime", "cyan", "blue", "magenta"]);

// overcomplicated version
(function(xs) {
let rainbow = [[48,49,51],[228,228,231]].map(x => xs.map(y => y.map((z, i) => (z + x[i]) / 2)));
let theme = rainbow[+!\$("html").hasClass("dark")];
let rainbowfy = (ix) => function() {
\$(this).attr("data-rainbow", ix);
\$(this).css("background-color", `rgb(\${theme[ix]})`);
if (\$(this).hasClass("nested-items")) {
\$(this).children().each(rainbowfy((ix + 1) % xs.length));
}
};
\$("#snippet_list").children().each(rainbowfy(0));
let colorize = function() {
let theme = rainbow[+\$("html").hasClass("dark")];
for (let i = 0; i < xs.length; ++i) {
\$(`#snippet_list div[data-rainbow=\${i}]`).css("background-color", `rgb(\${theme[i]})`);
}
};
\$(".js-toggle-dark-mode").click(colorize);
})([[255,0,0],[255,255,0],[0,255,0],[0,255,255],[0,0,255],[255,0,255]]);

•  1 − (function(x){ 2 − x.src="https://code.jquery.com/jquery-3.6.0.min.js"; 3 − document.querySelector("head").appendChild(x); 4 − })(document.createElement("script")); 1 + // make it look a little nicer 2 + \$(".title-container").css("border", "none"); 5 5 6 − \$("") 7 − .insertBefore(".nested-items") 8 − .click(function(){\$(this).next().toggle();}); 4 + // too bright 5 + (function(xs) { 6 + let rainbowfy = (ix) => function() { 7 + \$(this).css("background-color", xs[ix]); //.css("opacity", 0.5); //good if you hate using codewars 8 + if (\$(this).hasClass("nested-items")) { 9 + \$(this).children().each(rainbowfy((ix + 1) % xs.length)); 10 + } 11 + }; 12 + \$("#snippet_list").children() 13 + .each(rainbowfy(0)); 14 + })(["red", "yellow", "lime", "cyan", "blue", "magenta"]); 15 + 16 + // overcomplicated version 17 + (function(xs) { 18 + let rainbow = [[48,49,51],[228,228,231]].map(x => xs.map(y => y.map((z, i) => (z + x[i]) / 2))); 19 + let theme = rainbow[+!\$("html").hasClass("dark")]; 20 + let rainbowfy = (ix) => function() { 21 + \$(this).attr("data-rainbow", ix); 22 + \$(this).css("background-color", `rgb(\${theme[ix]})`); 23 + if (\$(this).hasClass("nested-items")) { 24 + \$(this).children().each(rainbowfy((ix + 1) % xs.length)); 25 + } 26 + }; 27 + \$("#snippet_list").children().each(rainbowfy(0)); 28 + let colorize = function() { 29 + let theme = rainbow[+\$("html").hasClass("dark")]; 30 + for (let i = 0; i < xs.length; ++i) { 31 + \$(`#snippet_list div[data-rainbow=\${i}]`).css("background-color", `rgb(\${theme[i]})`); 32 + } 33 + }; 34 + \$(".js-toggle-dark-mode").click(colorize); 35 + })([[255,0,0],[255,255,0],[0,255,0],[0,255,255],[0,0,255],[255,0,255]]);
Failed Tests

### Kumite Hider

I have to learn JQuery, and I thought I might as well do something fun with it to practice. This can be considered an advanced Hello World.
This makes extremely popular Kumite easier to look through without the need of opening new tabs with different roots or whatever it is you're expected to do.
While testing this, I noticed there are a few div.nested-items elements that have nothing inside them. I suspect that this is the result of Kumite being removed in some way.
Things I want to add at soem point:
Elements containing the code of each individual Kumite that can be popped out and viewed like a window.
A tool taking two of these windows and showing the diff between them.
Something useful for comparing different solutions for code golf Kumite.
A simple query system for searching for Kumite of given languages or fitting certain criteria, meant to allow the button for unhiding elements to indicate whether something fitting is being hidden.
Hopefully this part of the site does not completely die by the time I'm satisfied with this.

(function(x){
x.src="https://code.jquery.com/jquery-3.6.0.min.js";
})(document.createElement("script"));

\$("<button>[ - - ! - - ]</button>")
.insertBefore(".nested-items")
.click(function(){\$(this).next().toggle();});

### Find some happiness

Mathematics
Algorithms
Numbers

A potential addition to this Kumite that I didn't do would be introducing an argument for radix.
If anybody feels like golfing this, check out code.golf/happy-numbers.

Code
Diff
• def is_happy(h: int, *, _unhappy={0}, _happy={1}) -> bool:
"""Returns `True` if `h` is happy, `False` otherwise."""
seen = set()
while True:
if h in _unhappy or h in seen:
_unhappy.update(seen)
return False
elif h in _happy:
_happy.update(seen)
return True
tot = 0
while h > 0:
tot += pow(h % 10, 2)
h //= 10
h = tot

•  1 − def is_happy(h: int) -> bool: 1 + def is_happy(h: int, *, _unhappy={0}, _happy={1}) -> bool: 2 2 """Returns `True` if `h` is happy, `False` otherwise.""" 3 3 seen = set() 4 − while h > 1 and h not in seen: 4 + while True: 5 + if h in _unhappy or h in seen: 6 + _unhappy.update(seen) 7 + return False 8 + elif h in _happy: 9 + _happy.update(seen) 10 + return True 5 5 seen.add(h) 6 6 tot = 0 7 7 while h > 0: 8 8 tot += pow(h % 10, 2) 9 9 h //= 10 10 10 h = tot 11 − return h == 1

### One Away (Levenshtein)

Version with theoretically improved performance due to not requiring any expensive operations like set difference, instead just iterating through the strings.
Unless somebody finds something clever, this is not a very interesting golf problem in Ruby, just use (backtick)chars(backtick) method.

Code
Diff
• def one_away(a,b)
case a.length - b.length
when 0
i = 0
while i < a.length && a[i] == b[i]
i += 1
end
i += 1
# probably slower than just using substring equality,
while i < a.length && a[i] == b[i]
i += 1
end
# but the allure of pretty complexities is too much
return i >= a.length
when 1
return helper(a,b)
when -1
return helper(b, a)
else
return false
end
end

def helper(longer, shorter)
i = 0
while i < shorter.length && longer[i] == shorter[i]
i += 1
end
while i < shorter.length && longer[i + 1] == shorter[i]
i += 1
end
return i >= shorter.length
end
•  1 1 def one_away(a,b) 2 − (a.split('')-b.split('')).count <= 1 ? true : false 2 + case a.length - b.length 3 + when 0 4 + i = 0 5 + while i < a.length && a[i] == b[i] 6 + i += 1 7 + end 8 + i += 1 9 + # probably slower than just using substring equality, 10 + while i < a.length && a[i] == b[i] 11 + i += 1 12 + end 13 + # but the allure of pretty complexities is too much 14 + return i >= a.length 15 + when 1 16 + return helper(a,b) 17 + when -1 18 + return helper(b, a) 19 + else 20 + return false 21 + end 22 + end 23 + 24 + def helper(longer, shorter) 25 + i = 0 26 + while i < shorter.length && longer[i] == shorter[i] 27 + i += 1 28 + end 29 + while i < shorter.length && longer[i + 1] == shorter[i] 30 + i += 1 31 + end 32 + return i >= shorter.length 3 3 end

### Implement ○, `o, or \bigcirc <s>in Julia</s> (monadic, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh)

Surprised nobody has taken advantage of me not thinking about this problem properly. I mixed the a and b arguments the last time, and ended up wasting two bytes doing absolutely nothing. This just goes to show how important good variable naming is.

Code
Diff
• /*
f=(a,b=C="",M=Math,B=M.abs(b))=>b+C?M[(b<0?"a":C)+[,"sin","cos","tan"][B%4]+(B>4?"h":C)](a):a*M.PI
*/
f=(a,b,M=Math,B=M.abs(b))=>B?M[(b<0?"a":"")+[,"sin","cos","tan"][B%4]+(B>4?"h":"")](a):a*M.PI

•  1 1 /* 2 2 f=(a,b=C="",M=Math,B=M.abs(b))=>b+C?M[(b<0?"a":C)+[,"sin","cos","tan"][B%4]+(B>4?"h":C)](a):a*M.PI 3 3 */ 4 − f=(a,b,M=Math,B=M.abs(b))=>B+1?M[(b<0?"a":"")+[,"sin","cos","tan"][B%4]+(B>4?"h":"")](a):a*M.PI 4 + f=(a,b,M=Math,B=M.abs(b))=>B?M[(b<0?"a":"")+[,"sin","cos","tan"][B%4]+(B>4?"h":"")](a):a*M.PI

### Implement ○, `o, or \bigcirc <s>in Julia</s> (monadic, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh)

Code
Diff
• """
import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)
import cmath as c;f=lambda a,b=None:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=None else c.pi*a
import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a
import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a
import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"[-4<b<4:])(a)if b!=""else c.pi*a
from cmath import*;f=lambda a,b=0:globals()["a"[b:]+"sctioansn"[abs(b)%4-1::3]+"h"[-4<b<4:]](a)if b else pi*a
from cmath import*;f=lambda a,b=0:globals()["a"[b:]+"_sctioansn"[abs(b)%4::3]+"h"[-4<b<4:]](a)if b else pi*a
"""
from cmath import*;f=lambda a,b=9:[globals()["a"[b:]+"_sctioansn"[abs(b)%4::3]+"h"[-4<b<4:]](a),pi*a][b>8]
•  1 1 """ 2 2 import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a) 3 3 import cmath as c;f=lambda a,b=None:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=None else c.pi*a 4 4 import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a 5 5 import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a 6 6 import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"[-48]

### Implement ○, `o, or \bigcirc <s>in Julia</s> (monadic, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh)

Another one.
I tried to make a Ruby version of this problem that utilizes Math.send, but Ruby's trig functions seem to be a little disagreeable when it comes to domain, so I'm not sure what the best way to do it would be.

Code
Diff
• """
import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)
import cmath as c;f=lambda a,b=None:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=None else c.pi*a
import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a
import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a
"""
import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"[-4<b<4:])(a)if b!=""else c.pi*a

•  1 1 """ 2 2 import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a) 3 3 import cmath as c;f=lambda a,b=None:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=None else c.pi*a 4 4 import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a 5 − """ 6 6 import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a 6 + """ 7 + import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"[-4

### Implement ○, `o, or \bigcirc <s>in Julia</s> (monadic, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh)

I guess this could be considered a math-based byte save, but it's not the one I was hoping for.

Code
Diff
• """
import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)
import cmath as c;f=lambda a,b=None:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=None else c.pi*a
import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a
"""
import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a
•  1 1 """ 2 2 import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a) 3 3 import cmath as c;f=lambda a,b=None:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=None else c.pi*a 4 − import cmath as c;f=lambda a,b=...:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=...else c.pi*a 5 − import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if str(b)else c.pi*a 6 − """ 7 7 import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a 5 + """ 6 + import cmath as c;f=lambda a,b="":getattr(c,"a"[b:]+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a

### Implement ○, `o, or \bigcirc <s>in Julia</s> (monadic, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh)

Taking advantage of another aspect of JavaScript weirdness, default undefined arguments.

Code
Diff
• /*
f=(a,b=C="",M=Math,B=M.abs(b))=>b+C?M[(b<0?"a":C)+[,"sin","cos","tan"][B%4]+(B>4?"h":C)](a):a*M.PI
*/
f=(a,b,M=Math,B=M.abs(b))=>B+1?M[(b<0?"a":"")+[,"sin","cos","tan"][B%4]+(B>4?"h":"")](a):a*M.PI

•  1 + /* 1 1 f=(a,b=C="",M=Math,B=M.abs(b))=>b+C?M[(b<0?"a":C)+[,"sin","cos","tan"][B%4]+(B>4?"h":C)](a):a*M.PI 2 − 3 + */ 4 + f=(a,b,M=Math,B=M.abs(b))=>B+1?M[(b<0?"a":"")+[,"sin","cos","tan"][B%4]+(B>4?"h":"")](a):a*M.PI

### Implement ○, `o, or \bigcirc <s>in Julia</s> (monadic, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh)

JavaScript and getattr related tasks are a perfect match.
Had to use weird assertions because I kept running into problems relating to NaN not equalling NaN.

Code
Diff
• f=(a,b=C="",M=Math,B=M.abs(b))=>b+C?M[(b<0?"a":C)+[,"sin","cos","tan"][B%4]+(B>4?"h":C)](a):a*M.PI

•  1 − import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a) 1 + f=(a,b=C="",M=Math,B=M.abs(b))=>b+C?M[(b<0?"a":C)+[,"sin","cos","tan"][B%4]+(B>4?"h":C)](a):a*M.PI 2 +

### Implement ○, `o, or \bigcirc <s>in Julia</s> (monadic, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh)

Pretty minimal improvement, couldn't figure out any math-based saves.

Code
Diff
• """
import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)
import cmath as c;f=lambda a,b=None:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=None else c.pi*a
import cmath as c;f=lambda a,b=...:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=...else c.pi*a
import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if str(b)else c.pi*a
"""
import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a
•  1 + """ 1 1 import cmath as c;f=lambda a,b=None:c.pi*a if b==None else getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a) 3 + import cmath as c;f=lambda a,b=None:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=None else c.pi*a 4 + import cmath as c;f=lambda a,b=...:getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=...else c.pi*a 5 + import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if str(b)else c.pi*a 6 + """ 7 + import cmath as c;f=lambda a,b="":getattr(c,"a"*(b<0)+["sin","cos","tan"][abs(b)%4-1]+"h"*(abs(b)>4))(a)if b!=""else c.pi*a