Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
18
Task/Stern-Brocot-sequence/D/stern-brocot-sequence-2.d
Normal file
18
Task/Stern-Brocot-sequence/D/stern-brocot-sequence-2.d
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import std.stdio, std.algorithm, std.range, std.numeric, queue_usage2;
|
||||
|
||||
struct SternBrocot {
|
||||
private auto sb = GrowableCircularQueue!uint(1, 1);
|
||||
enum empty = false;
|
||||
@property uint front() pure nothrow @safe @nogc {
|
||||
return sb.front;
|
||||
}
|
||||
uint popFront() pure nothrow @safe {
|
||||
sb.push(sb.front + sb[1]);
|
||||
sb.push(sb[1]);
|
||||
return sb.pop;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
SternBrocot().drop(50_000_000).front.writeln;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue