304 North Cardinal St.
Dorchester Center, MA 02124

# Lyra and the Alethiometer CodeChef Solution

## Lyra and the Alethiometer CodeChef Solution in C++14

``````#include<bits/stdc++.h>
using namespace std;

#define ll				long long
#define pb				push_back
#define vll				vector<ll>
#define pll				pair<ll, ll>
#define F				first
#define S				second

bool cmp(string s, string t){
if(s.length() != t.length()) return s.length() < t.length();
return s < t;
}
void sol(){
string s;
cin >> s;

string res="0";
for(ll i=0; i<s.length(); i++){
string temp="";
ll cnt=0;
for(ll j=i; j<s.length(); j++){
if(s[j] >= 'A' && s[j] <= 'Z') cnt++;
if(cnt < 2){
if(s[j] >= 'A' && s[j] <= 'Z') temp += '9';
else{
if(temp.empty() && s[j] == '0') continue;
temp += s[j];
}
res = max(res, temp, cmp);
}
else break;
}
}

cout << res;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);

ll tt=1;
// cin >> tt;
while(tt--){
sol();
}

return 0;
}``````

## Lyra and the Alethiometer CodeChef Solution in PYTH 3

``````# cook your dish here

s = input()
m = 0
for i in range(len(s)):
v = 0
c = str()
j = i
while j < len(s) and v < 2:
if s[j].isalpha():
if v == 0:
c += '9'
v += 1
else:
v += 1
else:
c += s[j]
j += 1
m = max(m, int(c))
print(m)``````

## Lyra and the Alethiometer CodeChef Solution in C

``````#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
char s[1003],m[1006],m1[1006];
int i,j,f[1003],p1,p2,count=0,t1,t2,l;
scanf("%s",s);
l=strlen(s);
memset(f,0,sizeof(f));
for(i=0;i<l;i++){
if(s[i]<'0'||s[i]>'9') f[i]=1,s[i]='9';

}
//	printf("%s\n",s);
i=p2=p1=0;
while(s[i]=='0'&&i<l) i++;
if(i==l) {
printf("0\n");
return 0;
}
j=0;
while(i<l){
p1=p2;

if(s[i]=='9'&&f[i]==1) count++,p2=i;
if(count>1) break;
m[j]=s[i];
i++;
j++;
}

m[i]='\0';
//	printf("%s\n",m);
//	printf("%d %d\n",p1,p2);

count=0;
if(i!=l){
for(j=p1+1;j<l;j=p1+1){
i=0;
//printf("--%d--",j);
p1=p2;
//printf("==%d--",p1);
while(s[j]=='0'&&j<l) j++;
while(j<l){

if(s[j]=='9'&&f[j]==1) count++,p2=j;
if(count>1) break;
m1[i]=s[j];
j++;
i++;
}
m1[i]='\0';
//	printf("%s\n",m1);
//printf("%d  %d\n",strlen(m1),strlen(m));
if(strlen(m1)>strlen(m)) strcpy(m,m1);
else if(strlen(m1)==strlen(m)){
t1=0;
while(t1<strlen(m1)){
if(m1[t1]>m[t1]) strcpy(m,m1);
else if(m1[t1]<m[t1])  break;
t1++;
}
}
count=0;

if(!(j<l)) break;
}

}
printf("%s",m);

return 0;
}``````

## Lyra and the Alethiometer CodeChef Solution in JAVA

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
int i,j,count=0,flag=0,am=0;
int l=str.length();
BigInteger b=new BigInteger("0");

for(i=0;i<l;i++)
{
count=0;
j=i+1;
StringBuffer sb=new StringBuffer("");
char ch=str.charAt(i);
if(ch>='A' && ch<='Z')
{
sb.append("9");
count=1;
}
else
{
sb.append(String.valueOf(ch));
}
while(j<l)
{
char ch2=str.charAt(j);
if(ch2>='A' && ch2<='Z')
{

if(count==0)
{
sb.append("9");
count=1;
}
else
break;

}
else
{

sb.append(String.valueOf(ch2));

}
j++;
}
BigInteger b2=new BigInteger(sb.toString());
b=b.max(b2);

}
System.out.println(b);

}
}``````

## Lyra and the Alethiometer CodeChef Solution in PYPY 3

``````import bisect

try:
s = input()
n = len(s)
path = []
for i in s:
path.append(i)

cal = ""
result = 0
j = -1
k = -1
count = 0
flag = False

for i in range(n):
if not path[i].isdigit() and count == 0:

path[i] = '9'
count = 1
k = i

elif not path[i].isdigit() and count == 1:
path[i] = '9'

result = max(result,int("".join(path[j+1:i])))
flag = True
j = k
k = i
if flag == False:
for i in range(n):
if not path[i].isdigit():
path[i] = '9'
print(int("".join(path)))
else:

print(max(result,int("".join(path[j+1:n]))))

except EOFError:
pass``````

## Lyra and the Alethiometer CodeChef Solution in PYTH

``````word = raw_input().strip()
length = len(word)
ans = 0
for i in range(length):
curSub = word[i]
if curSub not in '0123456789':
nowBreak = True
curSub = '9'
else:
nowBreak = False

curAns = int(curSub)

if curAns>ans:
ans = curAns

for j in range(i+1,length):
curLetter = word[j]
if curLetter not in '0123456789':
if nowBreak:
break
else:
nowBreak=True
curSub+='9'
curAns = int(curSub)
if curAns>ans:
ans = curAns
else:
curSub+=curLetter
curAns = int(curSub)
if curAns>ans:
ans = curAns

print ans``````

## Lyra and the Alethiometer CodeChef Solution in C#

``````using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace ConsoleApplication1
{

class Program
{

static void Main(string[] args)
{

String ret = "0";
for (int i = 0; i < s.Length; i++)
{
if (s[i] == '0') continue;
int lett = -1;
int j = i;
for (; j < s.Length; j++)
{
if (s[j] >= 'A' && s[j] <= 'Z')
{
if (lett>-1) break;
lett = j-i;
}
}
char [] now = s.Substring(i, j - i).ToCharArray();
if (lett > -1) now[lett] = '9';
String sNow = new String(now);
if (now.Length > ret.Length) ret = sNow;
else if (now.Length == ret.Length)
{
if (sNow.CompareTo(ret)>0) ret = sNow;
}
}
Console.WriteLine(ret);

}

}

}``````
##### Lyra and the Alethiometer CodeChef Solution Review:

In our experience, we suggest you solve this Lyra and the Alethiometer CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Lyra and the Alethiometer CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Lyra and the Alethiometer CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!