Submission #601747


Source Code Expand

import std.stdio,
       std.string,
       std.range,
       std.algorithm;

import std.functional;
import std.range.primitives;
import std.traits;
import std.typecons; 
template any(alias pred = "a")
{
    bool any(Range)(Range range)
    if (isInputRange!Range && is(typeof(unaryFun!pred(range.front))))
    {
        return !find!pred(range).empty;
    }
}

template all(alias pred = "a")
{
    bool all(Range)(Range range)
    if (isInputRange!Range && is(typeof(unaryFun!pred(range.front))))
    {
        import std.functional : not;

        return find!(not!(unaryFun!pred))(range).empty;
    }
}

void main(){
  string[] cs = ["a", "t", "c", "o", "d", "e", "r", "@"];
 (zip(readln.chomp.split(""), readln.chomp.split("")).all!(t => 
      (t[0] == "@" && cs.any!(e => e == t[1]) ) || t[1] == "@" &&  cs.any!(e => e == t[0]) 
      || t[0] == t[1]) ? "You can win":"You will lose" )
    .writeln;
}

Submission Info

Submission Time
Task B - AtCoderトランプ
User alphaKAI
Language D (DMD 2.060)
Score 0
Code Size 944 Byte
Status CE

Compile Error

./Main.d(7): Error: can only import from a module, not from a member of module range. Did you mean `import std.range : primitives`?