From 73d0deef8bad64e542f73982789bebeb50e347a4 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 23 Jul 2017 19:59:49 +0200 Subject: clear --- .kdev4/esercizi.kdev4 | 10 ++++++++++ cpp/Makefile | 3 +++ java/somme.java | 35 ---------------------------------- python/.kdev4/python.kdev4 | 30 +++++++++++++++++++++++++++++ python/crittografa.py | 2 +- python/palindroma.py | 29 +++++++++++++++++----------- python/python.kdev4 | 3 +++ ruby/conversioneBinariaDec.ru | 32 ------------------------------- ruby/lswf.rb | 44 ------------------------------------------- 9 files changed, 65 insertions(+), 123 deletions(-) create mode 100644 .kdev4/esercizi.kdev4 create mode 100644 cpp/Makefile delete mode 100644 java/somme.java create mode 100644 python/.kdev4/python.kdev4 create mode 100644 python/python.kdev4 delete mode 100644 ruby/conversioneBinariaDec.ru delete mode 100644 ruby/lswf.rb diff --git a/.kdev4/esercizi.kdev4 b/.kdev4/esercizi.kdev4 new file mode 100644 index 0000000..bc55a08 --- /dev/null +++ b/.kdev4/esercizi.kdev4 @@ -0,0 +1,10 @@ +[Buildset] +BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x10\x00e\x00s\x00e\x00r\x00c\x00i\x00z\x00i) + +[Defines And Includes][Compiler] +Name=GCC +Path=gcc +Type=GCC + +[Project] +VersionControlSupport=kdevgit diff --git a/cpp/Makefile b/cpp/Makefile new file mode 100644 index 0000000..49aaacf --- /dev/null +++ b/cpp/Makefile @@ -0,0 +1,3 @@ +all: + g++ -std=c++11 -Wall $1.cpp -o $1 + diff --git a/java/somme.java b/java/somme.java deleted file mode 100644 index c1da9d5..0000000 --- a/java/somme.java +++ /dev/null @@ -1,35 +0,0 @@ -import java.util.Scanner; - -public class HelloWorld { - private static boolean pari(int n) { - return (n % 2) == 0; - } - - private static int sequenza(int n, boolean pollatz, int tCollatz) { - int m = ((pollatz) ? 5 : 3), tot = 1; - - while(n != 1) { - n = (pari(n)) ? n/2 : n*m+1; - - tot++; - - if(tCollatz != -1 && tot > tCollatz) - break; - } - - return tot; - } - - public static void main(String[] args) { - Scanner in = new Scanner(System.in); - int N1 = in.nextInt(), N2 = in.nextInt(), tot = 0, collatz; - - for(int i = N1; i <= N2; i++) { - collatz = sequenza(i, false, -1); - if(sequenza(i, true, collatz) < collatz ) - tot++; - } - - System.out.println(tot); - } -} diff --git a/python/.kdev4/python.kdev4 b/python/.kdev4/python.kdev4 new file mode 100644 index 0000000..ccb47d8 --- /dev/null +++ b/python/.kdev4/python.kdev4 @@ -0,0 +1,30 @@ +[Buildset] +BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x0c\x00p\x00y\x00t\x00h\x00o\x00n) + +[Defines And Includes][Compiler] +Name=GCC +Path=gcc +Type=GCC + +[Launch] +Launch Configurations=Launch Configuration 0 + +[Launch][Launch Configuration 0] +Configured Launch Modes=execute +Configured Launchers=scriptAppLauncher +Name=New Script Application Launcher +Type=Script Application + +[Launch][Launch Configuration 0][Data] +Arguments=1010010 +EnvironmentGroup= +Executable= +Execute on Remote Host=false +Interpreter=python3 +Output Filtering Mode=2 +Remote Host= +Run current file=true +Working Directory= + +[Project] +VersionControlSupport=kdevgit diff --git a/python/crittografa.py b/python/crittografa.py index 3c904d5..6df0fc8 100644 --- a/python/crittografa.py +++ b/python/crittografa.py @@ -27,7 +27,6 @@ with open('input.txt', 'r') as fin: for line in fin.readlines(): parole += line - for i in parole: converti(i) @@ -35,3 +34,4 @@ for i in parole: with open('output.txt', 'w') as fout: for i in nuovaParola: fout.write(i) + diff --git a/python/palindroma.py b/python/palindroma.py index af82a04..6c3a7e9 100644 --- a/python/palindroma.py +++ b/python/palindroma.py @@ -1,15 +1,22 @@ -def palindromo(parola, start, end): - if start >= end: - return True - elif parola[start] == parola[end]: - return palindromo(parola, start+1 , end-1) - else: - return False +# def palindromo(parola, start, end): +# if start >= end: +# return True +# elif parola[start] == parola[end]: +# return palindromo(parola, start+1 , end-1) +# else: +# return False +# +# +# parola = input('Parola: ') +# +# if palindromo(parola, 0, len(parola)-1): +# print('Palindroma') +# else: +# print('Non palindroma') +parola = raw_input('Parola: ') -parola = input('Parola: ') - -if palindromo(parola, 0, len(parola)-1): +if parola == parola[::-1]: print('Palindroma') else: - print('Non palindroma') + print('Non palindroma') \ No newline at end of file diff --git a/python/python.kdev4 b/python/python.kdev4 new file mode 100644 index 0000000..9d6efbd --- /dev/null +++ b/python/python.kdev4 @@ -0,0 +1,3 @@ +[Project] +Manager=KDevGenericManager +Name=python diff --git a/ruby/conversioneBinariaDec.ru b/ruby/conversioneBinariaDec.ru deleted file mode 100644 index c506372..0000000 --- a/ruby/conversioneBinariaDec.ru +++ /dev/null @@ -1,32 +0,0 @@ -b = 32 -v = Array.new(b, 0) - -stringa = gets.to_s - -unless stringa.size > b then - valVuoto = stringa.size -end - -i = b - valVuoto -j = 0 - -loop do - v[i] = stringa[j].to_i - - i += 1 - j += 1 - - break unless i < b -end - -i = b - 1 -j = 0 -num = 0 - -while i > -1 do - num += v[i] * (2 ** j) - i -= 1 - j += 1 -end - -puts num/2 diff --git a/ruby/lswf.rb b/ruby/lswf.rb deleted file mode 100644 index 236847e..0000000 --- a/ruby/lswf.rb +++ /dev/null @@ -1,44 +0,0 @@ -fib = [] -fib.push 1 -fib.push 1 - -def fibonacci(n, fib) - for i in 2...n do - fib.push fib[i-1] + fib[i-2] - - break if fib[i] > n - end - - return i -end - -File.open('input.txt', 'r') do |fin| - N = fin.gets.to_i -end - -fibonacci(N, fib) - -fib = fib.reverse - -somma = 0 -seq = [] - -for i in 0...fib.length-1 do - potSomma = somma + fib[i] - - if potSomma < N - somma = potSomma - seq << 1 - else - seq << 0 - end -end - -seq << 1 -seq = seq.reverse - -seq.pop if N == 1 || N > 4 - -File.open('output.txt', 'w') do |fout| - seq.each {|c| fout.print c} -end -- cgit v1.2.3-18-g5258