task_url
stringlengths
30
116
task_name
stringlengths
2
86
task_description
stringlengths
0
14.4k
language_url
stringlengths
2
53
language_name
stringlengths
1
52
code
stringlengths
0
61.9k
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#TI-89_BASIC
TI-89 BASIC
Define doors(fast) = Func Local doors,i,j seq(false,x,1,100) ? doors If fast Then For i,1,10,1 true ? doors[i^2] EndFor Else For i,1,100,1 For j,i,100,i not doors[j] ? doors[j] EndFor EndFor EndIf Return doors EndFunc
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#TorqueScript
TorqueScript
for(%steps = 1; %a <= 100; %a++) for(%current = %steps; %current <= 100; %current += %steps) %door[%current] = !%door[%current]; for(%a = 1; %a <= 100; %a++) echo("Door #" @ %a @ " is" SPC %door[%current] ? "Open" : "Closed" @ ".");
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Transact-SQL
Transact-SQL
  WITH OneToTen (N) AS ( SELECT N FROM ( VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) ) V(N) ) , InitDoors (Num, IsOpen) AS ( SELECT 1 + 1 * Units.N + 10 * Tens.N AS Num , CONVERT(Bit, 0) AS IsOpen FROM One...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Transd
Transd
#lang transd   MainModule: { doors: Vector<Bool>(100), _start: (λ (for i in Seq(100) do (for k in Seq(i 100 (+ i 1)) do (set-el doors k (not (get doors k))) ))   (for i in Seq(100) do (if (get doors i) (textout (+ i 1) " ")) )) }  
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#True_BASIC
True BASIC
  ! Optimized solution with True BASIC   OPTION NOLET x = 1 y = 3 z = 0 PRINT STR$(x) & " Open" DO UNTIL z >= 100 z = x + y PRINT STR$(z) & " Open" x = z y = y + 2 LOOP   END  
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#TSE_SAL
TSE SAL
    // library: math: get: task: door: open: close100 <description></description> <version control></version control> <version>1.0.0.0.11</version> <version control></version control> (filenamemacro=getmaocl.s) [<Program>] [<Research>] [kn, ri, mo, 31-12-2012 22:03:16] PROC PROCMathGetTaskDoorOpenClose( INTEGER doorMax...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#TUSCRIPT
TUSCRIPT
  $$ MODE TUSCRIPT DICT doors create COMPILE LOOP door=1,100 LOOP pass=1,100 SET go=MOD (door,pass) DICT doors lookup door,num,cnt,status IF (num==0) THEN SET status="open" DICT doors add door,num,cnt,status ELSE IF (go==0) THEN IF (status=="closed") THEN SET status="open" ...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Tiny_BASIC
Tiny BASIC
PRINT "Open doors are:"   LET I = 1 10 IF I = 100 THEN END rem funcion SQR LET B = I*I rem funcion MODULO LET A = I - (I / B) * B IF A < 11 THEN PRINT B LET I = I + 1 GOTO 10
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#TypeScript
TypeScript
  interface Door { id: number; open: boolean; }   function doors(): Door[] { var Doors: Door[] = [];   for (let i = 1; i <= 100; i++) { Doors.push({id: i, open: false}); }   for (let secuence of Doors) { for (let door of Doors) { if (door.id % secuence.id == 0) { door.open = !door.open...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#TXR
TXR
(defun hyaku-mai-tobira () (let ((doors (vector 100))) (each ((i (range 0 99))) (each ((j (range i 99 (+ i 1)))) (flip [doors j]))) doors))   (each ((counter (range 1)) (door (hyaku-mai-tobira))) (put-line `door @counter is @(if door "open" "closed")`))
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#uBasic.2F4tH
uBasic/4tH
FOR p = 1 TO 100 FOR d = p TO 100 STEP p @(d) = @(d) = 0 NEXT d NEXT p   FOR d= 1 TO 100 IF @(d) PRINT "Door ";d;" is open" NEXT d
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Uniface
Uniface
  entry LP_DO_IT   variables string V_DOORS boolean V_DOOR_STATE string V_DOOR_STATE_S numeric V_IDX numeric V_TOTAL_DOORS string V_DOOR_STATE_LIST numeric V_LOOP_COUNT endvariables   V_TOTAL_DOORS = 100 putitem V_DOORS, V_TOTAL_DOORS, 0   V...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Unison
Unison
hundredDoors : [Boolean] hundredDoors = toggleEachNth : Nat -> [Boolean] -> [Boolean] toggleEachNth n doors = go counter = cases [] -> [] (d +: ds) -> if counter == n then (not d) +: go 1 ds else d +: go (counter+1) ds   go 1 doors   foldr toggleEachNth (replicate 100 'false) (...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#UNIX_Shell
UNIX Shell
#! /bin/bash   declare -a doors for((i=1; i <= 100; i++)); do doors[$i]=0 done   for((i=1; i <= 100; i++)); do for((j=i; j <= 100; j += i)); do echo $i $j doors[$j]=$(( doors[j] ^ 1 )) done done   for((i=1; i <= 100; i++)); do if [[ ${doors[$i]} -eq 0 ]]; then op="closed" else op="open" fi ...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Ursa
Ursa
  # # 100 doors #   decl int i j decl boolean<> doors   # append 101 boolean values to doors stream for (set i 0) (or (< i 100) (= i 100)) (inc i) append false doors end for   # loop through, opening and closing doors for (set i 1) (or (< i 100) (= i 100)) (inc i) for (set j i) (or (< j 100) (= j 100)) ...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Ursala
Ursala
#import std #import nat   doors = 0!* iota 100   pass("n","d") = remainder\"n"?l(~&r,not ~&r)* num "d"   #cast %nL   main = ~&rFlS num pass=>doors nrange(100,1)
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#UTFool
UTFool
  ··· http://rosettacode.org/wiki/100_doors ··· ■ HundredDoors § static ▶ main • args⦂ String[] open⦂ boolean: true closed⦂ boolean: false doors⦂ boolean[1+100] · all initially closed 🔁 pass from 1 to 100 ∀ visited ∈ pass‥100 by pass · toggle the visited doors ...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Vala
Vala
int main() { bool doors_open[101]; for(int i = 1; i < doors_open.length; i++) { for(int j = 1; i*j < doors_open.length; j++) { doors_open[i*j] = !doors_open[i*j]; } stdout.printf("%d: %s\n", i, (doors_open[i] ? "open" : "closed")); } return 0; }
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#VAX_Assembly
VAX Assembly
  00000064 0000 1 n = 100 0000 0000 2 .entry doors, ^m<> 26'AF 9F 0002 3 pushab b^arr ; offset signed byte 50 64 8F 9A 0005 4 movzbl #n, r0 50 DD 0009 ...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#VBA
VBA
  Sub Rosetta_100Doors() Dim Door(100) As Boolean, i As Integer, j As Integer For i = 1 To 100 Step 1 For j = i To 100 Step i Door(j) = Not Door(j) Next j If Door(i) = True Then Debug.Print "Door " & i & " is Open" Else Debug.Print "Door " & i & " is Closed" End If Next i End...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#VBScript
VBScript
Dim doorIsOpen(100), pass, currentDoor, text   For currentDoor = 0 To 99 doorIsOpen(currentDoor) = False Next   For pass = 0 To 99 For currentDoor = pass To 99 Step pass + 1 doorIsOpen(currentDoor) = Not doorIsOpen(currentDoor) Next Next   For currentDoor = 0 To 99 text = "Door #" & currentDoor + 1 & " is " If d...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Vedit_macro_language
Vedit macro language
Buf_Switch(Buf_Free) Ins_Char('-', COUNT, 100) // All doors closed for (#1 = 1; #1 <= 100; #1++) { for (#2 = #1; #2 <= 100; #2 += #1) { Goto_Col(#2) Ins_Char((Cur_Char^0x62), OVERWRITE) // Toggle between '-' and 'O' } }
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Verilog
Verilog
  module main; integer i;   initial begin $display("Las siguientes puertas están abiertas:"); for (i=1; i<=10; i=i+1) if (i%i*i<11) $display(i*i); $finish ; end endmodule  
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#VHDL
VHDL
library IEEE; use IEEE.STD_LOGIC_1164.ALL;   entity DOORS is port (CLK: in std_logic; OUTPUT: out std_logic_vector(1 to 100)); end DOORS;   architecture Behavioral of DOORS is begin process (CLK) variable TEMP: std_logic_vector(1 to 100); begin --setup closed doors TEMP := (others => '0');   --looping through...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Visual_Basic
Visual Basic
  Public Sub Doors100() ' the state of a door is represented by the data type boolean (false = door closed, true = door opened) Dim doorstate(1 To 100) As Boolean ' the doorstate()-array is initialized by VB with value 'false' Dim i As Long, j As Long   For i = 1 To 100 For j = i To 100 Step i d...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Visual_Basic_.NET
Visual Basic .NET
Module Module1   Sub Main() Dim doors(100) As Boolean 'Door 1 is at index 0   For pass = 1 To 100 For door = pass - 1 To 99 Step pass doors(door) = Not doors(door) Next Next   For door = 0 To 99 Console.WriteLine("Door # " & (door + 1) & " i...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Vlang
Vlang
const number_doors = 101   fn main() { mut closed_doors := []bool{len: number_doors, init: true} for pass in 0..number_doors { for door := 0; door < number_doors; door += pass + 1 { closed_doors[door] = !closed_doors[door] } } for pass in 1..number_doors { if !closed...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#VTL-2
VTL-2
10 D=1 20 :D)=0 30 D=D+1 40 #=100>D*20 50 P=1 60 D=P 70 :D)=:D)=0 80 D=D+P 90 #=100>D*70 100 P=P+1 110 #=100>P*60 120 D=1 130 #=:D)*170 140 D=D+1 150 #=100>D*130 160 #=999 170 ?="DOOR "; 180 ?=D 190 ?=" IS OPEN" 200 #=!
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Wart
Wart
def (doors n) let door (table) for step 1 (step <= n) ++step for j 0 (j < n) (j <- j+step) zap! not door.j   for j 0 (j < n) ++j when door.j pr j pr " "
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#WDTE
WDTE
let a => import 'arrays'; let s => import 'stream'; let io => import 'io';   let toggle doors m => a.stream doors -> s.enumerate -> s.map (@ s n => [+ (a.at n 0) 1; a.at n 1]) -> s.map (@ s n => switch n { (@ s n => == (% (a.at n 0) m) 0) => ! (a.at n 1); true => a.at n 1; }) -> s.collect ;   s.range 100 ...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Wortel
Wortel
; unoptimized +^[ @var doors []   @for i rangei [1 100] @for j rangei [i 100 i]  :!@not `j doors   @for i rangei [1 100] @if `i doors  !console.log "door {i} is open" ] ; optimized, map square over 1 to 10 !*^@sq @to 10
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Wrapl
Wrapl
MOD Doors;   IMP Agg.Table; IMP Std.String; IMP IO.Terminal USE Out;   VAR door <- {}; EVERY door[1:to(100), "closed"];   DEF toggle(num) door[num] <- door[num] = "open" => "closed" // "open";   EVERY WITH pass <- 1:to(100), num <- pass:to(100, pass) DO toggle(num);   Out:write('Doors {door @ String.T}.');   END Doors.
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Wren
Wren
var doors = [true] * 100 for (i in 1..100) { var j = i while (j < 100) { doors[j] = !doors[j] j = j + i + 1 } }   for (i in 0...100) { if (doors[i]) System.write("%(i + 1) ") } System.print()
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#X86_Assembly
X86 Assembly
    .NOLIST   ; The task can be completed in 48 and "half" steps: ; On the first pass ALL doors are opened. ; On the second pass every EVEN door is closed. ; So, instead of all closed, the doors can initially be: ; Every odd door open, every even door closed and start at pass 3. ; On 51st and all the next passes, onl...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#XBasic
XBasic
PROGRAM "100doors" VERSION "0.0001"   IMPORT "xma" IMPORT "xst"   DECLARE FUNCTION Entry()   FUNCTION Entry() maxpuertas = 100 cont = 0 DIM puertas[100]   FOR p = 1 TO maxpuertas IF INT(SQRT(p)) = SQRT(p) THEN puertas[p] = 1 NEXT p   PRINT "The doors are open: "; FOR p = 1 TO maxpuertas IF puertas...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Xojo
Xojo
  // True=Open; False=Closed Dim doors(100) As Boolean // Booleans default to false For j As Integer = 1 To 100 For i As Integer = 1 to 100 If i Mod j = 0 Then doors(i) = Not doors(i) Next Next  
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#XPL0
XPL0
include c:\cxpl\codes; \intrinsic 'code' declarations int Door(100); \You have 100 doors in a row define Open, Closed; int D, Pass, Step;   [for D:= 0 to 100-1 do \that are all initially closed Door(D):= Closed;   Step:= 1; \The first time through, y...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#XSLT_1.0
XSLT 1.0
<hallway> <door number="1">closed</door> <door number="2">closed</door> <door number="3">closed</door> <door number="4">closed</door> ... etc ... <door number="100">closed</door> <hallway>
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#XSLT_2.0
XSLT 2.0
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>   <xsl:template match="/"> <hallway> <xsl:for-each select="1 to 100"> <xsl:variable name="door-num" select="position()" /> <door number="{$door-num}"> ...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Yabasic
Yabasic
n = 100 // doors ppa = 1 // next open door p2 = 1   for i = 1 to n print "Door ", i, " is "; if i < p2 then print "closed." else ppa = ppa + 1 p2 = ppa^2 print "OPEN." end if next
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Yorick
Yorick
doors = array(0, 100); for(i = 1; i <= 100; i++) for(j = i; j <= 100; j += i) doors(j) ~= 1; print, where(doors);
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#Zig
Zig
pub fn main() !void { const stdout = @import("std").io.getStdOut().writer();   var doors = [_]bool{false} ** 101; var pass: u8 = 1; var door: u8 = undefined;   while (pass <= 100) : (pass += 1) { door = pass; while (door <= 100) : (door += pass) doors[door] = !doors[door]...
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#zkl
zkl
doors:=List.createLong(100,False); // list of 100 Falses foreach n,m in (100,[n..99,n+1]){ doors[m]=(not doors[m]); } //foreach{ foreach{} } doors.filterNs().apply('+(1)).println();
http://rosettacode.org/wiki/100_doors
100 doors
There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and  toggle  the door  (if the door is closed,  open it;   if it is open,  close it). The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it. The third...
#ZX_Spectrum_Basic
ZX Spectrum Basic
10 REM 100 doors open/closed? 20 DIM d(100) 25 LET o=0 30 FOR a=1 TO 100 40 FOR b=a TO 100 STEP a 50 LET d(b)=NOT d(b) 55 LET o=o+(d(b)=1)-(d(b)=0) 60 NEXT b 70 NEXT a 80 PRINT o;" open doors"
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#11l
11l
V costs = [‘W’ = [‘A’ = 16, ‘B’ = 16, ‘C’ = 13, ‘D’ = 22, ‘E’ = 17], ‘X’ = [‘A’ = 14, ‘B’ = 14, ‘C’ = 13, ‘D’ = 19, ‘E’ = 15], ‘Y’ = [‘A’ = 19, ‘B’ = 19, ‘C’ = 20, ‘D’ = 23, ‘E’ = 50], ‘Z’ = [‘A’ = 50, ‘B’ = 12, ‘C’ = 50, ‘D’ = 15, ‘E’ = 11]] V demand = [‘A’ = 30, ‘B’ = 20, ‘C’ = 70, ‘D...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#C
C
#include <stdio.h> #include <limits.h>   #define TRUE 1 #define FALSE 0 #define N_ROWS 4 #define N_COLS 5   typedef int bool;   int supply[N_ROWS] = { 50, 60, 50, 50 }; int demand[N_COLS] = { 30, 20, 70, 30, 60 };   int costs[N_ROWS][N_COLS] = { { 16, 16, 13, 22, 17 }, { 14, 14, 13, 19, 15 }, { 19, 19, 20, ...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#C.2B.2B
C++
#include <iostream> #include <numeric> #include <vector>   template <typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) { auto it = v.cbegin(); auto end = v.cend();   os << '['; if (it != end) { os << *it; it = std::next(it); } while (it != end) { ...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#11l
11l
L(filename) fs:list_dir(‘/foo/bar’) I filename.ends_with(‘.mp3’) print(filename)
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#D
D
void main() { import std.stdio, std.string, std.algorithm, std.range;   enum K { A, B, C, D, E, X, Y, Z, W } immutable int[K][K] costs = cast() //** [K.W: [K.A: 16, K.B: 16, K.C: 13, K.D: 22, K.E: 17], K.X: [K.A: 14, K.B: 14, K.C: 13, K.D: 19, K.E: 15], K.Y: [K.A: 19, K.B: 19, K.C...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#68000_Assembly
68000 Assembly
; ; Non-recursive directory walk for Motorola 68000 under AmigaOs 2.04+ by Thorham ;   execBase equ 4   ; ; from exec includes ; _LVOOpenLibrary equ -552 _LVOCloseLibrary equ -414 _LVOAllocVec equ -684 _LVOFreeVec equ -690   MEMF_ANY equ 0   ; ; from dos includes ; _LVOVPrintf equ -954 _LVOExamine equ -102 _LVOExNext e...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Go
Go
package main   import ( "fmt" "math" )   var supply = []int{50, 60, 50, 50} var demand = []int{30, 20, 70, 30, 60}   var costs = make([][]int, 4)   var nRows = len(supply) var nCols = len(demand)   var rowDone = make([]bool, nRows) var colDone = make([]bool, nCols) var results = make([][]int, nRows)   func init...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#8080_Assembly
8080 Assembly
exit: equ 0 ; CP/M syscall to exit puts: equ 9 ; CP/M syscall to print a string sfirst: equ 17 ; 'Find First' CP/M syscall snext: equ 18 ; 'Find Next' CP/M syscall FCB: equ 5Ch ; Location of FCB for file given on command line org 100h lxi d,FCB ; CP/M parses the command line for us automatically mvi c,sfirst; and p...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#8th
8th
  "*.c" f:glob \ puts an array of strings with the file names on the top of the stack  
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#J
J
vam=:1 :0 : exceeding=. 0 <. -&(+/) D=. x,y exceeding x NB. x: demands S=. y,x exceeding y NB. y: sources C=. (m,.0),0 NB. m: costs B=. 1+>./,C NB. bigger than biggest cost mincost=. <./@-.&0 NB. smallest non-zero cost penalty=. |@(B * 2 -/@{. /:~ -. 0:)"1 - mincost"1 R=. C*0 while. 0 ...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Action.21
Action!
PROC GetFileName(CHAR ARRAY line,fname) BYTE i,len   len=0 i=3 FOR i=3 TO 10 DO IF line(i)=32 THEN EXIT FI len==+1 fname(len)=line(i) OD len==+1 fname(len)='. FOR i=11 TO 13 DO IF line(i)=32 THEN EXIT FI len==+1 fname(len)=line(i) OD fname(0)=len RETURN   PROC Dir(CHAR AR...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Ada
Ada
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO;   procedure Walk_Directory (Directory : in String := "."; Pattern  : in String := "") -- empty pattern = all file names/subdirectory names is Search  : Search_Type; Dir_Ent : Directory_Entry_Type; begin Star...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Java
Java
import java.util.Arrays; import static java.util.Arrays.stream; import java.util.concurrent.*;   public class VogelsApproximationMethod {   final static int[] demand = {30, 20, 70, 30, 60}; final static int[] supply = {50, 60, 50, 50}; final static int[][] costs = {{16, 16, 13, 22, 17}, {14, 14, 13, 19, 15}...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#ALGOL_68
ALGOL 68
INT match=0, no match=1, out of memory error=2, other error=3;   []STRING directory = get directory("."); FOR file index TO UPB directory DO STRING file = directory[file index]; IF grep in string("[Ss]ort*.[.]a68$", file, NIL, NIL) = match THEN print((file, new line)) FI OD
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#AppleScript
AppleScript
tell application "Finder" to return name of every item in (startup disk) --> EXAMPLE RESULT: {"Applications", "Developer", "Library", "System", "Users"}
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Julia
Julia
  immutable TProblem{T<:Integer,U<:String} sd::Array{Array{T,1},1} toc::Array{T,2} labels::Array{Array{U,1},1} tsort::Array{Array{T,2}, 1} end   function TProblem{T<:Integer,U<:String}(s::Array{T,1}, d::Array{T,1}, toc::Arra...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Arturo
Arturo
; list all files at current path print list "."   ; get all files at given path ; and select only the ones we want   ; just select the files with .md extension select list "some/path" => [".md" = extract.extension]   ; just select the files that contain "test" select list "some/path" => [in? "test"]
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#AutoHotkey
AutoHotkey
Loop, %A_WinDir%\*.ini out .= A_LoopFileName "`n" MsgBox,% out
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Kotlin
Kotlin
// version 1.1.3   val supply = intArrayOf(50, 60, 50, 50) val demand = intArrayOf(30, 20, 70, 30, 60)   val costs = arrayOf( intArrayOf(16, 16, 13, 22, 17), intArrayOf(14, 14, 13, 19, 15), intArrayOf(19, 19, 20, 23, 50), intArrayOf(50, 12, 50, 15, 11) )   val nRows = supply.size val nCols = demand.size...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#BaCon
BaCon
PRINT WALK$(".", 1, ".+", FALSE, NL$)
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#BASIC
BASIC
DECLARE SUB show (pattern AS STRING)   show "*.*"   SUB show (pattern AS STRING) DIM f AS STRING f = DIR$(pattern) DO WHILE LEN(f) PRINT f f = DIR$ LOOP END SUB
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Lua
Lua
function initArray(n,v) local tbl = {} for i=1,n do table.insert(tbl,v) end return tbl end   function initArray2(m,n,v) local tbl = {} for i=1,m do table.insert(tbl,initArray(n,v)) end return tbl end   supply = {50, 60, 50, 50} demand = {30, 20, 70, 30, 60} costs = { ...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#BASIC256
BASIC256
call show ("c:\") end   subroutine show (pattern$) f$ = dir(pattern$) while length(f$) print f$ f$ = dir end while end subroutine
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Batch_File
Batch File
dir /b "%windir%\system32\*.exe"
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Nim
Nim
import math, sequtils, strutils   var supply = [50, 60, 50, 50] demand = [30, 20, 70, 30, 60]   let costs = [[16, 16, 13, 22, 17], [14, 14, 13, 19, 15], [19, 19, 20, 23, 50], [50, 12, 50, 15, 11]]   nRows = supply.len nCols = demand.len   var rowDone = newSeq[bool](nRows) ...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#BBC_BASIC
BBC BASIC
directory$ = "C:\Windows\" pattern$ = "*.ini" PROClistdir(directory$ + pattern$) END   DEF PROClistdir(afsp$) LOCAL dir%, sh%, res% DIM dir% LOCAL 317 SYS "FindFirstFile", afsp$, dir% TO sh% IF sh% <> -1 THEN REPEAT PRINT $$(dir%+44) SYS ...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#C
C
#include <sys/types.h> #include <dirent.h> #include <regex.h> #include <stdio.h>   enum { WALK_OK = 0, WALK_BADPATTERN, WALK_BADOPEN, };   int walker(const char *dir, const char *pattern) { struct dirent *entry; regex_t reg; DIR *d;   if (regcomp(&reg, pattern, REG_EXTENDED | REG_NOSUB)) ...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Perl
Perl
#!/usr/bin/perl   use strict; # https://rosettacode.org/wiki/Vogel%27s_approximation_method use warnings; use List::AllUtils qw( max_by nsort_by min );   my $data = <<END; A=30 B=20 C=70 D=30 E=60 W=50 X=60 Y=50 Z=50 AW=16 BW=16 CW=13 DW=22 EW=17 AX=14 BX=14 CX=13 DX=19 EX=15 AY=19 BY=19 CY=20 DY=23 EY=50 AZ=50 BZ=12 C...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#C.23
C#
using System; using System.IO;   namespace DirectoryWalk { class Program { static void Main(string[] args) { string[] filePaths = Directory.GetFiles(@"c:\MyDir", "a*"); foreach (string filename in filePaths) Console.WriteLine(filename); ...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#C.2B.2B
C++
#include "boost/filesystem.hpp" #include "boost/regex.hpp" #include <iostream>   using namespace boost::filesystem;   int main() { path current_dir("."); // list all files starting with a boost::regex pattern("a.*"); for (directory_iterator iter(current_dir), end; iter != end; ++iter) { boos...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Phix
Phix
with javascript_semantics sequence supply = {50,60,50,50}, demand = {30,20,70,30,60}, costs = {{16,16,13,22,17}, {14,14,13,19,15}, {19,19,20,23,50}, {50,12,50,15,11}} sequence row_done = repeat(false,length(supply)), col_done = repeat(fa...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Clojure
Clojure
(import java.nio.file.FileSystems)   (defn match-files [f pattern] (.matches (.getPathMatcher (FileSystems/getDefault) (str "glob:*" pattern)) (.toPath f)))   (defn walk-directory [dir pattern] (let [directory (clojure.java.io/file dir)] (map #(.getPath %) (filter #(match-files % pattern) (.listFiles directory)...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#ColdFusion
ColdFusion
<cfdirectory action="list" directory="C:\temp" filter="*.html" name="dirListing"> <cfoutput query="dirListing"> #dirListing.name# (#dirListing.type#)<br> </cfoutput>
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Python
Python
from collections import defaultdict   costs = {'W': {'A': 16, 'B': 16, 'C': 13, 'D': 22, 'E': 17}, 'X': {'A': 14, 'B': 14, 'C': 13, 'D': 19, 'E': 15}, 'Y': {'A': 19, 'B': 19, 'C': 20, 'D': 23, 'E': 50}, 'Z': {'A': 50, 'B': 12, 'C': 50, 'D': 15, 'E': 11}} demand = {'A': 30, 'B': 20, 'C': 7...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Common_Lisp
Common Lisp
(defun walk-directory (directory pattern) (directory (merge-pathnames pattern directory)))
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#D
D
void main() { import std.stdio, std.file;   dirEntries(".", "*.*", SpanMode.shallow).writeln; }
http://rosettacode.org/wiki/Water_collected_between_towers
Water collected between towers
Task In a two-dimensional world, we begin with any bar-chart (or row of close-packed 'towers', each of unit width), and then it rains, completely filling all convex enclosures in the chart with water. 9 ██ 9 ██ 8 ██ 8 ██ 7 ██ ...
#11l
11l
F water_collected(tower) V l = tower.len V highest_left = [0] [+] (1 .< l).map(n -> max(@tower[0 .< n])) V highest_right = (1 .< l).map(n -> max(@tower[n .< @l])) [+] [0] V water_level = (0 .< l).map(n -> max(min(@highest_left[n], @highest_right[n]) - @tower[n], 0)) print(‘highest_left: ’highest_left) ...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Racket
Racket
#lang racket (define-values (1st 2nd 3rd) (values first second third))   (define-syntax-rule (?: x t f) (if (zero? x) f t))   (define (hash-ref2 hsh# key-1 key-2 #:fail-2 (fail-2 (λ () (error 'hash-ref2 "key-2:~a is not found in hash" key-2))) #:fail-1 (fail-1 (λ () (error 'hash-ref2 "key-1:~...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#DCL
DCL
* matches any number of characters & matches exactly any one character
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Delphi
Delphi
  program Walk_a_directory;   {$APPTYPE CONSOLE} {$R *.res}   uses System.IOUtils;   var Files: TArray<string>; FileName, Directory: string;   begin Directory := TDirectory.GetCurrentDirectory; // dir = '.', work to Files := TDirectory.GetFiles(Directory, '*.*');   for FileName in Files do begin Writ...
http://rosettacode.org/wiki/Water_collected_between_towers
Water collected between towers
Task In a two-dimensional world, we begin with any bar-chart (or row of close-packed 'towers', each of unit width), and then it rains, completely filling all convex enclosures in the chart with water. 9 ██ 9 ██ 8 ██ 8 ██ 7 ██ ...
#8080_Assembly
8080 Assembly
org 100h jmp demo ;;; Calculate the amount of water a row of towers will hold ;;; Note: this will destroy the input array. ;;; Input: DE = tower array, BC = length of array ;;; Output: A = amount of water water: xra a ; Start with no water sta w_out+1 wscanr: mov h,d ; HL = right edge mov l,e dad b wscrlp: dc...
http://rosettacode.org/wiki/Voronoi_diagram
Voronoi diagram
A Voronoi diagram is a diagram consisting of a number of sites. Each Voronoi site s also has a Voronoi cell consisting of all points closest to s. Task Demonstrate how to generate and display a Voroni diagram. See algo K-means++ clustering.
#AutoHotkey
AutoHotkey
;------------------------------------------------------------------------ Gui, 1: +E0x20 +Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs Gui, 1: Show, NA hwnd1 := WinExist() OnExit, Exit If !pToken := Gdip_Startup() { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplu...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Raku
Raku
my %costs = :W{:16A, :16B, :13C, :22D, :17E}, :X{:14A, :14B, :13C, :19D, :15E}, :Y{:19A, :19B, :20C, :23D, :50E}, :Z{:50A, :12B, :50C, :15D, :11E};   my %demand = :30A, :20B, :70C, :30D, :60E; my %supply = :50W, :60X, :50Y, :50Z;   my @cols = %demand.keys.sort;   my %res; my %g = (|%supply.keys.map: ->...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#E
E
def walkDirectory(directory, pattern) { for name => file ? (name =~ rx`.*$pattern.*`) in directory { println(name) } }
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Elena
Elena
import system'io; import system'routines; import extensions'routines;   public program() { var dir := Directory.assign("c:\MyDir");   dir.getFiles("a.*").forEach:printingLn; }
http://rosettacode.org/wiki/Water_collected_between_towers
Water collected between towers
Task In a two-dimensional world, we begin with any bar-chart (or row of close-packed 'towers', each of unit width), and then it rains, completely filling all convex enclosures in the chart with water. 9 ██ 9 ██ 8 ██ 8 ██ 7 ██ ...
#8086_Assembly
8086 Assembly
cpu 8086 org 100h section .text jmp demo ;;; Calculate the amount of water a row of towers will hold ;;; Note: this will destroy the input array. ;;; Input: DX = tower array, CX = length of array ;;; Output: AX = amount of water water: xor ax,ax ; Amount of water starts at zero xor bx,bx ; BH = zero, BL = b...
http://rosettacode.org/wiki/Voronoi_diagram
Voronoi diagram
A Voronoi diagram is a diagram consisting of a number of sites. Each Voronoi site s also has a Voronoi cell consisting of all points closest to s. Task Demonstrate how to generate and display a Voroni diagram. See algo K-means++ clustering.
#BASIC256
BASIC256
global ancho, alto ancho = 500 : alto = 500   clg graphsize ancho, alto   function hypot(a, b) return sqr(a^2+b^2) end function   subroutine Generar_diagrama_Voronoi(ancho, alto, num_celdas) dim nx(num_celdas+1) dim ny(num_celdas+1) dim nr(num_celdas+1) dim ng(num_celdas+1) dim nb(num_celdas+1)   for i = 0 to nu...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#REXX
REXX
/* REXX *************************************************************** * Solve the Transportation Problem using Vogel's Approximation Default Input 2 3 # of sources / # of demands 25 35 sources 20 30 10 demands 3 5 7 cost matrix < 3 2 5 * 20201210 support no input file -courtesy GS * Not...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Elixir
Elixir
# current directory IO.inspect File.ls!   dir = "/users/public" IO.inspect File.ls!(dir)
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Emacs_Lisp
Emacs Lisp
(directory-files "/some/dir/name" nil ;; just the filenames, not full paths "\\.c\\'" ;; regexp t) ;; don't sort the filenames ;;=> ("foo.c" "bar.c" ...)
http://rosettacode.org/wiki/Water_collected_between_towers
Water collected between towers
Task In a two-dimensional world, we begin with any bar-chart (or row of close-packed 'towers', each of unit width), and then it rains, completely filling all convex enclosures in the chart with water. 9 ██ 9 ██ 8 ██ 8 ██ 7 ██ ...
#Action.21
Action!
PROC PrintArray(BYTE ARRAY a BYTE len) BYTE i   Put('[) FOR i=0 TO len-1 DO IF i>0 THEN Put(32) FI PrintB(a(i)) OD Put(']) RETURN   BYTE FUNC Max(BYTE ARRAY a BYTE start,stop) BYTE i,res   res=0 FOR i=start TO stop DO IF a(i)>res THEN res=a(i) FI OD RETURN (res)   B...
http://rosettacode.org/wiki/Voronoi_diagram
Voronoi diagram
A Voronoi diagram is a diagram consisting of a number of sites. Each Voronoi site s also has a Voronoi cell consisting of all points closest to s. Task Demonstrate how to generate and display a Voroni diagram. See algo K-means++ clustering.
#C
C
#include <stdio.h> #include <stdlib.h> #include <string.h>   #define N_SITES 150 double site[N_SITES][2]; unsigned char rgb[N_SITES][3];   int size_x = 640, size_y = 480;   inline double sq2(double x, double y) { return x * x + y * y; }   #define for_k for (k = 0; k < N_SITES; k++) int nearest_site(double x, double y)...
http://rosettacode.org/wiki/Vogel%27s_approximation_method
Vogel's approximation method
Vogel's Approximation Method (VAM) is a technique for finding a good initial feasible solution to an allocation problem. The powers that be have identified 5 tasks that need to be solved urgently. Being imaginative chaps, they have called them “A”, “B”, “C”, “D”, and “E”. They estimate that: A will require 30 hours ...
#Ruby
Ruby
# VAM # # Nigel_Galloway # September 1st., 2013 COSTS = {W: {A: 16, B: 16, C: 13, D: 22, E: 17}, X: {A: 14, B: 14, C: 13, D: 19, E: 15}, Y: {A: 19, B: 19, C: 20, D: 23, E: 50}, Z: {A: 50, B: 12, C: 50, D: 15, E: 11}} demand = {A: 30, B: 20, C: 70, D: 30, E: 60} supply = {W: 50, X: 60, Y...
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Erlang
Erlang
8> filelib:fold_files( "/tmp", ".*", false, fun(File, Acc) -> [File|Acc] end, []). ["/tmp/.X0-lock","/tmp/.cron-check-4000-was-here", "/tmp/kerneloops.XyN0SP","/tmp/npicagwD7tf"] 9> filelib:fold_files( "/tmp", "k.*P", false, fun(File, Acc) -> [File|Acc] end, []). ["/tmp/kerneloops.XyN0SP"]
http://rosettacode.org/wiki/Walk_a_directory/Non-recursively
Walk a directory/Non-recursively
Task Walk a given directory and print the names of files matching a given pattern. (How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?) Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree. ...
#Euphoria
Euphoria
include file.e   procedure show(sequence pattern) sequence f f = dir(pattern) for i = 1 to length(f) do puts(1,f[i][D_NAME]) puts(1,'\n') end for end procedure   show("*.*")
http://rosettacode.org/wiki/Water_collected_between_towers
Water collected between towers
Task In a two-dimensional world, we begin with any bar-chart (or row of close-packed 'towers', each of unit width), and then it rains, completely filling all convex enclosures in the chart with water. 9 ██ 9 ██ 8 ██ 8 ██ 7 ██ ...
#Ada
Ada
with Ada.Text_IO;   procedure Water_Collected is   type Bar_Index is new Positive; type Natural_Array is array (Bar_Index range <>) of Natural;   subtype Bar_Array is Natural_Array; subtype Water_Array is Natural_Array;   function Flood (Bars : Bar_Array; Forward : Boolean) return Water_Array is ...