code
stringlengths
1
46.1k
label
class label
1.18k classes
domain_label
class label
21 classes
index
stringlengths
4
5
from itertools import permutations from operator import mul from math import fsum from spermutations import spermutations def prod(lst): return reduce(mul, lst, 1) def perm(a): n = len(a) r = range(n) s = permutations(r) return fsum(prod(a[i][sigma[i]] for i in r) for sigma in s) def det(a): ...
947Determinant and permanent
3python
0tesq
use strict; use warnings; use feature 'say'; use utf8; binmode(STDOUT, ':utf8'); use List::AllUtils qw(uniq); use Unicode::UCD 'charinfo'; for my $str ( '', '.', 'abcABC', 'XYZ ZYX', '1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ', '01234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ0X', '', '', ) { my @S...
952Determine if a string has all unique characters
2perl
hwljl
let strings = [ "", #""If I were two-faced, would I be wearing this one?" --- Abraham Lincoln "#, "..1111111111111111111111111111111111111111111111111111111111111117777888", "I never give 'em hell, I just tell the truth, and they think it's hell. ", " --- Harry S ...
948Determine if a string is collapsible
17swift
i6xo0
require 'mutex_m' class Philosopher def initialize(name, left_fork, right_fork) @name = name @left_fork = left_fork @right_fork = right_fork @meals = 0 end def go while @meals < 5 think dine end puts end def think puts sleep(rand()) puts end def d...
941Dining philosophers
14ruby
vh52n
use std::cmp::Ordering; use std::collections::BinaryHeap; use std::usize; struct Grid<T> { nodes: Vec<Node<T>>, } struct Node<T> { data: T, edges: Vec<(usize,usize)>, } #[derive(Copy, Clone, Eq, PartialEq)] struct State { node: usize, cost: usize, }
942Dijkstra's algorithm
15rust
7ejrc
use strict; package Delegator; sub new { bless {} } sub operation { my ($self) = @_; if (defined $self->{delegate} && $self->{delegate}->can('thing')) { $self->{delegate}->thing; } else { 'default implementation'; } } 1; package Delegate; sub new { bless {}; } sub thing { 'delegate im...
955Delegates
2perl
pslb0
from __future__ import print_function import numpy as np def CheckTriWinding(tri, allowReversed): trisq = np.ones((3,3)) trisq[:,0:2] = np.array(tri) detTri = np.linalg.det(trisq) if detTri < 0.0: if allowReversed: a = trisq[2,:].copy() trisq[2,:] = trisq[1,:] trisq[1,:] = a else: raise ValueError() ...
950Determine if two triangles overlap
3python
r1cgq
library(combinat) perm <- function(A) { stopifnot(is.matrix(A)) n <- nrow(A) if(n != ncol(A)) stop("Matrix is not square.") if(n < 1) stop("Matrix has a dimension of size 0.") sum(sapply(combinat::permn(n), function(sigma) prod(sapply(1:n, function(i) A[i, sigma[i]])))) } testData <- list("Test 1" = rbind(c...
947Determinant and permanent
13r
wibe5
null
953Detect division by zero
11kotlin
8zk0q
package main import ( "fmt" "strconv" ) func isNumeric(s string) bool { _, err := strconv.ParseFloat(s, 64) return err == nil } func main() { fmt.Println("Are these strings numeric?") strings := []string{"1", "3.14", "-100", "1e2", "NaN", "rose"} for _, s := range strings { fmt.Pr...
956Determine if a string is numeric
0go
m5qyi
'''Determine if a string has all the same characters''' from itertools import groupby def firstDifferingCharLR(s): '''Either a message reporting that no character changes were seen, or a dictionary with details of the first character (if any) that differs from that at the head of the string. ...
949Determine if a string has all the same characters
3python
273lz
use std::thread; use std::sync::{Mutex, Arc}; struct Philosopher { name: String, left: usize, right: usize, } impl Philosopher { fn new(name: &str, left: usize, right: usize) -> Philosopher { Philosopher { name: name.to_string(), left: left, right: right, ...
941Dining philosophers
15rust
uk4vj
class Delegator { function __construct() { $this->delegate = NULL ; } function operation() { if(method_exists($this->delegate, )) return $this->delegate->thing() ; return 'default implementation' ; } } class Delegate { function thing() { return 'Delegate Implementation' ; } } $a = ne...
955Delegates
12php
yuq61
import java.io.File; public class FileDeleteTest { public static boolean deleteFile(String filename) { boolean exists = new File(filename).delete(); return exists; } public static void test(String type, String filename) { System.out.println("The following " + type + " called " + fi...
957Delete a file
9java
10cp2
def isNumeric = { def formatter = java.text.NumberFormat.instance def pos = [0] as java.text.ParsePosition formatter.parse(it, pos)
956Determine if a string is numeric
7groovy
tc1fh
isInteger s = case reads s :: [(Integer, String)] of [(_, "")] -> True _ -> False isDouble s = case reads s :: [(Double, String)] of [(_, "")] -> True _ -> False isNumeric :: String -> Bool isNumeric s = isInteger s || isDouble s
956Determine if a string is numeric
8haskell
kxmh0
isAllSame <- function(string) { strLength <- nchar(string) if(length(strLength) > 1) { stop("This task is intended for character vectors with lengths of at most 1.") } else if(length(strLength) == 0) { cat("Examining a character vector of length 0.\n") TRUE } else if(strL...
949Determine if a string has all the same characters
13r
m5dy4
require 'date' class DiscordianDate SEASON_NAMES = [,,,,] DAY_NAMES = [,,,,] YEAR_OFFSET = 1166 DAYS_PER_SEASON = 73 DAYS_PER_WEEK = 5 ST_TIBS_DAY_OF_YEAR = 60 def initialize(year, month, day) gregorian_date = Date.new(year, month, day) @day_of_year = gregorian_date.yday @st_tibs = false ...
944Discordian date
14ruby
94ymz
object Dijkstra { type Path[Key] = (Double, List[Key]) def Dijkstra[Key](lookup: Map[Key, List[(Double, Key)]], fringe: List[Path[Key]], dest: Key, visited: Set[Key]): Path[Key] = fringe match { case (dist, path) :: fringe_rest => path match {case key :: path_rest => if (key == dest) (dist, path.reverse...
942Dijkstra's algorithm
16scala
kqbhk
class Delegator: def __init__(self): self.delegate = None def operation(self): if hasattr(self.delegate, 'thing') and callable(self.delegate.thing): return self.delegate.thing() return 'default implementation' class Delegate: def thing(self): return 'delegate implementation...
955Delegates
3python
102pc
var fso = new ActiveXObject("Scripting.FileSystemObject"); fso.DeleteFile('input.txt'); fso.DeleteFile('c:/input.txt'); fso.DeleteFolder('docs'); fso.DeleteFolder('c:/docs');
957Delete a file
10javascript
qd5x8
require 'matrix' class Matrix def permanent r = (0...row_count).to_a r.permutation.inject(0) do |sum, sigma| sum += sigma.zip(r).inject(1){|prod, (row, col)| prod *= self[row, col] } end end end m1 = Matrix[[1,2],[3,4]] m2 = Matrix[[1, 2, 3, 4], [4, 5, 6, 7], [7, 8, 9, 10], [10, 11, 12, 1...
947Determinant and permanent
14ruby
o3x8v
local function div(a,b) if b == 0 then error() end return a/b end
953Detect division by zero
1lua
o3b8h
'''Determine if a string has all unique characters''' from itertools import groupby def duplicatedCharIndices(s): '''Just the first duplicated character, and the indices of its occurrence, or Nothing if there are no duplications. ''' def go(xs): if 1 < len(xs): duplicat...
952Determine if a string has all unique characters
3python
kx2hf
extern crate chrono; use chrono::NaiveDate; use std::str::FromStr; fn main() { let date = std::env::args().nth(1).expect("Please provide a YYYY-MM-DD date."); println!("{} is {}", date, NaiveDate::from_str(&date).unwrap().to_poee()); }
944Discordian date
15rust
cgm9z
class Delegator attr_accessor :delegate def operation if @delegate.respond_to?(:thing) @delegate.thing else 'default implementation' end end end class Delegate def thing 'delegate implementation' end end if __FILE__ == $PROGRAM_NAME a = Delegator.new ...
955Delegates
14ruby
eouax
null
957Delete a file
11kotlin
je37r
fn main() { let mut m1: Vec<Vec<f64>> = vec![vec![1.0,2.0],vec![3.0,4.0]]; let mut r_m1 = &mut m1; let rr_m1 = &mut r_m1; let mut m2: Vec<Vec<f64>> = vec![vec![1.0, 2.0, 3.0, 4.0], vec![4.0, 5.0, 6.0, 7.0], vec![7.0, 8.0, 9.0, 10.0], vec![10.0, 11.0, 12.0, 13.0]]; let mut r_m2 = &mut m2; let rr_m2 =...
947Determinant and permanent
15rust
i6qod
def permutationsSgn[T]: List[T] => List[(Int,List[T])] = { case Nil => List((1,Nil)) case xs => { for { (x, i) <- xs.zipWithIndex (sgn,ys) <- permutationsSgn(xs.take(i) ++ xs.drop(1 + i)) } yield { val sgni = sgn * (2 * (i%2) - 1) (sgni, (x :: ys)) } } } def det(m:List[List[In...
947Determinant and permanent
16scala
f98d4
isAllUnique <- function(string) { strLength <- nchar(string) if(length(strLength) > 1) { stop("This task is intended for character vectors with lengths of at most 1.") } else if(length(strLength) == 0) { cat("Examining a character vector of length 0.", "It is therefore ma...
952Determine if a string has all unique characters
13r
r1mgj
package rosetta import java.util.GregorianCalendar import java.util.Calendar object DDate extends App { private val DISCORDIAN_SEASONS = Array("Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath")
944Discordian date
16scala
vjl2s
typealias WeightedEdge = (Int, Int, Int) struct Grid<T> { var nodes: [Node<T>] mutating func addNode(data: T) -> Int { nodes.append(Node(data: data, edges: [])) return nodes.count - 1 } mutating func createEdges(weights: [WeightedEdge]) { for (start, end, weight) in weights { nodes[start]....
942Dijkstra's algorithm
17swift
g1r49
trait Thingable { fn thing(&self) -> &str; } struct Delegator<T>(Option<T>); struct Delegate {} impl Thingable for Delegate { fn thing(&self) -> &'static str { "Delegate implementation" } } impl<T: Thingable> Thingable for Delegator<T> { fn thing(&self) -> &str { self.0.as_ref().map(...
955Delegates
15rust
wi5e4
trait Thingable { def thing: String } class Delegator { var delegate: Thingable = _ def operation: String = if (delegate == null) "default implementation" else delegate.thing } class Delegate extends Thingable { override def thing = "delegate implementation" }
955Delegates
16scala
sfrqo
strings = [, , , , , , , , , ] strings.each do |str| pos = str.empty?? nil: str =~ /[^ print puts pos? : end
949Determine if a string has all the same characters
14ruby
uhyvz
import Foundation protocol Thingable {
955Delegates
17swift
a8v1i
require def det2D(p1, p2, p3) return p1[0] * (p2[1] - p3[1]) + p2[0] * (p3[1] - p1[1]) + p3[0] * (p1[1] - p2[1]) end def checkTriWinding(p1, p2, p3, allowReversed) detTri = det2D(p1, p2, p3) if detTri < 0.0 then if allowReversed then p2[0], p3[0] = p3[0], p2[0] p2[1], p3[1...
950Determine if two triangles overlap
14ruby
je27x
public boolean isNumeric(String input) { try { Integer.parseInt(input); return true; } catch (NumberFormatException e) {
956Determine if a string is numeric
9java
4bf58
function isNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n); } var value = "123.45e7";
956Determine if a string is numeric
10javascript
hwyjh
fn test_string(input: &str) { println!("Checking string {:?} of length {}:", input, input.chars().count()); let mut chars = input.chars(); match chars.next() { Some(first) => { if let Some((character, pos)) = chars.zip(2..).filter(|(c, _)| *c!= first).next() { println!(...
949Determine if a string has all the same characters
15rust
5kmuq
import scala.collection.immutable.ListMap object StringAllSameCharacters { def countChar( s : String) : Map[Char, Int] = { val mapChar = s.toSeq.groupBy(identity).map{ case (a,b) => a->s.indexOf(a) } val orderedMapChar = ListMap(mapChar.toSeq.sortWith(_._2 < _._2):_*) orderedMapChar } def are...
949Determine if a string has all the same characters
16scala
r1lgn
def digital_root (n): ap = 0 n = abs(int(n)) while n >= 10: n = sum(int(digit) for digit in str(n)) ap += 1 return ap, n if __name__ == '__main__': for n in [627615, 39390, 588225, 393900588225, 55]: persistance, root = digital_root(n) print( % (n, pers...
945Digital root
3python
dmon1
object Overlap { type Point = (Double, Double) class Triangle(var p1: Point, var p2: Point, var p3: Point) { override def toString: String = s"Triangle: $p1, $p2, $p3" } def det2D(t: Triangle): Double = { val (p1, p2, p3) = (t.p1, t.p2, t.p3) p1._1 * (p2._2 - p3._2) + p2._1 * (p3._2 - p1._2)...
950Determine if two triangles overlap
16scala
ps4bj
os.remove("input.txt") os.remove("/input.txt") os.remove("docs") os.remove("/docs")
957Delete a file
1lua
hw6j8
strings = [, , , , , , , , , ,] strings.each do |str| seen = {} print res = str.chars.each_with_index do |c,i| if seen[c].nil? seen[c] = i else res = break end end puts res end
952Determine if a string has all unique characters
14ruby
psubh
WITH FUNCTION same_characters_in_string(p_in_str IN varchar2) RETURN varchar2 IS v_que varchar2(32767):= p_in_str; v_res varchar2(32767); v_first varchar2(1); v_next varchar2(1); BEGIN v_first:= substr(v_que,1,1); IF v_first IS NULL THEN v_res:= ' length:0 all characters are the same'; ELS...
949Determine if a string has all the same characters
19sql
hwujn
import Foundation let monthDays = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334] let seasons = ["Chaos", "Discord", "Confusion", "Bureacracy", "The Aftermath"] let dayNames = ["Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"] let holyDays1 = ["Mungday", "Mojoday", "Syaday", "Zaraday",...
944Discordian date
17swift
m56yk
y=1 digital_root=function(n){ x=sum(as.numeric(unlist(strsplit(as.character(n),"")))) if(x<10){ k=x }else{ y=y+1 assign("y",y,envir = globalenv()) k=digital_root(x) } return(k) } print("Given number has additive persistence",y)
945Digital root
13r
8zq0x
package main import "fmt" func main() { fmt.Println("Police Sanitation Fire") fmt.Println("------ ---------- ----") count := 0 for i := 2; i < 7; i += 2 { for j := 1; j < 8; j++ { if j == i { continue } for k := 1; k < 8; k++ { if k == i || k == j { ...
958Department numbers
0go
sf5qa
null
956Determine if a string is numeric
11kotlin
lr8cp
fn unique(s: &str) -> Option<(usize, usize, char)> { s.chars().enumerate().find_map(|(i, c)| { s.chars() .enumerate() .skip(i + 1) .find(|(_, other)| c == *other) .map(|(j, _)| (i, j, c)) }) } fn main() { let strings = [ "", ".", ...
952Determine if a string has all unique characters
15rust
105pu
class DepartmentNumbers { static void main(String[] args) { println("Police Sanitation Fire") println("------ ---------- ----") int count = 0 for (int i = 2; i <= 6; i += 2) { for (int j = 1; j <= 7; ++j) { if (j == i) continue for (int...
958Department numbers
7groovy
a8c1p
class String def digroot_persistence(base=10) num = self.to_i(base) persistence = 0 until num < base do num = num.digits(base).sum persistence += 1 end [num.to_s(base), persistence] end end puts %w(627615 39390 588225 393900588225).each do |str| puts % [str, *str.digroot_persist...
945Digital root
14ruby
tcnf2
main :: IO () main = mapM_ print $ [2, 4, 6] >>= \x -> [1 .. 7] >>= \y -> [12 - (x + y)] >>= \z -> case y /= z && 1 <= z && z <= 7 of True -> [(x, y, z)] _ -> []
958Department numbers
8haskell
94xmo
fn sum_digits(mut n: u64, base: u64) -> u64 { let mut sum = 0u64; while n > 0 { sum = sum + (n% base); n = n / base; } sum }
945Digital root
15rust
zldto
if tonumber(a) ~= nil then
956Determine if a string is numeric
1lua
27ol3
def digitalRoot(x:BigInt, base:Int=10):(Int,Int) = { def sumDigits(x:BigInt):Int=x.toString(base) map (_.asDigit) sum def loop(s:Int, c:Int):(Int,Int)=if (s < 10) (s, c) else loop(sumDigits(s), c+1) loop(sumDigits(x), 1) } Seq[BigInt](627615, 39390, 588225, BigInt("393900588225")) foreach {x => var (s, c)=digi...
945Digital root
16scala
yuz63
public class DepartmentNumbers { public static void main(String[] args) { System.out.println("Police Sanitation Fire"); System.out.println("------ ---------- ----"); int count = 0; for (int i = 2; i <= 6; i += 2) { for (int j = 1; j <= 7; ++j) { if (j ...
958Department numbers
9java
tcbf9
sub div_check {local $@; eval {$_[0] / $_[1]}; $@ and $@ =~ /division by zero/;}
953Detect division by zero
2perl
4b35d
(function () { 'use strict';
958Department numbers
10javascript
m5wyv
function div_check($x, $y) { @trigger_error(''); @($x / $y); $e = error_get_last(); return $e['message'] != ''; }
953Detect division by zero
12php
i6pov
sub dotprod { my($vec_a, $vec_b) = @_; die "they must have the same size\n" unless @$vec_a == @$vec_b; my $sum = 0; $sum += $vec_a->[$_] * $vec_b->[$_] for 0..$ return $sum; } my @vec_a = (1,3,-5); my @vec_b = (4,-2,-1); print dotprod(\@vec_a,\@vec_b), "\n";
938Dot product
2perl
uk7vr
null
958Department numbers
11kotlin
o3r8z
use File::Spec::Functions qw(catfile rootdir); unlink 'input.txt'; rmdir 'docs'; unlink catfile rootdir, 'input.txt'; rmdir catfile rootdir, 'docs';
957Delete a file
2perl
tcpfg
print( "Fire", "Police", "Sanitation" ) sol = 0 for f = 1, 7 do for p = 1, 7 do for s = 1, 7 do if s + p + f == 12 and p % 2 == 0 and f ~= p and f ~= s and p ~= s then print( f, p, s ); sol = sol + 1 end end end end print( string.format( "\n%d solutions fo...
958Department numbers
1lua
i67ot
<?php unlink('input.txt'); unlink('/input.txt'); rmdir('docs'); rmdir('/docs'); ?>
957Delete a file
12php
kxyhv
def div_check(x, y): try: x / y except ZeroDivisionError: return True else: return False
953Detect division by zero
3python
gp64h
d <- 5/0 if ( !is.finite(d) ) { }
953Detect division by zero
13r
vjf27
null
945Digital root
20typescript
4bv53
<?php function dot_product($v1, $v2) { if (count($v1) != count($v2)) throw new Exception('Arrays have different lengths'); return array_sum(array_map('bcmul', $v1, $v2)); } echo dot_product(array(1, 3, -5), array(4, -2, -1)), ; ?>
938Dot product
12php
83f0m
import os os.remove() os.rmdir() os.remove() os.rmdir()
957Delete a file
3python
zl1tt
def div_check(x, y) begin x / y rescue ZeroDivisionError true else false end end
953Detect division by zero
14ruby
7amri
fn test_division(numerator: u32, denominator: u32) { match numerator.checked_div(denominator) { Some(result) => println!("{} / {} = {}", numerator, denominator, result), None => println!("{} / {} results in a division by zero", numerator, denominator) } } fn main() { test_division(5, 4); ...
953Detect division by zero
15rust
je972
file.remove("input.txt") file.remove("/input.txt") file.remove("input.txt", "/input.txt") unlink("input.txt"); unlink("/input.txt") unlink("docs", recursive = TRUE) unlink("/docs", recursive = TRUE)
957Delete a file
13r
nyhi2
object DivideByZero extends Application { def check(x: Int, y: Int): Boolean = { try { val result = x / y println(result) return false } catch { case x: ArithmeticException => { return true } } } println("divided by zero = " + check(1, 0)) def check1(x: Int,...
953Detect division by zero
16scala
bq2k6
def dotp(a,b): assert len(a) == len(b), 'Vector sizes must match' return sum(aterm * bterm for aterm,bterm in zip(a, b)) if __name__ == '__main__': a, b = [1, 3, -5], [4, -2, -1] assert dotp(a,b) == 3
938Dot product
3python
5bjux
my @even_numbers; for (1..7) { if ( $_ % 2 == 0) { push @even_numbers, $_; } } print "Police\tFire\tSanitation\n"; foreach my $police_number (@even_numbers) { for my $fire_number (1..7) { for my $sanitation_number (1..7) { if ( $police_number + $fire_number + $sanitation_number == 12 && ...
958Department numbers
2perl
gpd4e
File.delete(, ) Dir.delete() Dir.delete()
957Delete a file
14ruby
6ve3t
x <- c(1, 3, -5) y <- c(4, -2, -1) sum(x*y) x%*% y dotp <- function(x, y) { n <- length(x) if(length(y)!= n) stop("invalid argument") s <- 0 for(i in 1:n) s <- s + x[i]*y[i] s } dotp(x, y)
938Dot product
13r
l74ce
use std::io::{self, Write}; use std::fs::{remove_file,remove_dir}; use std::path::Path; use std::{process,display}; const FILE_NAME: &'static str = "output.txt"; const DIR_NAME: &'static str = "docs"; fn main() { delete(".").and(delete("/")) .unwrap_or_else(|e| error_handler(e,1)); } fn delete<P>...
957Delete a file
15rust
yuw68
use Scalar::Util qw(looks_like_number); print looks_like_number($str) ? "numeric" : "not numeric\n";
956Determine if a string is numeric
2perl
qd4x6
<?php $valid = 0; for ($police = 2 ; $police <= 6 ; $police += 2) { for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) { $fire = 12 - $police - $sanitation; if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) { echo 'Police: ', $police, ', Sa...
958Department numbers
12php
nyjig
import java.util._ import java.io.File object FileDeleteTest extends App { def deleteFile(filename: String) = { new File(filename).delete() } def test(typ: String, filename: String) = { System.out.println("The following " + typ + " called " + filename + (if (deleteFile(filename)) " was deleted." else " ...
957Delete a file
16scala
cgs93
<?php $string = '123'; if(is_numeric(trim($string))) { } ?>
956Determine if a string is numeric
12php
vji2v
from itertools import permutations def solve(): c, p, f, s = .split(',') print(f) c = 1 for p, f, s in permutations(range(1, 8), r=3): if p + s + f == 12 and p% 2 == 0: print(f) c += 1 if __name__ == '__main__': solve()
958Department numbers
3python
r1fgq
irb(main):001:0> require 'matrix' => true irb(main):002:0> Vector[1, 3, -5].inner_product Vector[4, -2, -1] => 3
938Dot product
14ruby
g1k4q
allPermutations <- setNames(expand.grid(seq(2, 7, by = 2), 1:7, 1:7), c("Police", "Sanitation", "Fire")) solution <- allPermutations[which(rowSums(allPermutations)==12 & apply(allPermutations, 1, function(x) !any(duplicated(x)))),] solution <- solution[order(solution$Police, solution$Sanitation),] row.names(solution) <...
958Department numbers
13r
uhovx
null
938Dot product
15rust
rabg5
def is_numeric(s): try: float(s) return True except (ValueError, TypeError): return False is_numeric('123.0')
956Determine if a string is numeric
3python
sfgq9
class Dot[T](v1: Seq[T])(implicit n: Numeric[T]) { import n._
938Dot product
16scala
hxaja
(1..7).to_a.permutation(3){|p| puts p.join if p.first.even? && p.sum == 12 }
958Department numbers
14ruby
jez7x
> strings <- c("152", "-3.1415926", "Foo123") > suppressWarnings(!is.na(as.numeric(strings))) [1] TRUE TRUE FALSE
956Determine if a string is numeric
13r
eovad
extern crate num_iter; fn main() { println!("Police Sanitation Fire"); println!("----------------------"); for police in num_iter::range_step(2, 7, 2) { for sanitation in 1..8 { for fire in 1..8 { if police!= sanitation && sanitation!= fire ...
958Department numbers
15rust
hw3j2
val depts = { (1 to 7).permutations.map{ n => (n(0),n(1),n(2)) }.toList.distinct
958Department numbers
16scala
psmbj
let res = [2, 4, 6].map({x in return (1...7) .filter({ $0!= x }) .map({y -> (Int, Int, Int)? in let z = 12 - (x + y) guard y!= z && 1 <= z && z <= 7 else { return nil } return (x, y, z) }).compactMap({ $0 }) }).flatMap({ $0 }) for result in res { print(...
958Department numbers
17swift
7atrq
def is_numeric?(s) begin Float(s) rescue false else true end end
956Determine if a string is numeric
14ruby
8z701
SELECT i, k, SUM(A.N*B.N) AS N FROM A INNER JOIN B ON A.j=B.j GROUP BY i, k
938Dot product
19sql
p0xb1
null
956Determine if a string is numeric
15rust
o3j83
null
958Department numbers
20typescript
8zg0i
import scala.util.control.Exception.allCatch def isNumber(s: String): Boolean = (allCatch opt s.toDouble).isDefined
956Determine if a string is numeric
16scala
dmbng