Programing Puzzles (another bonus) (Spoiler)

BCS ao at pathlink.com
Wed Aug 6 18:34:08 PDT 2008


Reply to wyverex,

> BCS wrote:
> 
>> char a=0,b=0,c=0,d=0;
>> while(a<5 || b<9 || c<5 || d<9)
>> {
>> writef("%d%d:%d%d\n", a,b,c,d);
>> // add a single /expression/ here
>> }
>> make that count from "00:00" to "59:59" (minutes and seconds)
>> 
>> I seem to remember I figured this out once, but I don't remember how
>> I did it.
>> 
> import std.stdio;
> 
> void main()
> {
> char a=0,b=0,c=0,d=0;
> 
> do{
> writef("%d%d:%d%d\n", a,b,c,d);
> ( d == 9 ? d = 0 || (c == 5 ? c = 0 || ( b == 9 ? b = 0 || ++a :
> ++b )  : ++c) : ++d);
> 
> }while(a<6 || b<0 || c<0 || d<0)
> 
> }
> 

yah, that looks right. I think I used a comma expression or some sutch.




More information about the Digitalmars-d-learn mailing list