Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Winter 2011/2012 GA1 Handlungsschritt 1b und 4 - Programmcode

Empfohlene Antworten

Falls ich die Angabe nicht falsch in Erinnerung habe und das Datum begrenzt ist, ist die Formel keine Abbildung, und damit nicht eindeutig zurückrechenbar.

Unsere Datumsrechnung hört ja nicht bei 2300 Jahren auf, sondern geht theoretisch weiter bis in diesem Fall 9999 da der Wertebereich durch das Format begrenzt ist

Folgender Code bestätigt das ( JavaScript, node.js oder Chrome ):


// Wertebereiche:

// a,b,c    : [65;90]

// d        : [0;51]

// e        : [0;9999]



function encryptHash(date, country)

{

    var a = country.charCodeAt(0);

	var b = country.charCodeAt(1);

	var c = country.charCodeAt(2);


	var d = parseInt(date.substr(0,2), 10);

	var e = parseInt(date.substr(2,4), 10);


	hash = (((a * 91 +  * 91 + c) * 51 + d) * 2300 + e;


    console.log('[Hash  ]'+hash);

    console.log('[Input ]'+ 'a: '+a+', ' + 

                            'b: '+b+', ' + 

                            'c: '+c+', ' + 

                            'd: '+d+', ' + 

                            'e: '+e);


    return hash;

}


function decryptHash(hash)

{

	var tmp = hash;


	var e = tmp % 2300;

	tmp = (tmp - e)/2300;


	var d = tmp % 51;

	tmp = (tmp - d)/51;


	var c = tmp % 91;

	tmp = (tmp - c)/91;


	var b = tmp % 91;

	tmp = (tmp - b)/91;


	var a = tmp;


    console.log('[Output]'+ 'a: '+a+', ' + 

                            'b: '+b+', ' + 

                            'c: '+c+', ' + 

                            'd: '+d+', ' + 

                            'e: '+e);


}


var hash;


console.log('Test 1');

hash = encryptHash('222011', 'GER');

decryptHash(hash);


// Output 1:

// Test 1

// [Hash  ]69712850211

// [Input ]a: 71, b: 69, c: 82, d: 22, e: 2011

// [Output]a: 71, b: 69, c: 82, d: 22, e: 2011


console.log('Test 2');

hash = encryptHash('519999', 'GER');

decryptHash(hash);


// Test 2

// [Hash  ]69712924899

// [Input ]a: 71, b: 69, c: 82, d: 51, e: 9999

// [Output]a: 71, b: 69, c: 83, d: 4, e: 799


[/code]

Alternativ: [JavaScript] BigWookie - Pastebin.com

Damit ist eine eindeutige Zuordnung nicht möglich und die Aufgabe unlösbar, allerdings habe ich den Aufgabentext nichtmehr eindeutig im Kopf.

  • 7 Monate später...

@BigWookie

Leider hast du Sie falsch im Kopf.

Die Angabe 2300 ist nur eine Konstante.

Das Jahr wird vorher schon addiert.

Demnach ist die Aufgabe sehr wohl lösbar.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.