Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
compile d online
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Replacing nested loops //DMD64 D Compiler v2.067.1 import std.stdio, std.algorithm, std.range; void main() { const x = 12, y = 65, z = 50, s = 1435; auto a = iota(0, x + 1); foreach (idx; cartesianProduct(a, a, a).filter!(i => i[0] * (y + 3 * z) + i[1] * (y + 2 * z) + i[2] * (y + z) == s)) { writeln(idx[0] + idx[1] + idx[2]); writeln(idx[0] * 3 + idx[1] * 2 + idx[2]); writeln(idx[0] * 3 + idx[1] * 2 + idx[2]); writeln(idx[0], idx[1], idx[2]); } }
dmd
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.73 sec, absolute running time: 0.14 sec, cpu time: 0 sec, memory peak: 3 Mb, absolute service time: 0.87 sec
edit mode
|
history
9 17 17 081 9 17 17 162 9 17 17 243 9 17 17 324 9 17 17 405