This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closure generateRandomEan13 = { | |
// Primeiro executamos os metodos de geracao | |
List<Integer> listaAleatoria = new ArrayList(); | |
for (int i = 0; i < 12; i++) { | |
listaAleatoria.add((int) (Math.random() * 10)); | |
} | |
int totalSomatoria = 0; | |
// Metade dos números vai ser somado sem ser multiplicado |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getArrCombos = (arr, comboSize) => { | |
let combos = arr.reduce( (acc, v, i) => { | |
if (comboSize === 1) { | |
return acc.concat([[v]]) | |
} else { | |
arrCombo = getArrCombos(arr.slice(i+1), comboSize - 1); | |
return acc.concat(arrCombo.map( w => [v].concat(w))); | |
} | |
}, []); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closure isPisValid = { String pis -> | |
final List tap = [3,2,9,8,7,6,5,4,3,2] | |
String nroPis = pis.replaceAll("[^0-9]*", "").padLeft(11, '0') | |
int checker = Integer.parseInt( | |
String.valueOf(nroPis.charAt(nroPis.length()-1)) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example | |
import griffon.core.artifact.GriffonController | |
import griffon.metadata.ArtifactProviderFor | |
@ArtifactProviderFor(GriffonController) | |
class ExemploActionsController { | |
ExemploActionsModel model | |
void somarAction() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
while vcod_pagamento <= 999 loop | |
-- | |
begin | |
-- | |
ps_var.valor_pagamento(vcod_pagamento) := ps_var.valor_pagamento(vcod_pagamento); | |
-- | |
exception when no_data_found then | |
-- | |
ps_var.valor_pagamento(vcod_pagamento) := 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print 'Digite os valores a serem ordenados separados por virgula:' | |
valores = [2,5,3,9,8,4] | |
def merge_sort(li): | |
if len(li) < 2: return li | |
m = len(li) / 2 | |
return merge(merge_sort(li[:m]), merge_sort(li[m:])) | |
def merge(l, r): | |
result = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print 'Digite os valores a serem ordenados separados por virgula:' | |
valores = [2,5,3,9,8] | |
def selection_sort(list): | |
l=list[:] # create a copy of the list | |
sorted=[] # this new list will hold the results | |
while len(l): # while there are elements to sort... | |
lowest=l[0] # create a variable to identify lowest | |
for x in l: # and check every item in the list... | |
if x<lowest: # to see if it might be lower. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print 'Digite os valores a serem ordenados separados por virgula:' | |
valores = [2,5,3,9,8] | |
def bubbleSort(numbers): # Bubble Sort Algorithm | |
nums = list(numbers) | |
for i in range(len(nums)): | |
for j in range(i+1, len(nums)): | |
if numbers[j] < numbers[i]: | |
numbers[j], numbers[i] = numbers[i], numbers[j] |