Alphametic

axpgn
$$
$$
[size=150][tt]T W E L V E +[/tt]

[tt]T W E L V E +[/tt]

[tt]T W E L V E +[/tt]

[tt]T W E L V E +[/tt]

[tt]T W E L V E +[/tt]

[tt]T H I R T Y =[/tt]

[tt]=============[/tt]

[tt]N I N E T Y[/tt][/size]





Cordialmente, Alex

Risposte
Super Squirrel
Grazie! :D

"Umby":
In ogni caso, tu ne hai trovate di più, e a tal proposito ti chiedo:
- Come hai considerato le soluzioni multiple? Io le ho scartate, presupponendo, di considerare valido solo i puzzle a soluzione unica.
(non vorrei che sia proprio questa la diff. tra la mia elaborazione e la tua !!)

No no, ho considerato solo i puzzle con un'unica soluzione.

"Umby":
Ti confesso, che non ho fatto il "solver" ma solo il "creator"
...
il mio programma è strutturato in due [SECTION].
La prima si occupa di generare le combinazioni dei numeri in base al numero di addendi impostato ad inizio programma,
la [SECTION1] passa la combinazione creata alla seconda [SECTION2] che ne verifica la
validità, passando una variabile, con il numero di soluzioni trovate

Da come la descrivi, la section2 mi sembrerebbe un solver, altrimenti come farebbe a restituire il numero di soluzioni? :?

Io invece per generare tutte le possibili combinazioni (con ripetizione), di somma $n$ e composte da $m$ addendi di valore minimo pari a $min$, ho implementato due funzioni:
- la funzione inizializza_array_somma() incaricata di trovare la combinazione iniziale;
- la funzione somma_successiva() incaricata di trovare la combinazione successiva dalla sola analisi della combinazione corrente.

Questo il codice completo:


Se riscontrate qualche bug fatemi sapere.

EDIT:
Corretto un bug nel codice.

Umby2
"Super Squirrel":

No no, ho considerato solo i puzzle con un'unica soluzione.



...allora ci sta qualche bughetto nel mio/tuo programma, :roll:
sarei orientato nel mio, visto che:
- tutte le soluzioni da me trovate appaiono nella tua elaborazione
- alcune delle tue, non appaiono nella mia

Pertanto, molto probabilmente, alcune soluzioni valide, sfuggono al mio codice:

ad esempio: la tua soluzione a 3 addendi: [82 = 12 + 32 + 38], sfugge dal mio
solver, e quindi viene skippata, pertanto ti chiedo:
Quale soluzione ti da il tuo solver per questa combinazione ?

----------------------------
"Super Squirrel":

Da come la descrivi, la section2 mi sembrerebbe un solver, altrimenti come farebbe a restituire il numero di soluzioni? :?



E' proprio come dici: quella SECTION2 non è altro che un solver, ma all'interno di un main, che si occupa di fare altro. Io come solver intendevo un programma che si occupa di accettare da tastiera la combinazione che ti interessa, e ti restituisce l'esito della stessa.

Super Squirrel
Ho trovato il problema... nella conversione delle stringhe in numeri utilizzavo il tipo unsigned int che non essendo abbastanza capiente andava in "overflow". Ho risolto utilizzando il tipo uint64_t. Aggiornato anche il codice postato in precedenza.

Ho cercato di nuovo le soluzioni con 3 addendi e ho trovato le seguenti:
13 = 3 + 5 + 5
16 = 5 + 5 + 6
91 = 23 + 30 + 38


Il numero è sceso, ma comunque sono più delle due che hai trovato tu.
Magari prova a dare in pasto al solver quella con il 91 e vediamo che succede.

Questo l'output che ottengo io:
SOLUZIONE 1:

a=6   e=4   i=0   n=2   o=7   r=9   t=1   u=5   v=8

.ventitre +
...trenta +
trentotto =
-----------
novantuno

.84210194 +
...194216 +
194217117 =
-----------
278621527


Process returned 0 (0x0)   execution time : 2.014 s
Press any key to continue.

Umby2
"Super Squirrel":
Ho trovato il problema...



Ehmm... "To ress nu ****tt" :-D

https://www.youtube.com/watch?v=gDaVy1KfQsU&t=134

p.s. il 91 esce anche a me...

Super Squirrel
"Umby":
Ehmm... "To ress nu ****tt"

https://www.youtube.com/watch?v=gDaVy1KfQsU&t=134

:-D

Poi a tempo perso metto il pc a ricalcolare le altre soluzioni e le posto!

Super Squirrel
Ecco le soluzioni che ho trovato (anche già formattate per essere eventualmente utilizzate nel programma riportato in precedenza):

    //2 ADDENDI:
    //3 ADDENDI:
    //vector<string> v = {w[13], w[3], w[5], w[5]};
    //vector<string> v = {w[16], w[5], w[5], w[6]};
    //vector<string> v = {w[91], w[23], w[30], w[38]};
    //4 ADDENDI:
    //vector<string> v = {w[7], w[0], w[1], w[3], w[3]};
    //vector<string> v = {w[11], w[0], w[1], w[5], w[5]};
    //vector<string> v = {w[16], w[1], w[5], w[5], w[5]};
    //vector<string> v = {w[16], w[2], w[2], w[5], w[7]};
    //vector<string> v = {w[21], w[2], w[2], w[5], w[12]};
    //vector<string> v = {w[21], w[2], w[5], w[5], w[9]};
    //vector<string> v = {w[21], w[3], w[4], w[7], w[7]};
    //vector<string> v = {w[30], w[0], w[10], w[10], w[10]};
    //vector<string> v = {w[30], w[2], w[7], w[10], w[11]};
    //vector<string> v = {w[30], w[3], w[3], w[12], w[12]};
    //vector<string> v = {w[30], w[3], w[6], w[10], w[11]};
    //vector<string> v = {w[30], w[6], w[6], w[8], w[10]};
    //vector<string> v = {w[40], w[1], w[4], w[7], w[28]};
    //vector<string> v = {w[40], w[5], w[10], w[10], w[15]};
    //5 ADDENDI (FINO A 30):
    //vector<string> v = {w[10], w[0], w[2], w[2], w[3], w[3]};
    //vector<string> v = {w[11], w[0], w[0], w[1], w[5], w[5]};
    //vector<string> v = {w[16], w[1], w[1], w[2], w[5], w[7]};
    //vector<string> v = {w[21], w[2], w[3], w[4], w[4], w[8]};
    //vector<string> v = {w[30], w[0], w[6], w[7], w[8], w[9]};
    //vector<string> v = {w[30], w[1], w[1], w[8], w[8], w[12]};
    //vector<string> v = {w[30], w[1], w[1], w[8], w[10], w[10]};
    //vector<string> v = {w[30], w[1], w[2], w[3], w[12], w[12]};
    //vector<string> v = {w[30], w[1], w[3], w[8], w[8], w[10]};
    //vector<string> v = {w[30], w[1], w[7], w[7], w[7], w[8]};
    //vector<string> v = {w[30], w[2], w[2], w[3], w[11], w[12]};
    //vector<string> v = {w[30], w[2], w[2], w[5], w[10], w[11]};
    //vector<string> v = {w[30], w[2], w[3], w[5], w[10], w[10]};
    //vector<string> v = {w[30], w[5], w[5], w[6], w[7], w[7]};
    //vector<string> v = {w[30], w[5], w[6], w[6], w[6], w[7]};
    //6 ADDENDI (FINO A 30):
    //vector<string> v = {w[7], w[0], w[0], w[0], w[1], w[3], w[3]};
    //vector<string> v = {w[11], w[0], w[0], w[0], w[1], w[5], w[5]};
    //vector<string> v = {w[12], w[0], w[0], w[0], w[2], w[3], w[7]};
    //vector<string> v = {w[16], w[1], w[1], w[1], w[1], w[5], w[7]};
    //vector<string> v = {w[30], w[0], w[0], w[0], w[8], w[10], w[12]};
    //vector<string> v = {w[30], w[0], w[0], w[3], w[3], w[12], w[12]};
    //vector<string> v = {w[30], w[0], w[0], w[6], w[7], w[8], w[9]};
    //vector<string> v = {w[30], w[0], w[2], w[7], w[7], w[7], w[7]};
    //vector<string> v = {w[30], w[0], w[3], w[3], w[7], w[8], w[9]};
    //vector<string> v = {w[30], w[1], w[1], w[2], w[2], w[12], w[12]};
    //vector<string> v = {w[30], w[1], w[1], w[2], w[3], w[11], w[12]};
    //vector<string> v = {w[30], w[1], w[1], w[3], w[3], w[10], w[12]};
    //vector<string> v = {w[30], w[1], w[1], w[3], w[3], w[11], w[11]};
    //vector<string> v = {w[30], w[1], w[1], w[6], w[7], w[7], w[8]};
    //vector<string> v = {w[30], w[1], w[1], w[7], w[7], w[7], w[7]};
    //vector<string> v = {w[30], w[1], w[2], w[2], w[3], w[11], w[11]};
    //vector<string> v = {w[30], w[1], w[2], w[2], w[7], w[9], w[9]};
    //vector<string> v = {w[30], w[1], w[2], w[3], w[3], w[10], w[11]};
    //vector<string> v = {w[30], w[1], w[3], w[5], w[5], w[8], w[8]};
    //vector<string> v = {w[30], w[2], w[2], w[2], w[2], w[10], w[12]};
    //vector<string> v = {w[30], w[2], w[2], w[2], w[3], w[10], w[11]};
    //vector<string> v = {w[30], w[2], w[2], w[2], w[7], w[7], w[10]};
    //vector<string> v = {w[30], w[2], w[2], w[3], w[3], w[8], w[12]};
    //vector<string> v = {w[30], w[2], w[2], w[3], w[6], w[6], w[11]};
    //vector<string> v = {w[30], w[2], w[2], w[3], w[6], w[7], w[10]};
    //vector<string> v = {w[30], w[2], w[3], w[5], w[5], w[5], w[10]};
    //vector<string> v = {w[30], w[3], w[3], w[3], w[5], w[8], w[8]};
    //vector<string> v = {w[30], w[3], w[5], w[5], w[5], w[6], w[6]};
    //7 ADDENDI (FINO A 20):
    //vector<string> v = {w[8], w[0], w[0], w[0], w[0], w[2], w[3], w[3]};
    //vector<string> v = {w[11], w[0], w[0], w[0], w[0], w[1], w[5], w[5]};
    //vector<string> v = {w[16], w[1], w[1], w[1], w[1], w[1], w[5], w[6]};
    //8 ADDENDI (FINO A 20):
    //vector<string> v = {w[11], w[0], w[0], w[1], w[1], w[1], w[1], w[2], w[5]};
    //vector<string> v = {w[12], w[0], w[0], w[0], w[0], w[0], w[2], w[5], w[5]};
    //9 ADDENDI (FINO A 20):
    //vector<string> v = {w[8], w[0], w[0], w[0], w[0], w[0], w[0], w[2], w[3], w[3]};
    //vector<string> v = {w[9], w[0], w[0], w[0], w[0], w[0], w[0], w[3], w[3], w[3]};
    //vector<string> v = {w[11], w[0], w[0], w[0], w[0], w[0], w[0], w[1], w[5], w[5]};
    //vector<string> v = {w[12], w[0], w[0], w[0], w[0], w[0], w[0], w[2], w[5], w[5]};
    //vector<string> v = {w[12], w[0], w[0], w[0], w[1], w[1], w[1], w[2], w[2], w[5]};
    //vector<string> v = {w[16], w[0], w[0], w[0], w[0], w[1], w[1], w[2], w[2], w[10]};
    //10 ADDENDI (FINO A 20):
    //vector<string> v = {w[9], w[0], w[0], w[0], w[0], w[0], w[0], w[0], w[3], w[3], w[3]};
    //vector<string> v = {w[11], w[0], w[0], w[0], w[0], w[0], w[0], w[2], w[2], w[2], w[5]};
    //vector<string> v = {w[11], w[0], w[0], w[0], w[0], w[0], w[1], w[1], w[2], w[2], w[5]};
    //vector<string> v = {w[12], w[0], w[0], w[0], w[0], w[0], w[0], w[0], w[2], w[5], w[5]};
    //vector<string> v = {w[12], w[0], w[0], w[0], w[0], w[0], w[0], w[1], w[1], w[5], w[5]};


Di "materiale" ce n'è abbastanza, credo proprio che la ricerca delle soluzioni per me finisce qui! :D

Rispondi
Per rispondere a questa discussione devi prima effettuare il login.