code
stringlengths
1
46.1k
label
class label
1.18k classes
domain_label
class label
21 classes
index
stringlengths
4
5
powerMod :: (Integral a, Integral b) => a -> a -> b -> a powerMod m _ 0 = 1 powerMod m x n | n > 0 = f x_ (n - 1) x_ where x_ = x `rem` m f _ 0 y = y f a d y = g a d where g b i | even i = g (b * b `rem` m) (i `quot` 2) | otherwise = f b (i - 1) (b * y `rem` m) powe...
544Multiplicative order
8haskell
n7uie
import Control.Monad (join) import Data.List (unfoldr) isMunchausen :: Integer -> Bool isMunchausen = (==) <*> (sum . map (join (^)) . unfoldr digit) digit 0 = Nothing digit n = Just (r, q) where (q, r) = n `divMod` 10 main :: IO () main = print $ filter isMunchausen [1 .. 5000]
541Munchausen numbers
8haskell
py3bt
package main import ( "fmt" "math" "rcu" ) var maxDepth = 6 var maxBase = 36 var c = rcu.PrimeSieve(int(math.Pow(float64(maxBase), float64(maxDepth))), true) var digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" var maxStrings [][][]int var mostBases = -1 func maxSlice(a []int) in...
546Multi-base primes
0go
x23wf
isConsistent(List q, int n) { for (int i=0; i<n; i++) { if (q[i] == q[n]) { return false;
543N-queens problem
18dart
3pjzz
import java.math.BigInteger; import java.util.ArrayList; import java.util.List; public class MultiplicativeOrder { private static final BigInteger ONE = BigInteger.ONE; private static final BigInteger TWO = BigInteger.valueOf(2); private static final BigInteger THREE = BigInteger.valueOf(3); private st...
544Multiplicative order
9java
qvmxa
public class Nth { public static String ordinalAbbrev(int n){ String ans = "th";
540N'th
9java
u80vv
class Integer def narcissistic? return false if negative? digs = self.digits m = digs.size digs.map{|d| d**m}.sum == self end end puts 0.step.lazy.select(&:narcissistic?).first(25)
536Narcissistic decimal number
14ruby
3pez7
null
544Multiplicative order
11kotlin
1mtpd
console.log(function () { var lstSuffix = 'th st nd rd th th th th th th'.split(' '), fnOrdinalForm = function (n) { return n.toString() + ( 11 <= n % 100 && 13 >= n % 100 ? "th" : lstSuffix[n % 10] ); }, range = function (m, n) { return Array.apply( null, Arra...
540N'th
10javascript
7fdrd
fn is_narcissistic(x: u32) -> bool { let digits: Vec<u32> = x .to_string() .chars() .map(|c| c.to_digit(10).unwrap()) .collect(); digits .iter() .map(|d| d.pow(digits.len() as u32)) .sum::<u32>() == x } fn main() { let mut counter = 0; le...
536Narcissistic decimal number
15rust
61w3l
object NDN extends App { val narc: Int => Int = n => (n.toString map (_.asDigit) map (math.pow(_, n.toString.size)) sum) toInt val isNarc: Int => Boolean = i => i == narc(i) println((Iterator from 0 filter isNarc take 25 toList) mkString(" ")) }
536Narcissistic decimal number
16scala
9wsm5
public class Main { public static void main(String[] args) { for(int i = 0 ; i <= 5000 ; i++ ){ int val = String.valueOf(i).chars().map(x -> (int) Math.pow( x-48 ,x-48)).sum(); if( i == val){ System.out.println( i + " (munchausen)"); } } } }
541Munchausen numbers
9java
rdig0
extension String { func multiSplit(on seps: [String]) -> ([Substring], [(String, (start: String.Index, end: String.Index))]) { var matches = [Substring]() var matched = [(String, (String.Index, String.Index))]() var i = startIndex var lastMatch = startIndex main: while i!= endIndex { for se...
539Multisplit
17swift
rddgg
int a[10]; float b[3][2]; char c[4][5][6]; double d[6][7][8][9]; int e[][3]; float f[5][4][]; int *g; float **h; double **i[]; char **j[][5];
547Multi-dimensional array
5c
7fqrg
double w[] = { 52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46 }; double h[] = { 1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83 }; int main() { int n = sizeof(h)/sizeof(double); gsl_matrix *X = gsl_matrix_calloc...
548Multiple regression
5c
fh2d3
extension BinaryInteger { @inlinable public var isNarcissistic: Bool { let digits = String(self).map({ Int(String($0))! }) let m = digits.count guard m!= 1 else { return true } return digits.map({ $0.power(m) }).reduce(0, +) == self } @inlinable public func power(_ n: Self) -> Sel...
536Narcissistic decimal number
17swift
zbatu
for (let i of [...Array(5000).keys()] .filter(n => n == n.toString().split('') .reduce((a, b) => a+Math.pow(parseInt(b),parseInt(b)), 0))) console.log(i);
541Munchausen numbers
10javascript
b6zki
func nxm(n, m int) [][]int { d2 := make([][]int, n) for i := range d2 { d2[i] = make([]int, m) } return d2 }
545Multiple distinct objects
0go
pydbg
use strict; use warnings; use feature 'say'; use List::AllUtils <firstidx max>; use ntheory qw/fromdigits todigitstring primes/; my(%prime_base, %max_bases, $l); my $chars = 5; my $upto = fromdigits( '1' . 'Z' x $chars, 36); my @primes = @{primes( $upto )}; for my $base (2..36) { my $n = todigitstring($base-1...
546Multi-base primes
2perl
5oeu2
def createFoos1 = { n -> (0..<n).collect { new Foo() } }
545Multiple distinct objects
7groovy
7f0rz
replicateM n makeTheDistinctThing
545Multiple distinct objects
8haskell
fh5d1
use ntheory qw/znorder/; say znorder(54, 100001); use bigint; say znorder(11, 1 + 10**100);
544Multiplicative order
2perl
mekyz
from decimal import Decimal, getcontext def nthroot (n, A, precision): getcontext().prec = precision n = Decimal(n) x_0 = A / n x_1 = 1 while True: x_0, x_1 = x_1, (1 / n)*((n - 1)*x_0 + (A / (x_0 ** (n - 1)))) if x_0 == x_1: return x_1
531Nth root
3python
iraof
fun Int.ordinalAbbrev() = if (this % 100 / 10 == 1) "th" else when (this % 10) { 1 -> "st" 2 -> "nd" 3 -> "rd" else -> "th" } fun IntRange.ordinalAbbrev() = map { "$it" + it.ordinalAbbrev() }.joinToString(" ") fun main(args: Array<String>) { listOf((0..25), (250..265), (1000..1025)).forEach { prin...
540N'th
11kotlin
9wemh
Foo[] foos = new Foo[n];
545Multiple distinct objects
9java
059se
var a = new Array(n); for (var i = 0; i < n; i++) a[i] = new Foo();
545Multiple distinct objects
10javascript
djunu
bool is_prime(uint64_t n) { if (n < 2) return false; if (n % 2 == 0) return n == 2; if (n % 3 == 0) return n == 3; for (uint64_t p = 5; p * p <= n; p += 4) { if (n % p == 0) return false; p += 2; if (n % p == 0) return false; } ...
549Motzkin numbers
5c
053st
int move_to_front(char *str,char c) { char *q,*p; int shift=0; p=(char *)malloc(strlen(str)+1); strcpy(p,str); q=strchr(p,c); shift=q-p; strncpy(str+1,p,shift); str[0]=c; free(p); return shift; } void decode(int* pass,int size,char *sym) { int i,index; char c; ...
550Move-to-front algorithm
5c
dj9nv
nthroot <- function(A, n, tol=sqrt(.Machine$double.eps)) { ifelse(A < 1, x0 <- A * n, x0 <- A / n) repeat { x1 <- ((n-1)*x0 + A / x0^(n-1))/n if(abs(x1 - x0) > tol) x0 <- x1 else break } x1 } nthroot(7131.5^10, 10) nthroot(7, 0.5)
531Nth root
13r
sukqy
null
541Munchausen numbers
11kotlin
v0q21
null
545Multiple distinct objects
11kotlin
ecza4
int main() { Display *d; Window inwin; Window inchildwin; int rootx, rooty; int childx, childy; Atom atom_type_prop; int actual_format; unsigned int mask; unsigned long n_items, bytes_after_ret; Window *props; d = XOpenDisplay(NULL); (void)XGetWindowProperty(d, Default...
551Mouse position
5c
ecoav
def gcd(a, b): while b != 0: a, b = b, a% b return a def lcm(a, b): return (a*b) / gcd(a, b) def isPrime(p): return (p > 1) and all(f == p for f,e in factored(p)) primeList = [2,3,5,7] def primes(): for p in primeList: yield p while 1: p += 2 while not isPrime(...
544Multiplicative order
3python
9wbmf
null
545Multiple distinct objects
1lua
wl3ea
int multifact(int n, int deg){ return n <= deg ? n : n * multifact(n - deg, deg); } int multifact_i(int n, int deg){ int result = n; while (n >= deg + 1){ result *= (n - deg); n -= deg; } return result; } int main(void){ int i, j; for (i = 1; i <= HIGHEST_DEGREE; i++){ printf(...
552Multifactorial
5c
x2iwu
null
546Multi-base primes
15rust
7fsrc
function getSuffix (n) local lastTwo, lastOne = n % 100, n % 10 if lastTwo > 3 and lastTwo < 21 then return "th" end if lastOne == 1 then return "st" end if lastOne == 2 then return "nd" end if lastOne == 3 then return "rd" end return "th" end function Nth (n) return n .. "'" .. getSuffix(n) en...
540N'th
1lua
cxw92
(def lowercase (map char (range (int \a) (inc (int \z))))) (defn move-to-front [x xs] (cons x (remove #{x} xs))) (defn encode [text table & {:keys [acc]:or {acc []}}] (let [c (first text) idx (.indexOf table c)] (if (empty? text) acc (recur (drop 1 text) (move-to-front c table) {:acc (conj acc idx)}))...
550Move-to-front algorithm
6clojure
61u3q
package main import "fmt" type md struct { dim []int ele []float64 } func newMD(dim ...int) *md { n := 1 for _, d := range dim { n *= d } return &md{append([]int{}, dim...), make([]float64, n)} } func (m *md) index(i ...int) (x int) { for d, dx := range m.dim { x = x*dx +...
547Multi-dimensional array
0go
dj2ne
(let [point (.. java.awt.MouseInfo getPointerInfo getLocation)] [(.getX point) (.getY point)])
551Mouse position
6clojure
05tsj
def nthroot(n, a, precision = 1e-5) x = Float(a) begin prev = x x = ((n - 1) * prev + a / (prev ** (n - 1))) / n end while (prev - x).abs > precision x end p nthroot(5,34)
531Nth root
14ruby
djwns
function isMunchausen (n) local sum, nStr, digit = 0, tostring(n) for pos = 1, #nStr do digit = tonumber(nStr:sub(pos, pos)) sum = sum + digit ^ digit end return sum == n end
541Munchausen numbers
1lua
u8svl
package main import ( "fmt" "rcu" ) func motzkin(n int) []int { m := make([]int, n+1) m[0] = 1 m[1] = 1 for i := 2; i <= n; i++ { m[i] = (m[i-1]*(2*i+1) + m[i-2]*(3*i-3)) / (i + 2) } return m } func main() { fmt.Println(" n M[n] Prime?") fmt.Printl...
549Motzkin numbers
0go
u8bvt
public class MultiDimensionalArray { public static void main(String[] args) {
547Multi-dimensional array
9java
9wjmu
package main import ( "fmt" "github.com/gonum/matrix/mat64" ) func givens() (x, y *mat64.Dense) { height := []float64{1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83} weight := []float64{52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 6...
548Multiple regression
0go
jtq7d
require 'prime' def powerMod(b, p, m) p.to_s(2).each_char.inject(1) do |result, bit| result = (result * result) % m bit=='1'? (result * b) % m: result end end def multOrder_(a, p, k) pk = p ** k t = (p - 1) * p ** (k - 1) r = 1 for q, e in t.prime_division x = powerMod(a, t / q**e, pk) whi...
544Multiplicative order
14ruby
lq1cl
null
531Nth root
15rust
fhxd6
import Control.Monad.Memo (Memo, memo, startEvalMemo) import Math.NumberTheory.Primes.Testing (isPrime) import System.Environment (getArgs) import Text.Printf (printf) type I = Integer motzkin :: I -> Memo I I I motzkin 0 = return 1 motzkin 1 = return 1 motzkin n = do m1 <- memo motzkin (n-1) m2 <- memo motzkin...
549Motzkin numbers
8haskell
wlded
function array() { var dimensions= Array.prototype.slice.call(arguments); var N=1, rank= dimensions.length; for (var j= 0; j<rank; j++) N*= dimensions[j]; this.dimensions= dimensions; this.values= new Array(N); }
547Multi-dimensional array
10javascript
u81vb
import Numeric.LinearAlgebra import Numeric.LinearAlgebra.LAPACK m :: Matrix Double m = (3><3) [7.589183,1.703609,-4.477162, -4.597851,9.434889,-6.543450, 0.4588202,-6.115153,1.331191] v :: Matrix Double v = (3><1) [1.745005,-4.448092,-4.160842]
548Multiple regression
8haskell
ogm8p
(defn !! [m n] (->> (iterate #(- % m) n) (take-while pos?) (apply *))) (doseq [m (range 1 6)] (prn m (map #(!! m %) (range 1 11))))
552Multifactorial
6clojure
ogz8j
def nroot(n: Int, a: Double): Double = { @tailrec def rec(x0: Double) : Double = { val x1 = ((n - 1) * x0 + a/math.pow(x0, n-1))/n if (x0 <= x1) x0 else rec(x1) } rec(a) }
531Nth root
16scala
3p0zy
(Foo->new) x $n
545Multiple distinct objects
2perl
cxb9a
package main import "fmt" func F(n int) int { if n == 0 { return 1 } return n - M(F(n-1)) } func M(n int) int { if n == 0 { return 0 } return n - F(M(n-1)) } func main() { for i := 0; i < 20; i++ { fmt.Printf("%2d ", F(i)) } fmt.Println() for i := 0; i < 20; i++ { fmt.Printf("%2d ", M(i)) }...
542Mutual recursion
0go
wlmeg
(defn bind [coll f] (apply vector (mapcat f coll))) (defn unit [val] (vector val)) (defn doubler [n] [(* 2 n)]) (def vecstr (comp vector str)) (bind (bind (vector 3 4 5) doubler) vecstr) (-> [3 4 5] (bind doubler) (bind vecstr))
553Monads/List monad
6clojure
2sgl1
null
547Multi-dimensional array
11kotlin
zb5ts
import java.util.Arrays; import java.util.Objects; public class MultipleRegression { public static void require(boolean condition, String message) { if (condition) { return; } throw new IllegalArgumentException(message); } public static class Matrix { private fi...
548Multiple regression
9java
wlfej
def f, m
542Mutual recursion
7groovy
b6tky
[Foo()] * n
545Multiple distinct objects
3python
lqpcv
use strict; use warnings; use ntheory qw( is_prime ); sub motzkin { my $N = shift; my @m = ( 0, 1, 1 ); for my $i ( 3 .. $N ) { $m[$i] = ($m[$i - 1] * (2 * $i - 1) + $m[$i - 2] * (3 * $i - 6)) / ($i + 1); } return splice @m, 1; } print " n M[n]\n"; my $count = 0; for ( motzkin(42) )...
549Motzkin numbers
2perl
n79iw
package main import ( "fmt" "math" ) type mwriter struct { value float64 log string } func (m mwriter) bind(f func(v float64) mwriter) mwriter { n := f(m.value) n.log = m.log + n.log return n } func unit(v float64, s string) mwriter { return mwriter{v, fmt.Sprintf(" %-17s:%g\n", s,...
554Monads/Writer monad
0go
suiqa
null
547Multi-dimensional array
1lua
3p4zo
null
548Multiple regression
10javascript
84y0l
package main import ( "fmt" "github.com/go-vgo/robotgo" ) func isInside(x, y, w, h, mx, my int) bool { rx := x + w - 1 ry := y + h - 1 return mx >= x && mx <= rx && my >= y && my <= ry } func main() { name := "gedit"
551Mouse position
0go
9w4mt
f 0 = 1 f n | n > 0 = n - m (f $ n-1) m 0 = 0 m n | n > 0 = n - f (m $ n-1) main = do print $ map f [0..19] print $ map m [0..19]
542Mutual recursion
8haskell
61k3k
rep(foo(), n)
545Multiple distinct objects
13r
yaj6h
typedef enum type { INT, STRING } Type; typedef struct maybe { int i; char *s; Type t; _Bool is_something; } Maybe; void print_Maybe(Maybe *m) { if (m->t == INT) printf(, m->i); else if (m->t == STRING) printf(%s\, m->s); else printf(); } Maybe *return_maybe(void *data, Type t) { M...
555Monads/Maybe monad
5c
u8gv4
package main import ( "bytes" "fmt" ) type symbolTable string func (symbols symbolTable) encode(s string) []byte { seq := make([]byte, len(s)) pad := []byte(symbols) for i, c := range []byte(s) { x := bytes.IndexByte(pad, c) seq[i] = byte(x) copy(pad[1:], pad[:x]) pad[0] = c } return seq } func (symb...
550Move-to-front algorithm
0go
7fer2
import Control.Monad.Trans.Writer import Control.Monad ((>=>)) loggingVersion :: (a -> b) -> c -> a -> Writer c b loggingVersion f log x = writer (f x, log) logRoot = loggingVersion sqrt "obtained square root, " logAddOne = loggingVersion (+1) "added 1, " logHalf = loggingVersion (/2) "divided by 2, " halfOfAddOneOf...
554Monads/Writer monad
8haskell
9wvmo
1.upto(5) { Thread.sleep(1000) def p = java.awt.MouseInfo.pointerInfo.location println "${it}: x=${p.@x} y=${p.@y}" }
551Mouse position
7groovy
zblt5
extension FloatingPoint where Self: ExpressibleByFloatLiteral { @inlinable public func power(_ e: Int) -> Self { var res = Self(1) for _ in 0..<e { res *= self } return res } @inlinable public func root(n: Int, epsilon: Self = 2.220446049250313e-16) -> Self { var d = Self(0) v...
531Nth root
17swift
n7eil
[Foo.new] * n Array.new(n, Foo.new)
545Multiple distinct objects
14ruby
v0a2n
use std::rc::Rc; use std::cell::RefCell; fn main() { let size = 3;
545Multiple distinct objects
15rust
u8evj
for (i <- (0 until n)) yield new Foo()
545Multiple distinct objects
16scala
gnq4i
import Data.List (delete, elemIndex, mapAccumL) import Data.Maybe (fromJust) table :: String table = ['a' .. 'z'] encode :: String -> [Int] encode = let f t s = (s: delete s t, fromJust (elemIndex s t)) in snd . mapAccumL f table decode :: [Int] -> String decode = snd . mapAccumL f table where f t i = ...
550Move-to-front algorithm
8haskell
8430z
(function () { 'use strict';
554Monads/Writer monad
10javascript
me2yv
package main import "fmt" type mlist struct{ value []int } func (m mlist) bind(f func(lst []int) mlist) mlist { return f(m.value) } func unit(lst []int) mlist { return mlist{lst} } func increment(lst []int) mlist { lst2 := make([]int, len(lst)) for i, v := range lst { lst2[i] = v + 1 } ...
553Monads/List monad
0go
1mqp5
null
548Multiple regression
11kotlin
b68kb
main() { int n=5,d=3; int z= fact(n,d); print('$n factorial of degree $d is $z'); for(var j=1;j<=5;j++) { print('first 10 numbers of degree $j:'); for(var i=1;i<=10;i++) { int z=fact(i,j); print('$z'); } print('\n'); } } int fact(int a,int b) { if(a<=b||a==0) return a; if(a>1) return a*...
552Multifactorial
18dart
b6xk1
Point mouseLocation = MouseInfo.getPointerInfo().getLocation();
551Mouse position
9java
gnp4m
require motzkin = Enumerator.new do |y| m = [1,1] m.each{|m| y << m } 2.step do |i| m << (m.last*(2*i+1) + m[-2]*(3*i-3)) / (i+2) m.unshift y << m.last end end motzkin.take(42).each_with_index do |m, i| puts end
549Motzkin numbers
14ruby
tk2f2
null
549Motzkin numbers
15rust
zbvto
main = print $ [3,4,5] >>= (return . (+1)) >>= (return . (*2))
553Monads/List monad
8haskell
tkmf7
use feature 'say'; for $i (0..1) { for $j (0..2) { for $k (0..3) { $a[$i][$j][$k][$l] = [(0)x5]; } } } @b = ( [1, 2, 4, 8, 16, 32], [<Mon Tue Wed Thu Fri Sat Sun>], [sub{$_[0]+$_[1...
547Multi-dimensional array
2perl
b6ok4
document.addEventListener('mousemove', function(e){ var position = { x: e.clientX, y: e.clientY } }
551Mouse position
10javascript
k3xhq
use List::Util "sum"; for my $n (1..5000) { print "$n\n" if $n == sum( map { $_**$_ } split(//,$n) ); }
541Munchausen numbers
2perl
05vs4
class Foo { } var foos = [Foo]() for i in 0..<n { foos.append(Foo()) }
545Multiple distinct objects
17swift
2s1lj
import Foundation extension BinaryInteger { @inlinable public var isPrime: Bool { if self == 0 || self == 1 { return false } else if self == 2 { return true } let max = Self(ceil((Double(self).squareRoot()))) for i in stride(from: 2, through: max, by: 1) where self% i == 0 { ...
549Motzkin numbers
17swift
fhldk
(defn bind [val f] (if-let [v (:value val)] (f v) val)) (defn unit [val] {:value val}) (defn opt_add_3 [n] (unit (+ 3 n))) (defn opt_str [n] (unit (str n))) (bind (unit 4) opt_add_3) (bind (unit nil) opt_add_3) (bind (bind (unit 8) opt_add_3) opt_str) (bind (bind (unit nil)...
555Monads/Maybe monad
6clojure
7fkr0
import java.util.LinkedList; import java.util.List; public class MTF{ public static List<Integer> encode(String msg, String symTable){ List<Integer> output = new LinkedList<Integer>(); StringBuilder s = new StringBuilder(symTable); for(char c: msg.toCharArray()){ int idx = s.indexOf("" + c); output.add(id...
550Move-to-front algorithm
9java
ecia5
null
554Monads/Writer monad
11kotlin
ogf8z
Array.prototype.bind = function (func) { return this.map(func).reduce(function (acc, a) { return acc.concat(a); }); } Array.unit = function (elem) { return [elem]; } Array.lift = function (func) { return function (elem) { return Array.unit(func(elem)); }; } inc = function (n) { return n + 1; } doub = function ...
553Monads/List monad
10javascript
fhydg
null
551Mouse position
11kotlin
2s7li
null
543N-queens problem
0go
x2mwf
var encodeMTF = function (word) { var init = {wordAsNumbers: [], charList: 'abcdefghijklmnopqrstuvwxyz'.split('')}; return word.split('').reduce(function (acc, char) { var charNum = acc.charList.indexOf(char);
550Move-to-front algorithm
10javascript
05zsz
package Writer; use strict; use warnings; sub new { my ($class, $value, $log) = @_; return bless [ $value => $log ], $class; } sub Bind { my ($self, $code) = @_; my ($value, $log) = @$self; my $n = $code->($value); return Writer->new( @$n[0], $log.@$n[1] ); } sub Unit { Writer->new($_[0], sprintf(...
554Monads/Writer monad
2perl
gnh4e
null
553Monads/List monad
11kotlin
wl8ek
>>> from pprint import pprint as pp >>> from itertools import product >>> >>> def dict_as_mdarray(dimensions=(2, 3), init=0.0): ... return {indices: init for indices in product(*(range(i) for i in dimensions))} ... >>> >>> mdarray = dict_as_mdarray((2, 3, 4, 5)) >>> pp(mdarray) {(0, 0, 0, 0): 0.0, (0, 0, 0, ...
547Multi-dimensional array
3python
pyibm
def listOrder = { a, b -> def k = [a.size(), b.size()].min() def i = (0..<k).find { a[it] != b[it] } (i != null) ? a[i] <=> b[i]: a.size() <=> b.size() } def orderedPermutations = { list -> def n = list.size() (0..<n).permutations().sort(listOrder) } def diagonalSafe = { list -> def n = list.s...
543N-queens problem
7groovy
pytbo
<?php $pwr = array_fill(0, 10, 0); function isMunchhausen($n) { global $pwr; $sm = 0; $temp = $n; while ($temp) { $sm= $sm + $pwr[($temp % 10)]; $temp = (int)($temp / 10); } return $sm == $n; } for ($i = 0; $i < 10; $i++) { $pwr[$i] = pow((float)($i), (float)($i)); } for...
541Munchausen numbers
12php
5o0us