Skip to main content
2 of 3
added 2 characters in body
Greg Hewgill
  • 2.7k
  • 12
  • 21

Python 2, 167 characters

d=lambda x:("{"+d(x//4)+"}"if x>3 else"")+";"*(x%4)
c=lambda n:"{}"*(int(n)<4)+d(int(n))if n.isdigit()else reduce(lambda x,y:x*4+y,[x.count(";")for x in n.split("}")])

In this implementation, c is the function that satisfies the requirements. It returns a string if given an nonnegative integer as input, or an integer if given a curly number as input.

Greg Hewgill
  • 2.7k
  • 12
  • 21