A list of puns related to "Lexicographic order"
Stupid question, would I solve question #1 the same way as question #2? Are lexicographic order questions always in abc order, or does it depend on the set in question? Would the answer to these questions both always be 1=a, 2=b, 3=c, and then just sort them in abc order?
#1 - Which permutation of the set {1, 2, 3, 4, 5, 6} is first in lexicographic order?
#2 - Which permutation of the set {2, 4, 6, 9, 7, 8} is first in lexicographic order?
Any info about lexicographic order is helpful. Thanks!
Im using com.pinterest:ktlint:0.34.2 and getting Imports must be ordered in lexicographic order without any empty lines in-between error. How to sort my imports in a requested way automatically or turn this rule off? Why do imports need to be ordered in such way?
Hi!
Recently I got bored, so I found this video, from Daniel Shiffman, about this algorithm: https://www.youtube.com/watch?v=9Xy-LMAfglE&list=PLRqwX-V7Uu6ZncE7FtTEn53sK-BjR2aLf&index=3
I've tried to recreate it in C++, but... My version is way to quick and not accurate. And this this point I don't know even why...
Here's my code: https://pastebin.com/Hifk2dVy
I'm using effolkronium random lib from here: https://github.com/effolkronium/random
And the SFML to draw everything.
*lexicographic order topology
#include <string>
using std::string;
// . . .
string s = "to be";
string t = "not " + s; // t = โnot to beโ
string u = s + " or " + t; // u = โto be or not to beโ
if (s > t) // true: โto beโ > โnot to beโ
cout << u; // outputs โto be or not to beโ
I've been doing some research on comparing strings online, but I've been getting really confused. Some state that it is the length of the string, so in this case it would make sense, but my textbook says it's in lexicographic order, but wouldn't that mean "to be" is greater than "not"? Anyone know what I'm missing here? Thanks!
Hi all. I was reading this today and I couldn't really understand how this suggestion works.
>Another method would be to define a total order on finite sets: Let pS(n) be the n-th largest number in S. For example you could say that S<R if |S|<|R| or ( if |S|=|R| and there is an n such that for all i<n.pS(i)=pR(i) and pS(n)<pR(n) ). This is basically a lexicographic order. According to this order there is a smallest set (namely the empty set). Also for any two distinct sets you can say which set is larger. This means that for any set you can say that it is the i-th largest set (for some i) by this order. Now let f be the function which takes a set S and tells you the iโN such that S is the i-th largest set. Computing f(S) would give you some unique natural number which holds all the information of S (together with knowing the function f). For given x x/f(S) holds all information.
for example, if I have a set that contains the numbers [4,2,6,8,9] and an x = 15 what this "f" function would return as i for that particular set?
Sorry for my noobish question but I'm just a high school student and I'm trying to understand how this ordering is working.
Thanks in advance.
You are given as input a list of words from an unknown alphabet, sorted in lexicographic order. You may assume that the words are all lower case, and do not contain any non-letter characters. For example, using the Roman alphabet, an input might be:
["ad", "art", "bad", "bat", "cat"]
Write a function that accepts such a list as input, and outputs a string containing each character found in the dictionary, sorted in lexicographic order
Examples:
input: ["baa", "abcd", "abca", "cab", "cad"]
output: "bdac"
input: ["caa", "aaa", "aab"]
output: "cab"
For a standard roman alphabet, assuming a complete list of English words, the output should be:
'abcdefghijklmnopqrstuvwxyz'
However, we cannot assume that our input words use the standard roman alphabet order.
Source: Google interview and many others.
Edit: My example input and outputs were wrong, updated with new ones. See here for another write up.
The following expression is confusing to me: ghci> [3,2,1] > [2,10,100] True I don't understand why this is True. I expect evaluation in this order: 3 >2, 2 >10, 1>100 but clearly, this is not what is happening. What am I missing? Thanks for any thoughts.
Hey Guys,
can someone tell me why the deg.rev.lex. monomial ordering asks for the last variable to compare? I get the idea behind reversing < and > and make it into a global ordering using the degree, but why do we ask for the maximal index i such that the exponent difference is negative, i.e. why the "double reversing." The usual lexicographic ordering goes through the monomial from i=1 to n and checks which ones, first nonequal exponent is higher, i dont get why to change it, seems without advantage to me.
Greetings
Sorry if the wording is complicated, it's a complicated question.
Here is the ASCII table for reference and what I'm interested is the logic behind the 3rd column as everything else more or less makes sense to me...besides right here.
I was looking into the logic behind the ASCII standard's table ordering and found this wiki article which states-
>The "space" character had to come before graphics to make sorting easier, so it became position 20hex;[3]:237 ยง10 for the same reason, many special signs commonly used as separators were placed before digits.
And then asked some programmers for the reasoning and was given the reason-
>When sorting text lexicographically, you usually sort special symbols before numbers and letters. Placing symbols before numbers and letters means you can use normal number sorting to sort lexicographically
I'd never heard the term lexicographically but as a math guy I'm intrigued by the definition after googling it-
>In mathematics, the lexicographic or lexicographical order (also known as lexical order, dictionary order, alphabetical order or lexicographic(al) product) is a generalization of the alphabetical order of the dictionaries to sequences of ordered symbols or, more generally, of elements of a totally ordered set.
So what that means to me is there's some ordering of symbols based on the logic of "alphabetical ordering".
Now, I'm unsure if there's a logic behind our English alphabet ordering today but I figured if anyone knew it'd be this sub. Probably having some basis in Phoenician alphabet or some shit. And maybe it is just completely arbitrary but I'd like to know.
But I figure that, a standard for other symbols like the third row in ASCII might have more logic behind why they put it in a certain order other than "we gotta make a standard boyos". Maybe that ordering even predates the ASCII standard.
Anyway that's the whole question, hopefully I explained enough, if you'd like to explain the logic behind our modern day alphabet as well that would be cool as well but I'm mainly interested in that 3rd column.
Edit: [Found this post which has that question and good answers](https://www.reddit.com/r/AskHistorians/comments/4hkhdi/wh
... keep reading on reddit โกHi,
I am trying to index the Mediae Latinitatis Lexicon Minus (to use with the same program currently existing for the Gaffiot under the Debian operating system).
But this dictionary doesn't follow a strict lexicographical order. Some examples :
"laena" is put right next to "lena" so if you search for "laena" you won't find it.
"hy-" words are in the middle of the "hi-" words.
"proph-" words are in the middle of the "prof-" words.
"thX-" words are classified as "tX-" words.
This make indexation really annoying. Is there some systematic description of this classification ?
Hello guys. So the other day I wanted to do a Traveling Salesperson simulator. As a bit of a newbie to Processing I figured I'd watch some videos by the amazing YouTube-channel "The Coding Train" (https://www.youtube.com/user/shiffman). There just so happened to be a video on this exact topic. The host said something about lexicographic ordering. I searched for the Quora article that Dan used and tried to implement it. Anyway, here's the Quora article: https://www.quora.com/How-would-you-explain-an-algorithm-that-generates-permutations-using-lexicographic-ordering#
and my code:
//Lexicographical Ordering
int[] vals = {1, 5, 4, 2, 3, 0};
void setup() {
size(640, 360);
background(0);
frameRate(1);
}
void draw() {
//STEP 1
int largestI = -1;
for (int i = 0; i < vals.length - 1; i++) {
if (vals[i] < vals[i + 1]) {
largestI = i;
}
}
//IF largestI IS INVALID, THE ALGORITHM IS FINISHED.
if (largestI == -1) {
println("finished");
noLoop();
}
//STEP 2
int largestJ = 0;
for (int j = 0; j < vals.length; j++) {
if (vals[largestI] < vals[j]) {
largestJ = j;
}
}
//STEP 3
swap(vals, largestI, largestJ);
//STEP 4
int [] arrayToBeReversed = subset(vals, largestI+1, (vals.length - 1) - largestI+1);
arrayToBeReversed = reverse(arrayToBeReversed);
concat(vals, arrayToBeReversed);
//Debugging
println(largestI, "largestI");
println(largestJ, "largestJ");
//Displaying the order
background(0);
textSize(100);
for (int k = 0; k < vals.length; k++) {
text(vals[k], k * 60, height/2 + 20);
}
}
//SELF-MADE FUNCTIONS
void swap(int[] a, int i, int j) {
int temp = i;
a[i] = a[j];
a[j] = temp;
}
Thanks in advance! GreenScreenSocks
bit confused on lexicographical ordering.
"computer" < "computer" //Not true
"Computer" < "computer" //true
"computer" < "Computer" // Not true
"house" < "household" // Not Sure... true?
"household" < "house" //Not true?
how would the > work then? kinda confused...
In lexicographical ordering, "100" would occur before "2" because the items are treated as strings, not numbers. One solution is to pad the smaller numbers with zeros, e.g. "002".
By "alphabetical order", I mean the concept of giving all the symbols or radicals in a writing system a rank relative to one-another, such that words in that written language would then commonly be sorted by some mental algorithm that takes into account the ranks of the letters that make up each word.
Also: beyond the question of ordering the symbols themselves, did the concept of sorting words using their symbols โ and thus of needing a strict ordering for those symbols, to employ in sorting words โ exist before the advent of dictionaries, as just "a thing you can do with words", maybe for sorting/filing in ancient libraries/scriptoriums? Or did dictionaries impose standards of word-ordering (and thus strict standards of symbol ordering) onto previously-unordered lexicons, the way that printing imposed standards on orthography?
Also: are there written languages that have an "alphabetic order", and have a defined ordering for words using that "alphabetic order"; but where that ordering for words is defined using some algorithm other than the "lexicographic sort" algorithm (i.e. the "compare the first symbols of the words pairwise, then the next symbols, and so on" algorithm) we use for comparing words in English? (I'm imagining e.g. a Hebrew dictionary with the words in order of their gematria value.)
So I have to write a program that does lexicographical ordering following a set of requirements. I think I've gotten pretty far but now I seem to be stuck on the last 4 steps. I'm a beginner in assembly, (less than 1 month experience) and so I'm not sure how to even approach the last few steps. My program is on Gisthub. The requirements are here I also have the same program in python here if it helps at all. The only difference is that the input string is passed as a regular argument rather than a command line argument.
Pretty sure I've done steps 1-5 properly but 6-9 is where Im having trouble. Can't seem to figure anything out.
No matter where i look on the internet i can't get a straight answer on this. What comes where lexicographically? I don't need any symbols (%,$,!,etc.), just uppercase and lowercase letters, and numbers. I know uppercases come before lower, but basically I'm not sure where numbers go. Thanks for any help.
Hello,
I would like to create a simple script utilizing the simple network management protocol in order to retrieve information about printer toner levels of printers which are on a network. I found this SNMP library for Python -> https://pysnmp.readthedocs.io/en/latest/index.html but after reading through bits of it, I can't seem to understand how to even begin to implement the code.
I tried the quick start code example to retrieve the system description of a single printer by providing its ip address into UdpTransportTarget and it returned successfully.
What I am struggling with is how to retrieve the information which I need/want?
According to this -> https://secure.n-able.com/webhelp/NC_7-2-0_PA_en/Content/N-central/Services/Services_PrinterTonerLevel.html I should be able to retrieve information on:
Max capacity, current toner level and current toner level as a %
Would anyone be able to help?
from pysnmp.hlapi import *
iterator = getCmd(
SnmpEngine(),
CommunityData('public', mpModel=0),
UdpTransportTarget(('ip', 161)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))
)
errorIndication, errorStatus, errorIndex, varBinds = next(iterator)
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
Thank you!
_____________________________________________________________________
EDIT:
I figured out how to retrieve different types of system information, but still not how to retrieve toner levels. I found this website -> https://oidref.com/1.3.6.1.2.1.1 which shows OID numbers as well as their corresponding names, for example, OID 1.3.6.1.2.1.1.3 has the name of "sysUpTime". If I change :
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))
to:
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysUpTime', 0))
I receive the system up time of the machine.
I st
... keep reading on reddit โกI have written a calculator that converts infix expressions to postfix expressions (reverse polish notation). Could someone explain how I could find the lexicographically largest string representing a polish notation equation?
So I was asked the following problem :
Let G be the nine-vertex grid graph with vertices a, b, c, d, e, f, g, h, i and edges ab, bc, de, ef, gh, hi, ad, dg, be, eh, cf, and fi. Find a lexicographic breadth first search ordering for G, starting from vertex a.
The issue is that I don't understand how to obtain a lexicographic breadth first ordering.
According to the wiki (http://en.wikipedia.org/wiki/Lexicographic_breadth-first_search) the first steps are to "Initialize a sequence ฮฃ of sets, to contain a single set containing all vertices", but I'm not sure what this means :(
I'd appreciate any help at all. Thanks! :)
Considerable variety of marital custom is attested in pre-IslamicArabia, though we do not know the extent to which any one prevailed. Strict endogamy (people marry only their own stock) or exogamy(people marry only outside their own stock) does not seem to have existed (though at the town of Matira northeast of Sanโa permissionwas required to marry oneโs daughter to an outsider, Qutra 1). And itwould in any case have been limited by the practice of marriage bycapture:
>They did not give us Tayyites their daughters in marriage, but we wooed them against their will with our swords.And with us captivity brought no abasement to them,and they neither toiled in making bread nor boiled the pot.But we commingled them with our noblest women,and they bore us fine sons, of pure descent.How often will you see among us the son of a captive bride, who staunchly thrusts through heroes in the fray. (Hatim al-Taโi 66)
Most tribes would, however, at least have marked preferences. Somemight favour cross-cousin marriages, others felt that marriage withoutsiders produced hardier children and reduced the likelihood of family quarrels. Most disliked unions with people of very different manners. Thus a poet of Hudhayl is indignant at a proposal that heshould seek a bride among Himyarites, โwho do not circumcise their women and who do not think it disgusting to eat locustsโ, and Taโabbata Sharraโs kin are mocked for allowing their sister to wed intoa tribe accused of cannibalism (Hudhaliyyun57, 147, 164).
Newlyweds might join either the husbandโs or the wifeโs natalhouse. In the former case marriage challenges a womanโs connectionto her natural kin and in some sense captures her for her husbandโs(for which he pays a price, the dowry). He claims not merely wifely services but the woman as child-bearer and her progeny (whoever infact may sire them). The children belong to him and his people,primarily to him but residually to his lineage, who may in the eventof his demise perpetuate the groupโs interest by supplying anotherhusband:
>In pre-Islamic times, when a man died and left a widow, hisheir, if he came at once and threw his garment over her, hadthe right to marry her under the dowry of her deceased masteror to give her in marriage and take her dowry. But if sheanticipated him and went off to her own people, then theytook charge of her.(Tabari, Tafsรฎr ad 4.23)
The second option imposes exactly opposite demands. A manโs h
... keep reading on reddit โกPlease note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.