|
![]() |
#16 |
crà, crà
Join Date: Jan 2002
Posts: 13,828
|
Su quel forum ci sono mostri
![]() O semplicemente gente che ha studiato: Phi (golden ratio) is the approximate ratio between two consecutive terms in a Fibonacci sequence. The ratio between consecutive even terms approaches phi^3 (4.236068) because each 3rd term is even. Use a calculator and round the results to the nearest integer when calculating the next terms: 2,8,34,.. multiplying by 4.236068 each time: 144,610, 2584,10946,46368,196418 & 832040 The sum is 1089154 La sezione aurea me l'ha spiegata wikipedia ieri ![]() Sta a vedere che è la volta buona che mi metto a studiare matematica sul serio.
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat. Last edited by .Z.; 27th May 2007 at 20:43. |
![]() |
![]() |
![]() |
#17 |
lupetto supremo
Join Date: Mar 1999
Location: Bari
Posts: 12,829
|
ma questo trip è venuto solo a me e te?
Aresio, gh3 & co....avete perso punti in nerdaggine! ![]() |
![]() |
![]() |
![]() |
#19 |
~
Join Date: Jan 2006
Posts: 1,993
|
rosico
![]() |
![]() |
![]() |
![]() |
#20 |
Armata Baccanale
Join Date: Apr 2003
Location: /home/carlesso
Posts: 4,129
|
Quello dei palintromi fatto col rev mi ha dato soddisfazioni
![]()
__________________
The Big: the e.gmail filler Xperience OK, so you're a Ph.D. Just don't touch anything. Il mio sito, e il mio blog
|
![]() |
![]() |
![]() |
#21 |
lupetto supremo
Join Date: Mar 1999
Location: Bari
Posts: 12,829
|
Ecco una soluzione parziale al quesito 3, che ho dovuto scartare.
Dico parziale perchè l'algoritmo è il classico bruteforce poco efficiente, ed è castrato dal RecursionLimit di python (si può modificare, ma non mi va), che non permette di avere più di 1000 ricorsioni. La posto perchè presenta varie sboronaggini come la doppia ricorsione con funzioni annidate e la restituzione in output di più valori con una singola return. Python ![]() Code:
def factorize(n,f=[]): def getPrime(i): q,r = divmod(n,i) if r: return getPrime(i+1) else: f.append(i) return factorize(q,f) if n<>1:return getPrime(2),f else: return if __name__ == '__main__': a,b = factorize(13195) print max(b) Last edited by Darklord; 28th May 2007 at 17:45. |
![]() |
![]() |
![]() |
#22 |
Armata Baccanale
Join Date: Apr 2003
Location: /home/carlesso
Posts: 4,129
|
O mio dio quanto mi sento stronzo
![]() Quesito 19: How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? Code:
#!/bin/bash COUNT=0 for i in $(seq 1901 2000) ; do for j in $(seq 12); do if [ $(cal $j $i | head -n3 | tail -n1 | grep 7 | wc -l) == "1" ] ; then COUNT=$(( $COUNT + 1 )) fi done done echo There has been $COUNT mounth starting on Sunday :-\) ![]()
__________________
The Big: the e.gmail filler Xperience OK, so you're a Ph.D. Just don't touch anything. Il mio sito, e il mio blog
|
![]() |
![]() |
![]() |
#23 |
crà, crà
Join Date: Jan 2002
Posts: 13,828
|
![]() Per alcuni problemi bash è quasi un cheat. ![]()
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat. |
![]() |
![]() |
![]() |
#24 |
crà, crà
Join Date: Jan 2002
Posts: 13,828
|
E se non è stronza questa...
![]() Code:
# ncal label for "Sunday" in your locale (Su, do, ...) sunday=$(ncal | sed -n '$s/[ 0-9]//gp') echo -n "Answer: " # ncal outputs all the years from 1901 to 2000... for i in $(seq 1901 2000) ; do ncal $i done | # select only sundays... grep "^$sunday" | # verticalize output... tr -s [:space:] '\n' | # count ones. grep -c '^1$' ![]() Code:
< sunday=$(ncal | tail -n1 | grep -o '^\<[[:alpha:]]\{1,\}\>') --- > sunday=$(ncal | sed -n '$s/[ 0-9]//gp')
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat. Last edited by .Z.; 28th May 2007 at 19:41. |
![]() |
![]() |
![]() |
#25 |
lupetto supremo
Join Date: Mar 1999
Location: Bari
Posts: 12,829
|
ma quanto rulla Begoner?
trova sempre degli algoritmi matematici super efficienti. lo odio ![]() |
![]() |
![]() |
![]() |
#26 |
lupetto supremo
Join Date: Mar 1999
Location: Bari
Posts: 12,829
|
Il problema 5 l'ho fatto al primo tentativo con carta e penna
![]() |
![]() |
![]() |
![]() |
#27 |
lupetto supremo
Join Date: Mar 1999
Location: Bari
Posts: 12,829
|
soluzione python traccia 6...
volendo si fa tranqui con una sola riga: Code:
sumOfTheSquares = lambda x:sum(map(lambda x:x**2, range(2,x+1)))+1 squareOfTheSum = lambda x:pow(sum(range(1,x+1)),2) print squareOfTheSum(100)-sumOfTheSquares(100) |
![]() |
![]() |
![]() |
#28 |
crà, crà
Join Date: Jan 2002
Posts: 13,828
|
Qualcuno mi trovi il modo di selezionare l'i-esima cifra di un numero senza usare funzioni di libreria
![]()
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat. |
![]() |
![]() |
![]() |
#29 |
Armata Baccanale
Join Date: Apr 2003
Location: /home/carlesso
Posts: 4,129
|
in che linugaggio?
__________________
The Big: the e.gmail filler Xperience OK, so you're a Ph.D. Just don't touch anything. Il mio sito, e il mio blog
|
![]() |
![]() |
![]() |
#30 |
crà, crà
Join Date: Jan 2002
Posts: 13,828
|
In matematica
![]() Vorrei trovare un metodo esclusivamente matematico (aritmetico? ![]() La soluzione più intuitiva prevede divisioni per 10 e arrotondamenti con floor (), ma non volevo usare funzioni di libreria, volevo farmi la soluzione tutta da me ![]() Altrimenti riduciamo il problema a implementare in modo aritmetico floor.
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat. |
![]() |
![]() |
![]() |
Tags |
euler, matematica |
Thread Tools | |
Rate This Thread | |
|
|