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/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Scheme | Scheme | (display (number->string 5 2)) (newline)
(display (number->string 50 2)) (newline)
(display (number->string 9000 2)) (newline) |
http://rosettacode.org/wiki/Binary_search | Binary search | A binary search divides a range of values into halves, and continues to narrow down the field of search until the unknown value is found. It is the classic example of a "divide and conquer" algorithm.
As an analogy, consider the children's game "guess a number." The scorer has a secret number, and will only tell the p... | #Yabasic | Yabasic | sub floor(n)
return int(n + .5)
end sub
sub binarySearch(list(), value)
local low, high, mid
low = 1 : high = arraysize(list(), 1)
while(low <= high)
mid = floor((low + high) / 2)
if list(mid) > value then
high = mid - 1
elsif list(mid) < value then
... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Seed7 | Seed7 | $ include "seed7_05.s7i";
const proc: main is func
local
var integer: number is 0;
begin
for number range 0 to 16 do
writeln(number radix 2);
end for;
end func; |
http://rosettacode.org/wiki/Binary_search | Binary search | A binary search divides a range of values into halves, and continues to narrow down the field of search until the unknown value is found. It is the classic example of a "divide and conquer" algorithm.
As an analogy, consider the children's game "guess a number." The scorer has a secret number, and will only tell the p... | #z.2FArch_Assembler | z/Arch Assembler | * Binary search
BINSRCH LA R5,TABLE Begin of table
SR R2,R2 low = 0
LA R3,ENTRIES-1 high = N-1
LOOP CR R2,R3 while (low <= high)
JH NOTFOUND { ... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #SequenceL | SequenceL | main := toBinaryString([5, 50, 9000]);
toBinaryString(number(0)) :=
let
val := "1" when number mod 2 = 1 else "0";
in
toBinaryString(floor(number/2)) ++ val when floor(number/2) > 0
else
val; |
http://rosettacode.org/wiki/Binary_search | Binary search | A binary search divides a range of values into halves, and continues to narrow down the field of search until the unknown value is found. It is the classic example of a "divide and conquer" algorithm.
As an analogy, consider the children's game "guess a number." The scorer has a secret number, and will only tell the p... | #zkl | zkl | fcn bsearch(list,value){ // list is sorted
fcn(list,value, low,high){
if (high < low) return(Void); // not found
mid:=(low + high) / 2;
if (list[mid] > value) return(self.fcn(list,value, low, mid-1));
if (list[mid] < value) return(self.fcn(list,value, mid+1, high));
return(mid); // ... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Sidef | Sidef | [5, 50, 9000].each { |n|
say n.as_bin;
} |
http://rosettacode.org/wiki/Binary_search | Binary search | A binary search divides a range of values into halves, and continues to narrow down the field of search until the unknown value is found. It is the classic example of a "divide and conquer" algorithm.
As an analogy, consider the children's game "guess a number." The scorer has a secret number, and will only tell the p... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 DATA 2,3,5,6,8,10,11,15,19,20
20 DIM t(10)
30 FOR i=1 TO 10
40 READ t(i)
50 NEXT i
60 LET value=4: GO SUB 100
70 LET value=8: GO SUB 100
80 LET value=20: GO SUB 100
90 STOP
100 REM Binary search
110 LET lo=1: LET hi=10
120 IF lo>hi THEN LET idx=0: GO TO 170
130 LET middle=INT ((hi+lo)/2)
140 IF value<t(middle) THEN... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Simula | Simula | BEGIN
PROCEDURE OUTINTBIN(N); INTEGER N;
BEGIN
IF N > 1 THEN OUTINTBIN(N//2);
OUTINT(MOD(N,2),1);
END OUTINTBIN;
INTEGER SAMPLE;
FOR SAMPLE := 5, 50, 9000 DO BEGIN
OUTINTBIN(SAMPLE);
OUTIMAGE;
END;
END |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #SkookumScript | SkookumScript | println(5.binary)
println(50.binary)
println(9000.binary) |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Smalltalk | Smalltalk | 5 printOn: Stdout radix:2
50 printOn: Stdout radix:2
9000 printOn: Stdout radix:2 |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Action.21 | Action! | BYTE FUNC FindIndex(BYTE b)
IF b>='A AND b<='Z THEN
RETURN (b-'A)
ELSEIF b>='a AND b<='z THEN
RETURN (b-'a+26)
ELSEIF b>='0 AND b<='9 THEN
RETURN (b-'0+52)
ELSEIF b='+ THEN
RETURN (62)
ELSEIF b='/ THEN
RETURN (63)
FI
RETURN (-1)
PROC PrintChar(CHAR c)
IF c=10 THEN
PutE()
ELSE
... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #SNOBOL4 | SNOBOL4 |
define('bin(n,r)') :(bin_end)
bin bin = le(n,0) r :s(return)
bin = bin(n / 2, REMDR(n,2) r) :(return)
bin_end
output = bin(5)
output = bin(50)
output = bin(9000)
end |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #SNUSP | SNUSP |
/recurse\
$,binary!\@\>?!\@/<@\.#
! \=/ \=itoa=@@@+@+++++#
/<+>- \ div2
\?!#-?/+# mod2
|
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Ada | Ada | with Ada.Text_IO;
with AWS.Translator;
procedure Decode_AWS is
Input : constant String :=
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" &
"IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
Result : constant String := AWS.Translator.Base64_Decode (Input);
begin
Ada.T... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Arturo | Arturo | text: "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
print decode text |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Standard_ML | Standard ML | print (Int.fmt StringCvt.BIN 5 ^ "\n");
print (Int.fmt StringCvt.BIN 50 ^ "\n");
print (Int.fmt StringCvt.BIN 9000 ^ "\n"); |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Swift | Swift | for num in [5, 50, 9000] {
println(String(num, radix: 2))
} |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #BaCon | BaCon | data$ = "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAE.......QAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAE="
ico$ = B64DEC$(data$)
BSAVE ico$ TO "favicon.ico" SIZE LEN(ico$) |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Bash | Bash | #! /bin/bash
declare -a encodeTable=(
# + , - . / 0 1 2 3 4 5 6 7 8 9 :
62 -1 -1 -1 63 52 53 54 55 56 57 58 59 60 61 -1
# ; < = > ? @ A B C D E F G H I J
-1 -1 -1 -1 -1 -1 0 1 2 3 4 5 6 7 8 9
# K L M N O P ... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Tcl | Tcl | proc num2bin num {
# Convert to _fixed width_ big-endian 32-bit binary
binary scan [binary format "I" $num] "B*" binval
# Strip useless leading zeros by reinterpreting as a big decimal integer
scan $binval "%lld"
} |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #TI-83_BASIC | TI-83 BASIC | PROGRAM:BINARY
:Disp "NUMBER TO"
:Disp "CONVERT:"
:Input A
:0→N
:0→B
:While 2^(N+1)≤A
:N+1→N
:End
:While N≥0
:iPart(A/2^N)→C
:10^(N)*C+B→B
:If C=1
:Then
:A-2^N→A
:End
:N-1→N
:End
:Disp B |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #C | C | #include <stdio.h>
#include <stdlib.h>
typedef unsigned char ubyte;
const ubyte BASE64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int findIndex(const ubyte val) {
if ('A' <= val && val <= 'Z') {
return val - 'A';
}
if ('a' <= val && val <= 'z') {
return val -... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #uBasic.2F4tH | uBasic/4tH | Do
Input "Enter base (1<X<17): "; b
While (b < 2) + (b > 16)
Loop
Input "Enter number: "; n
s = (n < 0) ' save the sign
n = Abs(n) ' make number unsigned
For x = 0 Step 1 Until n = 0 ' calculate all the digits
@(x) = n % b
n = n / b
Next x... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #UNIX_Shell | UNIX Shell | # Define a function to output binary digits
tobinary() {
# We use the bench calculator for our conversion
echo "obase=2;$1"|bc
}
# Call the function with each of our values
tobinary 5
tobinary 50 |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #C.23 | C# | using System;
using System.Text;
namespace Base64DecodeData {
class Program {
static void Main(string[] args) {
var data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
Console.WriteLine(data);
... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #C.2B.2B | C++ | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef unsigned char ubyte;
const auto BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
std::vector<ubyte> encode(const std::vector<ubyte>& source) {
auto it = source.cbegin();
auto end = source.cend();... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #VBA | VBA |
Option Explicit
Sub Main_Dec2bin()
Dim Nb As Long
Nb = 5
Debug.Print "The decimal value " & Nb & " should produce an output of : " & DecToBin(Nb)
Debug.Print "The decimal value " & Nb & " should produce an output of : " & DecToBin2(Nb)
Nb = 50
Debug.Print "The decimal value " & Nb & " should produce an ... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Cach.C3.A9_ObjectScript | Caché ObjectScript | USER>Write $System.Encryption.Base64Decode("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=")
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrli... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Clojure | Clojure | (defn decode [str]
(String. (.decode (java.util.Base64/getDecoder) str)))
(decode "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=")
|
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Vedit_macro_language | Vedit macro language | repeat (ALL) {
#10 = Get_Num("Give a numeric value, -1 to end: ", STATLINE)
if (#10 < 0) { break }
Call("BINARY")
Update()
}
return
:BINARY:
do {
Num_Ins(#10 & 1, LEFT+NOCR)
#10 = #10 >> 1
Char(-1)
} while (#10 > 0)
EOL
Ins_Newline
Return |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Common_Lisp | Common Lisp | (eval-when (:load-toplevel :compile-toplevel :execute)
(ql:quickload "cl-base64"))
;; * The package definition
(defpackage :base64-decode
(:use :common-lisp :cl-base64))
(in-package :base64-decode)
;; * The encoded data
(defvar *base64-data*
"AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAEAAAACAAAAA... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Vim_Script | Vim Script | function Num2Bin(n)
let n = a:n
let s = ""
if n == 0
let s = "0"
else
while n
if n % 2 == 0
let s = "0" . s
else
let s = "1" . s
endif
let n = n / 2
endwhile
endif
return s
endfunction
echo ... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Crystal | Crystal | require "base64"
encoded_string = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
decoded_string = Base64.decode_string(encoded_string)
puts decoded_string |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #D | D | import std.base64;
import std.stdio;
void main() {
auto data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
writeln(data);
writeln;
auto decoded = cast(char[])Base64.decode(data);
writeln(decoded);
} |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Visual_Basic | Visual Basic |
Public Function Bin(ByVal l As Long) As String
Dim i As Long
If l Then
If l And &H80000000 Then 'negative number
Bin = "1" & String$(31, "0")
l = l And (Not &H80000000)
For i = 0 To 30
If l And (2& ^ i) Then
Mid$(Bin, Len(Bin) - i) = "1"
End If
Next i
Else ... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Dart | Dart | import 'dart:convert';
void main() {
var encoded = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
var decoded = utf8.decode(base64.decode(encoded));
print(decoded);
} |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Delphi | Delphi | program Base64Decoder;
{$APPTYPE CONSOLE}
uses
System.SysUtils, System.NetEncoding;
const
Src = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=';
begin
WriteLn(Format('Source string: ' + sLineBreak + '"%s"', [Src]));
WriteLn(Forma... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Visual_Basic_.NET | Visual Basic .NET | Module Program
Sub Main
For Each number In {5, 50, 9000}
Console.WriteLine(Convert.ToString(number, 2))
Next
End Sub
End Module |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Visual_FoxPro | Visual FoxPro |
*!* Binary Digits
CLEAR
k = CAST(5 As I)
? NToBin(k)
k = CAST(50 As I)
? NToBin(k)
k = CAST(9000 As I)
? NToBin(k)
FUNCTION NTOBin(n As Integer) As String
LOCAL i As Integer, b As String, v As Integer
b = ""
v = HiBit(n)
FOR i = 0 TO v
b = IIF(BITTEST(n, i), "1", "0") + b
ENDFOR
RETURN b
ENDFUNC
FUNCTION HiBi... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #F.23 | F# |
open System
open System.IO
let encoded = "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wCGiYcARkhHAL/CwAAmKScAam1rAOPm5ACgo6EAV1pYABcZGADO0c8AODs5AK2wrgBzdnQA6+7sAPz//QAAAwEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Factor | Factor | USING: base64 io strings ;
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
base64> >string print |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Whitespace | Whitespace | |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Forth | Forth | variable bitsbuff
: char>6bits ( c -- u )
dup 43 = if drop 62 exit then ( + case )
dup 47 = if drop 63 exit then ( / case )
dup 48 58 within if 48 - 52 + exit then ( 0-9 case )
dup 65 91 within if 65 - exit then ( A-Z case )
dup 97 123 within if 97 - 26 + exit t... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #FreeBASIC | FreeBASIC | Dim Shared As String B64
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" & _
"abcdefghijklmnopqrstuvwxyz" & _
"0123456789+/"
Function MIMEDecode(s As String ) As Integer
If Len(s) Then
MIMEdecode = Instr(B64,s) - 1
Else
MIMEdecode = -1
End If
End Function
Function Decode64(s As String) As String
... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Vlang | Vlang | fn main() {
for i in 0..16 {
println("${i:b}")
}
} |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Go | Go | package main
import (
"encoding/base64"
"fmt"
)
func main() {
msg := "Rosetta Code Base64 decode data task"
fmt.Println("Original :", msg)
encoded := base64.StdEncoding.EncodeToString([]byte(msg))
fmt.Println("\nEncoded :", encoded)
decoded, err := base64.StdEncoding.DecodeString(encode... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Groovy | Groovy | import java.nio.charset.StandardCharsets
class Decode {
static void main(String[] args) {
String data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
Base64.Decoder decoder = Base64.getDecoder()
byte[] decoded = d... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #VTL-2 | VTL-2 | 10 N=5
20 #=100
30 N=50
40 #=100
50 N=9000
100 ;=!
110 I=18
120 I=I-1
130 N=N/2
140 :I)=%
150 #=0<N*120
160 ?=:I)
170 I=I+1
180 #=I<18*160
190 ?=""
200 #=; |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Wortel | Wortel | \.toString 2
; the following function also casts the string to a number
^(@+ \.toString 2) |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Haskell | Haskell | --Decodes Base64 to ASCII
import qualified Data.Map.Strict as Map (Map, lookup, fromList)
import Data.Maybe (fromJust, listToMaybe, mapMaybe)
import Numeric (readInt, showIntAtBase)
import Data.Char (chr, digitToInt)
import Data.List.Split (chunksOf)
byteToASCII :: String -> String
byteToASCII = map chr . decoder
-... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #11l | 11l | F qmean(num)
R sqrt(sum(num.map(n -> n * n)) / Float(num.len))
print(qmean(1..10)) |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Wren | Wren | import "/fmt" for Fmt
System.print("Converting to binary:")
for (i in [5, 50, 9000]) Fmt.print("$d -> $b", i, i) |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Haxe | Haxe | class Main {
static function main() {
var data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
"IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
Sys.println('$data\n');
var decoded = haxe.crypto.Base64.decode(data);
Sys.println(decoded);
}
} |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #J | J | require'convert/misc/base64'
frombase64 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #Action.21 | Action! | INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
BYTE FUNC Equal(REAL POINTER a,b)
BYTE ARRAY x,y
x=a y=b
IF x(0)=y(0) AND x(1)=y(1) AND x(2)=y(2) THEN
RETURN (1)
FI
RETURN (0)
PROC Sqrt(REAL POINTER a,b)
REAL z,half
IntToReal(0,z)
ValR("0.5",half)
IF Equal(a,z) THEN
RealAssign(z,b)
... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #Ada | Ada | with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
type float_arr is array(1..10) of Float;
function rms(nums : float_arr) return Float is
sum : Float := 0.0;
begin
for p in nums'Range loop
sum := sum + nums(p)*... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #X86_Assembly | X86 Assembly | .model tiny
.code
.486
org 100h
start: mov ax, 5
call binout
call crlf
mov ax, 50
call binout
call crlf
mov ax, 9000
call binout
crlf: mov al, 0Dh ;new line
int 29h
... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Java | Java | import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class Decode {
public static void main(String[] args) {
String data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
Base64.Decoder decoder = Base6... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #JavaScript | JavaScript | // define base64 data; in this case the data is the string: "Hello, world!"
const base64 = 'SGVsbG8sIHdvcmxkIQ==';
// atob is a built-in function.
console.log(atob(base64)); |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #ALGOL_68 | ALGOL 68 | # Define the rms PROCedure & ABS OPerators for LONG... REAL #
MODE RMSFIELD = #LONG...# REAL;
PROC (RMSFIELD)RMSFIELD rms field sqrt = #long...# sqrt;
INT rms field width = #long...# real width;
PROC crude rms = ([]RMSFIELD v)RMSFIELD: (
RMSFIELD sum := 0;
FOR i FROM LWB v TO UPB v DO sum +:= v[i]**2 OD;
rms fi... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #XPL0 | XPL0 | include c:\cxpl\codes; \intrinsic code declarations
proc BinOut(N); \Output N in binary
int N;
int R;
[R:= N&1;
N:= N>>1;
if N then BinOut(N);
ChOut(0, R+^0);
];
int I;
[I:= 0;
repeat BinOut(I); CrLf(0);
I:= I+1;
until KeyHit or I=0;
] |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Yabasic | Yabasic | dim a(3)
a(0) = 5
a(1) = 50
a(2) = 9000
for i = 0 to 2
print a(i) using "####", " -> ", bin$(a(i))
next i
end |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #jq | jq | jq -rR base64d
|
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Jsish | Jsish | /* Base64 decode, in Jsish */
var data = exec('jsish base64.jsi', {retAll:true}).data; // or use File.read('stdin');
var icon = Util.base64(data, true);
File.write('rosetta-favicon.ico', icon); |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #ALGOL-M | ALGOL-M |
BEGIN
DECIMAL FUNCTION SQRT(X);
DECIMAL X;
BEGIN
DECIMAL R1, R2, TOL;
TOL := .00001; % reasonable for most purposes %
IF X >= 1.0 THEN
BEGIN
R1 := X;
R2 := 1.0;
END
ELSE
BEGIN
R1 := 1.0;
R2 := X;
END;
WHILE (R1-R2) > TOL DO
... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #ALGOL_W | ALGOL W | begin
% computes the root-mean-square of an array of numbers with %
% the specified lower bound (lb) and upper bound (ub) %
real procedure rms( real array numbers ( * )
; integer value lb
; integer value ub
... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #Z80_Assembly | Z80 Assembly | org &8000
PrintChar equ &BB5A ;syscall - prints accumulator to Amstrad CPC's screen
main:
ld hl,TestData0
call PrintBinary_NoLeadingZeroes
ld hl,TestData1
call PrintBinary_NoLeadingZeroes
ld hl,TestData2
call PrintBinary_NoLeadingZeroes
ret
TestData0:
byte 5,255
TestData1:
byte 5,0,255
Test... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Julia | Julia | using Base64
io = IOBuffer()
iob64_decode = Base64DecodePipe(io)
write(io, "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo")
seekstart(io)
println(String(read(iob64_decode)))
|
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Kotlin | Kotlin | import java.util.Base64
fun main() {
val data =
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
val decoder = Base64.getDecoder()
val decoded = decoder.decode(data)
val decodedStr = String(decoded, Charsets.UTF_8)
p... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #APL | APL | rms←{((+/⍵*2)÷⍴⍵)*0.5}
x←⍳10
rms x
6.204836823 |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #AppleScript | AppleScript | -- rootMeanSquare :: [Num] -> Real
on rootMeanSquare(xs)
script
on |λ|(a, x)
a + x * x
end |λ|
end script
(foldl(result, 0, xs) / (length of xs)) ^ (1 / 2)
end rootMeanSquare
-- TEST -----------------------------------------------------------------------
on run
rootMe... |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #zkl | zkl | (9000).toString(2) |
http://rosettacode.org/wiki/Binary_digits | Binary digits | Task
Create and display the sequence of binary digits for a given non-negative integer.
The decimal value 5 should produce an output of 101
The decimal value 50 should produce an output of 110010
The decimal value 9000 should produce an output of 10001100101000
... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 LET n=5: GO SUB 1000: PRINT s$
20 LET n=50: GO SUB 1000: PRINT s$
30 LET n=9000: GO SUB 1000: PRINT s$
999 STOP
1000 REM convert to binary
1010 LET t=n: REM temporary variable
1020 LET s$="": REM this will contain our binary digits
1030 LET sf=0: REM output has not started yet
1040 FOR l=126 TO 0 STEP -1
1050 LET d$... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Lua | Lua | -- Start taken from https://stackoverflow.com/a/35303321
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding
-- decoding
function dec(data)
data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
if (x == '=') th... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #Arturo | Arturo | rootMeanSquare: function [arr]->
sqrt (sum map arr 'i -> i^2) // size arr
print rootMeanSquare 1..10 |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #Astro | Astro | sqrt(mean(x²)) |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | ImportString[
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo",
"Base64"
] |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Nim | Nim | import base64
const Source = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
echo Source.decode() |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #AutoHotkey | AutoHotkey | MsgBox, % RMS(1, 10)
;---------------------------------------------------------------------------
RMS(a, b) { ; Root Mean Square of integers a through b
;---------------------------------------------------------------------------
n := b - a + 1
Loop, %n%
Sum += (a + A_Index - 1) ** 2
Return, Sqr... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #AWK | AWK | #!/usr/bin/awk -f
# computes RMS of the 1st column of a data file
{
x = $1; # value of 1st column
S += x*x;
N++;
}
END {
print "RMS: ",sqrt(S/N);
} |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #OCaml | OCaml | # let plain = Base64.decode_exn enc;;
val plain : string =
"\000\000\001\000\002\000\016\016\000\000\000\000\000\000h\005\000\000&\000"... (* string length 3638; truncated *)
|
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Ol | Ol |
(define base64-codes "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
(define kernel (alist->ff (map cons (string->bytes base64-codes) (iota (string-length base64-codes)))))
; returns n bits from input binary stream
(define (bits n hold)
(let loop ((hold hold))
(vector-apply hold (lambda... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #BASIC | BASIC | DIM i(1 TO 10) AS DOUBLE, L0 AS LONG
FOR L0 = 1 TO 10
i(L0) = L0
NEXT
PRINT STR$(rms#(i()))
FUNCTION rms# (what() AS DOUBLE)
DIM L0 AS LONG, tmp AS DOUBLE, rt AS DOUBLE
FOR L0 = LBOUND(what) TO UBOUND(what)
rt = rt + (what(L0) ^ 2)
NEXT
tmp = UBOUND(what) - LBOUND(what) + 1
rms# = SQR(... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Perl | Perl | sub decode_base64 {
my($d) = @_;
$d =~ tr!A-Za-z0-9+/!!cd;
$d =~ s/=+$//;
$d =~ tr!A-Za-z0-9+/! -_!;
my $r = '';
while( $d =~ /(.{1,60})/gs ){
my $len = chr(32 + length($1)*3/4);
$r .= unpack("u", $len . $1 );
}
$r;
}
$data = <<EOD;
J1R3YXMgYnJpbGxpZywgYW5kIHRoZSBzbGl0a... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Phix | Phix | with javascript_semantics
include builtins\base64.e
string s = "Rosetta Code Base64 decode data task"
string e = encode_base64(s)
?e
?decode_base64(e)
|
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #BQN | BQN | RMS ← √+´∘ט÷≠
RMS 1+↕10 |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #C | C | #include <stdio.h>
#include <math.h>
double rms(double *v, int n)
{
int i;
double sum = 0.0;
for(i = 0; i < n; i++)
sum += v[i] * v[i];
return sqrt(sum / n);
}
int main(void)
{
double v[] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
printf("%f\n", rms(v, sizeof(v)/sizeof(double)));
return 0;
} |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #PHP | PHP | $encoded = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw' .
'IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=';
echo
$encoded, PHP_EOL,
base64_decode($encoded), PHP_EOL; |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #PicoLisp | PicoLisp | (setq *Char64
`'(chop
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) )
(de decode64 (S)
(let S (chop S)
(pack
(make
(while S
(let
(A (dec (index (++ S) *Char64))
B (dec (index (++ S) *Char64))
... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #C.23 | C# | using System;
namespace rms
{
class Program
{
static void Main(string[] args)
{
int[] x = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
Console.WriteLine(rootMeanSquare(x));
}
private static double rootMeanSquare(int[] x)
{
... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Pike | Pike |
string icon = Protocols.HTTP.get_url_data("http://rosettacode.org/favicon.ico");
string encoded = MIME.encode_base64(icon);
Stdio.write_file("favicon.ico", MIME.decode_base64(encoded));
|
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Prolog | Prolog | ?- Encoded = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=',
base64(Plain, Encoded).
Plain = 'To err is human, but to really foul things up you need a computer.\n -- Paul R. Ehrlich'.
|
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #C.2B.2B | C++ | #include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
int main( ) {
std::vector<int> numbers ;
for ( int i = 1 ; i < 11 ; i++ )
numbers.push_back( i ) ;
double meansquare = sqrt( ( std::inner_product( numbers.begin(), numbers.end(), numbers.begin(), 0 ) ) / static_cast<double>( numbers.s... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #PureBasic | PureBasic | b64cd$ = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
"IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
*p_buf = AllocateMemory(1024)
Base64Decoder(b64cd$, *p_buf, 1024)
OpenConsole("") : PrintN(PeekS(*p_buf, -1, #PB_UTF8))
Input() |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #Python | Python |
import base64
data = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
print(base64.b64decode(data).decode('utf-8'))
|
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #Clojure | Clojure |
(defn rms [xs]
(Math/sqrt (/ (reduce + (map #(* % %) xs))
(count xs))))
(println (rms (range 1 11))) |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #COBOL | COBOL | IDENTIFICATION DIVISION.
PROGRAM-ID. QUADRATIC-MEAN-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 QUADRATIC-MEAN-VARS.
05 N PIC 99 VALUE 0.
05 N-SQUARED PIC 999.
05 RUNNING-TOTAL PIC 999 VALUE 0.
05 MEAN-OF-SQUARES PIC 99V9(16).
05 QUADRATIC-MEAN PIC 9V9(15... |
http://rosettacode.org/wiki/Base64_decode_data | Base64 decode data | See Base64 encode data.
Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously... | #QB64 | QB64 | Option _Explicit
Dim As String udata, decoded
udata = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
decoded = decode(udata)
Print udata
Print decoded
Function findIndex& (value As _Unsigned _Byte)
If Asc("A") <= value And value <= Asc(... |
http://rosettacode.org/wiki/Averages/Root_mean_square | Averages/Root mean square | Task[edit]
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean.
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
x
r
m
s
=
x
1
2
+
x
2
2
+
⋯
+
x
... | #CoffeeScript | CoffeeScript | root_mean_square = (ary) ->
sum_of_squares = ary.reduce ((s,x) -> s + x*x), 0
return Math.sqrt(sum_of_squares / ary.length)
alert root_mean_square([1..10]) |
Subsets and Splits
Rosetta Code COBOL Python Hard Tasks
Identifies and retrieves challenging tasks that exist in both COBOL and Python, revealing cross-language programming patterns and difficulty levels for comparative analysis.
Rosetta Code Task Comparisons
Identifies tasks common to both COBOL and Python languages that are described as having difficulty levels, revealing cross-language task similarities and providing useful comparative programming examples.
Select Specific Languages Codes
Retrieves specific programming language names and codes from training data, providing basic filtering but limited analytical value beyond identifying these particular languages.