Best Python code snippet using hypothesis
512.js
Source:512.js
...83 // 32 x 32bit words84 for (var i = 0; i < 32; i++)85 W[i] = msg[start + i];86 for (; i < W.length; i += 2) {87 var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 288 var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);89 var c1_hi = W[i - 14]; // i - 790 var c1_lo = W[i - 13];91 var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 1592 var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);93 var c3_hi = W[i - 32]; // i - 1694 var c3_lo = W[i - 31];95 W[i] = sum64_4_hi(96 c0_hi, c0_lo,97 c1_hi, c1_lo,98 c2_hi, c2_lo,99 c3_hi, c3_lo);100 W[i + 1] = sum64_4_lo(101 c0_hi, c0_lo,102 c1_hi, c1_lo,103 c2_hi, c2_lo,104 c3_hi, c3_lo);105 }106};107SHA512.prototype._update = function _update(msg, start) {108 this._prepareBlock(msg, start);109 var W = this.W;110 var ah = this.h[0];111 var al = this.h[1];112 var bh = this.h[2];113 var bl = this.h[3];114 var ch = this.h[4];115 var cl = this.h[5];116 var dh = this.h[6];117 var dl = this.h[7];118 var eh = this.h[8];119 var el = this.h[9];120 var fh = this.h[10];121 var fl = this.h[11];122 var gh = this.h[12];123 var gl = this.h[13];124 var hh = this.h[14];125 var hl = this.h[15];126 assert(this.k.length === W.length);127 for (var i = 0; i < W.length; i += 2) {128 var c0_hi = hh;129 var c0_lo = hl;130 var c1_hi = s1_512_hi(eh, el);131 var c1_lo = s1_512_lo(eh, el);132 var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);133 var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);134 var c3_hi = this.k[i];135 var c3_lo = this.k[i + 1];136 var c4_hi = W[i];137 var c4_lo = W[i + 1];138 var T1_hi = sum64_5_hi(139 c0_hi, c0_lo,140 c1_hi, c1_lo,141 c2_hi, c2_lo,142 c3_hi, c3_lo,143 c4_hi, c4_lo);144 var T1_lo = sum64_5_lo(145 c0_hi, c0_lo,146 c1_hi, c1_lo,147 c2_hi, c2_lo,148 c3_hi, c3_lo,149 c4_hi, c4_lo);150 c0_hi = s0_512_hi(ah, al);151 c0_lo = s0_512_lo(ah, al);152 c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);153 c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);154 var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);155 var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);156 hh = gh;157 hl = gl;158 gh = fh;159 gl = fl;160 fh = eh;161 fl = el;162 eh = sum64_hi(dh, dl, T1_hi, T1_lo);163 el = sum64_lo(dl, dl, T1_hi, T1_lo);164 dh = ch;165 dl = cl;166 ch = bh;167 cl = bl;168 bh = ah;169 bl = al;170 ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);171 al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);172 }173 sum64(this.h, 0, ah, al);174 sum64(this.h, 2, bh, bl);175 sum64(this.h, 4, ch, cl);176 sum64(this.h, 6, dh, dl);177 sum64(this.h, 8, eh, el);178 sum64(this.h, 10, fh, fl);179 sum64(this.h, 12, gh, gl);180 sum64(this.h, 14, hh, hl);181};182SHA512.prototype._digest = function digest(enc) {183 if (enc === 'hex')184 return utils.toHex32(this.h, 'big');185 else186 return utils.split32(this.h, 'big');187};188function ch64_hi(xh, xl, yh, yl, zh) {189 var r = (xh & yh) ^ ((~xh) & zh);190 if (r < 0)191 r += 0x100000000;192 return r;193}194function ch64_lo(xh, xl, yh, yl, zh, zl) {195 var r = (xl & yl) ^ ((~xl) & zl);196 if (r < 0)197 r += 0x100000000;198 return r;199}200function maj64_hi(xh, xl, yh, yl, zh) {201 var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);202 if (r < 0)203 r += 0x100000000;204 return r;205}206function maj64_lo(xh, xl, yh, yl, zh, zl) {207 var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);208 if (r < 0)209 r += 0x100000000;210 return r;211}212function s0_512_hi(xh, xl) {213 var c0_hi = rotr64_hi(xh, xl, 28);214 var c1_hi = rotr64_hi(xl, xh, 2); // 34215 var c2_hi = rotr64_hi(xl, xh, 7); // 39216 var r = c0_hi ^ c1_hi ^ c2_hi;217 if (r < 0)218 r += 0x100000000;219 return r;220}221function s0_512_lo(xh, xl) {222 var c0_lo = rotr64_lo(xh, xl, 28);223 var c1_lo = rotr64_lo(xl, xh, 2); // 34224 var c2_lo = rotr64_lo(xl, xh, 7); // 39225 var r = c0_lo ^ c1_lo ^ c2_lo;226 if (r < 0)227 r += 0x100000000;228 return r;229}230function s1_512_hi(xh, xl) {231 var c0_hi = rotr64_hi(xh, xl, 14);232 var c1_hi = rotr64_hi(xh, xl, 18);233 var c2_hi = rotr64_hi(xl, xh, 9); // 41234 var r = c0_hi ^ c1_hi ^ c2_hi;235 if (r < 0)236 r += 0x100000000;237 return r;238}239function s1_512_lo(xh, xl) {240 var c0_lo = rotr64_lo(xh, xl, 14);241 var c1_lo = rotr64_lo(xh, xl, 18);242 var c2_lo = rotr64_lo(xl, xh, 9); // 41243 var r = c0_lo ^ c1_lo ^ c2_lo;244 if (r < 0)245 r += 0x100000000;246 return r;247}248function g0_512_hi(xh, xl) {249 var c0_hi = rotr64_hi(xh, xl, 1);250 var c1_hi = rotr64_hi(xh, xl, 8);251 var c2_hi = shr64_hi(xh, xl, 7);252 var r = c0_hi ^ c1_hi ^ c2_hi;253 if (r < 0)254 r += 0x100000000;255 return r;256}257function g0_512_lo(xh, xl) {258 var c0_lo = rotr64_lo(xh, xl, 1);259 var c1_lo = rotr64_lo(xh, xl, 8);260 var c2_lo = shr64_lo(xh, xl, 7);261 var r = c0_lo ^ c1_lo ^ c2_lo;262 if (r < 0)263 r += 0x100000000;264 return r;265}266function g1_512_hi(xh, xl) {267 var c0_hi = rotr64_hi(xh, xl, 19);268 var c1_hi = rotr64_hi(xl, xh, 29); // 61269 var c2_hi = shr64_hi(xh, xl, 6);270 var r = c0_hi ^ c1_hi ^ c2_hi;271 if (r < 0)272 r += 0x100000000;273 return r;274}275function g1_512_lo(xh, xl) {276 var c0_lo = rotr64_lo(xh, xl, 19);277 var c1_lo = rotr64_lo(xl, xh, 29); // 61278 var c2_lo = shr64_lo(xh, xl, 6);279 var r = c0_lo ^ c1_lo ^ c2_lo;280 if (r < 0)281 r += 0x100000000;282 return r;283}
bisect.py
Source:bisect.py
1"""Bisection algorithms."""2def insort_right(a, x, lo=0, hi=None):3 """Insert item x in list a, and keep it sorted assuming a is sorted.4 If x is already in a, insert it to the right of the rightmost x.5 Optional args lo (default 0) and hi (default len(a)) bound the6 slice of a to be searched.7 """8 if lo < 0:9 raise ValueError('lo must be non-negative')10 if hi is None:11 hi = len(a)12 while lo < hi:13 mid = (lo+hi)//214 if x < a[mid]: hi = mid15 else: lo = mid+116 a.insert(lo, x)17insort = insort_right # backward compatibility18def bisect_right(a, x, lo=0, hi=None):19 """Return the index where to insert item x in list a, assuming a is sorted.20 The return value i is such that all e in a[:i] have e <= x, and all e in21 a[i:] have e > x. So if x already appears in the list, a.insert(x) will22 insert just after the rightmost x already there.23 Optional args lo (default 0) and hi (default len(a)) bound the24 slice of a to be searched.25 """26 if lo < 0:27 raise ValueError('lo must be non-negative')28 if hi is None:29 hi = len(a)30 while lo < hi:31 mid = (lo+hi)//232 if x < a[mid]: hi = mid33 else: lo = mid+134 return lo35bisect = bisect_right # backward compatibility36def insort_left(a, x, lo=0, hi=None):37 """Insert item x in list a, and keep it sorted assuming a is sorted.38 If x is already in a, insert it to the left of the leftmost x.39 Optional args lo (default 0) and hi (default len(a)) bound the40 slice of a to be searched.41 """42 if lo < 0:43 raise ValueError('lo must be non-negative')44 if hi is None:45 hi = len(a)46 while lo < hi:47 mid = (lo+hi)//248 if a[mid] < x: lo = mid+149 else: hi = mid50 a.insert(lo, x)51def bisect_left(a, x, lo=0, hi=None):52 """Return the index where to insert item x in list a, assuming a is sorted.53 The return value i is such that all e in a[:i] have e < x, and all e in54 a[i:] have e >= x. So if x already appears in the list, a.insert(x) will55 insert just before the leftmost x already there.56 Optional args lo (default 0) and hi (default len(a)) bound the57 slice of a to be searched.58 """59 if lo < 0:60 raise ValueError('lo must be non-negative')61 if hi is None:62 hi = len(a)63 while lo < hi:64 mid = (lo+hi)//265 if a[mid] < x: lo = mid+166 else: hi = mid67 return lo68# Overwrite above definitions with a fast C implementation69try:70 from _bisect import *71except ImportError:...
func2.js
Source:func2.js
1function sayHi() {2 alert("Hi");3 // давайÑе поÑÑиÑаем, ÑколÑко вÑзовов Ð¼Ñ Ñделали4 sayHi.counter++;5}6sayHi.counter = 0; // наÑалÑное знаÑение7sayHi(); // Hi8sayHi(); // Hi9alert( `ÐÑзвана ${sayHi.counter} Ñаза` );10function sayHi() {11 alert("Hi");12}13alert(sayHi.name); // sayHi14let sayHi = function() {15 alert("Hi");16};17alert(sayHi.name); // sayHi (еÑÑÑ Ð¸Ð¼Ñ!)18function f(sayHi = function() {}) {19 alert(sayHi.name); // sayHi (ÑабоÑаеÑ!)20}21f();22let user = {23 sayHi() {24 // ...25 },26 sayBye: function() {27 // ...28 }29}30alert(user.sayHi.name); // sayHi31alert(user.sayBye.name); // sayBye32function f1(a) {}33function f2(a, b) {}34function many(a, b, ...more) {}35alert(f1.length); // 136alert(f2.length); // 237alert(many.length); // 238let sayHi = function func(who) {39 if (who) {40 alert(`Hello, ${who}`);41 } else {42 func("Guest"); // иÑполÑзÑÐµÑ func, ÑÑÐ¾Ð±Ñ Ñнова вÑзваÑÑ ÑÐµÐ±Ñ Ð¶Ðµ43 }44};45sayHi(); // Hello, Guest46// Ð Ð²Ð¾Ñ Ñак - не cÑабоÑаеÑ:47func(); // ÐÑибка, func не опÑеделена48let sum = new Function('a', 'b', 'return a + b');49alert( sum(1, 2) ); // 350let str = ... код, полÑÑеннÑй Ñ ÑеÑвеÑа динамиÑеÑки ...51let func = new Function(str);52func();53function getFunc() {54 let value = "test";55 let func = new Function('alert(value)');56 return func;57}...
remove.js
Source:remove.js
1/*2Description:3Remove n exclamation marks in the sentence from left to right.4n is positive integer.5Examples6remove("Hi!",1) === "Hi"7remove("Hi!",100) === "Hi"8remove("Hi!!!",1) === "Hi!!"9remove("Hi!!!",100) === "Hi"10remove("!Hi",1) === "Hi"11remove("!Hi!",1) === "Hi!"12remove("!Hi!",100) === "Hi"13remove("!!!Hi !!hi!!! !hi",1) === "!!Hi !!hi!!! !hi"14remove("!!!Hi !!hi!!! !hi",3) === "Hi !!hi!!! !hi"15remove("!!!Hi !!hi!!! !hi",5) === "Hi hi!!! !hi"16remove("!!!Hi !!hi!!! !hi",100) === "Hi hi hi"17Note18Please don't post issue about difficulty or duplicate.19*/20function remove(s,n){21 var result = '';22 var count = n;23 for (var i = 0; i < s.length; i++){24 if (s.charAt(i) !== '!' || count <= 0){25 result += s.charAt(i);26 } else {27 count--;28 }29 }30 return result;...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!