Find the width of the field

The computer has a byte addressable main memory of 2 16 bytes and block size of 8 bytes. Assume that a direct mapped cache consisting of 128 lines used with this computer. And separate into three parts, TAG, LINE, WORD. Find the width of TAG, LINE and WORD fields.

How can this Line-Breaking algorithm consider spaces as having width different than 1.0?

The Divide & Conquer Algorithm for Line-Breaking described here is given below, both in Python and in Dart (which is similar to Java/C#).

Line-breaking is also known as “line wrap”, “word wrap”, or “paragraph formation”, and this algorithm is used for achieving minimum raggedness.

This algorithm works, but it considers each space as having exactly width = 1.0 .

My Question:

How can I modify this algorithm so that it ignores spaces? In other words, make it consider spaces as having width 0.0? (or it would also work for me if I could define any width I wanted for the spaces, including 0.0).

Python Implementation:

def divide(text, width):     words = text.split()     count = len(words)     offsets = [0]     for w in words:         offsets.append(offsets[-1] + len(w))      minima = [0] + [10 ** 20] * count     breaks = [0] * (count + 1)      def cost(i, j):         w = offsets[j] - offsets[i] + j - i - 1         if w > width:             return 10 ** 10         return minima[i] + (width - w) ** 2      def search(i0, j0, i1, j1):         stack = [(i0, j0, i1, j1)]         while stack:             i0, j0, i1, j1 = stack.pop()             if j0 < j1:                 j = (j0 + j1) // 2                 for i in range(i0, i1):                     c = cost(i, j)                     if c <= minima[j]:                         minima[j] = c                         breaks[j] = i                 stack.append((breaks[j], j+1, i1, j1))                 stack.append((i0, j0, breaks[j]+1, j))      n = count + 1     i = 0     offset = 0     while True:         r = min(n, 2 ** (i + 1))         edge = 2 ** i + offset         search(0 + offset, edge, edge, r + offset)         x = minima[r - 1 + offset]         for j in range(2 ** i, r - 1):             y = cost(j + offset, r - 1 + offset)             if y <= x:                 n -= j                 i = 0                 offset += j                 break         else:             if r == n:                 break             i = i + 1      lines = []     j = count     while j > 0:         i = breaks[j]         lines.append(' '.join(words[i:j]))         j = i     lines.reverse()     return lines 

Dart implementation:

class MinimumRaggedness {    /// Given some [boxWidths], break it into the smallest possible number   /// of lines such as each line has width not larger than [maxWidth].   /// It also minimizes the difference between width of each line,   /// achieving a "balanced" result.   /// Spacing between boxes is 1.0.   static List<List<int>> divide(List<num> boxWidths, num maxWidth) {      int count = boxWidths.length;     List<num> offsets = [0];      for (num boxWidth in boxWidths) {       offsets.add(offsets.last + min(boxWidth, maxWidth));     }      List<num> minimum = [0]..addAll(List<num>.filled(count, 9223372036854775807));     List<int> breaks = List<int>.filled(count + 1, 0);      num cost(int i, int j) {       num width = offsets[j] - offsets[i] + j - i - 1;       if (width > maxWidth)         return 9223372036854775806;       else         return minimum[i] + pow(maxWidth - width, 2);     }      void search(int i0, int j0, int i1, int j1) {       Queue<List<int>> stack = Queue()..add([i0, j0, i1, j1]);        while (stack.isNotEmpty) {         List<int> info = stack.removeLast();         i0 = info[0];         j0 = info[1];         i1 = info[2];         j1 = info[3];          if (j0 < j1) {           int j = (j0 + j1) ~/ 2;            for (int i = i0; i < i1; i++) {             num c = cost(i, j);             if (c <= minimum[j]) {               minimum[j] = c;               breaks[j] = i;             }           }            stack.add([breaks[j], j + 1, i1, j1]);           stack.add([i0, j0, breaks[j] + 1, j]);         }       }     }      int n = count + 1;     int i = 0;     int offset = 0;      while (true) {       int r = min(n, pow(2, i + 1));       int edge = pow(2, i) + offset;       search(0 + offset, edge, edge, r + offset);       num x = minimum[r - 1 + offset];        bool flag = true;       for (int j = pow(2, i); j < r - 1; j++) {         num y = cost(j + offset, r - 1 + offset);         if (y <= x) {           n -= j;           i = 0;           offset += j;           flag = false;           break;         }       }        if (flag) {         if (r == n) break;         i = i + 1;       }     }      int j = count;      List<List<int>> indexes = [];      while (j > 0) {       int i = breaks[j];       indexes.add(List<int>.generate(j - i, (index) => index + i));       j = i;     }      return indexes.reversed.toList();   } } 

load local data on fixed width file inserting all columns with NULL values

Last month I had occasion to load about 50 GB of data from fixed-width dat files. There were 7 files so I created 7 tables. I created 7 LOAD DATA LOCAL INFILE scripts to load the data and it all worked fine resulting in over 70 million rows. The data is available with updates on the 10th of the month so I downloaded the files and ran my scripts on them and only 1 worked and the rest loaded the number of rows but with all of the columns NULL. I’ve compared the previous files with the new ones and cannot find any difference that would cause this. I’ve put a small amount of data that’s failing in a test.dat file and am getting the same results, but have not been able to determine why this is happening or why one works and the rest don’t? I don’t see any difference between the files or the sql that loads them? I’ve tried changing the encoding, line endings, permissions, ownership, and various other things without success. There are no errors thrown, it just loads NULL values. Has anyone ran across this before?

Here is an example table with the load sql

DROP TABLE IF EXISTS exp_gpoper; CREATE TABLE `exp_gpoper` (   `_id` int(11) NOT NULL AUTO_INCREMENT,   `date_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),   `pun_county_num` varchar(100) DEFAULT '',   `pun_lease_num` varchar(100) DEFAULT '',   `pun_sub_num` varchar(100) DEFAULT '',   `pun_merge_num` varchar(100) DEFAULT '',   `company_number` varchar(100) DEFAULT '',   `company_name` varchar(300) DEFAULT '',   PRIMARY KEY (`_id`),   KEY `date_updated` (`date_updated`),   KEY `pun_county_num` (`pun_county_num`),   KEY `pun_lease_num` (`pun_lease_num`),   KEY `pun_merge_num` (`pun_merge_num`),   KEY `pun_sub_num` (`pun_sub_num`),   KEY `company_number` (`company_number`),   KEY `company_name` (`company_name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;  LOAD DATA LOCAL INFILE 'test.dat'  INTO TABLE exp_gpoper  (@_row)  SET `pun_county_num` = TRIM(SUBSTR(@row,1,3)),  `pun_lease_num` = TRIM(SUBSTR(@row,4,6)),  `pun_sub_num` = TRIM(SUBSTR(@row,10,1)),  `pun_merge_num` = TRIM(SUBSTR(@row,11,4)),  `company_number` = TRIM(SUBSTR(@row,15,7)),  `company_name` = TRIM(SUBSTR(@row,22,255)); 

Here is the content of the test.dat file:

001000000000000077777OTC USE                                                                                                                                                                                                                                                         003000000000000077777OTC USE                                                                                                                                                                                                                                                         003000567000000020011M & D PUMPING SERVICE INC                                                                                                                                                                                                                                       003000587000000022576SCOGGINS PRODUCTION LLC                                                                                                                                                                                                                                         003000588000000022576SCOGGINS PRODUCTION LLC                                                                                                                                                                                                                                         003000639000000017441CHESAPEAKE OPERATING LLC                                                                                                                                                                                                                                        003000963000000019694BVD INC                                                                                                                                                                                                                                                         003000964000000018119BLAKE PRODUCTION CO INC                                                                                                                                                                                                                                         003002207124830022281SANDRIDGE EXPLORATION AND PRODUCTION LLC                                                                                                                                                                                                                        003002394000000020891SUPERIOR OIL & GAS LLC                                                                                                                                                                                                                                           

This works fine:

DROP TABLE IF EXISTS `exp_gpexempt`; CREATE TABLE `exp_gpexempt` (   `_id` int(11) NOT NULL AUTO_INCREMENT,   `date_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),   `pun_county_num` varchar(100) DEFAULT '',   `pun_lease_num` varchar(100) DEFAULT '',   `pun_sub_num` varchar(100) DEFAULT '',   `pun_merge_num` varchar(100) DEFAULT '',   `exemption_type` varchar(100) DEFAULT '',   `code` varchar(100) DEFAULT '',   `exemption_percentage` varchar(100) DEFAULT '',   PRIMARY KEY (`_id`),   KEY `date_updated` (`date_updated`),   KEY `pun_county_num` (`pun_county_num`),   KEY `pun_lease_num` (`pun_lease_num`),   KEY `pun_merge_num` (`pun_merge_num`),   KEY `exemption_type` (`exemption_type`),   KEY `code` (`code`),   KEY `exemption_percentage` (`exemption_percentage`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;  LOAD DATA LOCAL INFILE 'test2.dat'  INTO TABLE exp_gpexempt (@_row) SET `pun_county_num` = TRIM(SUBSTR(@_row,1,3)), `pun_lease_num` = TRIM(SUBSTR(@_row,4,6)), `pun_sub_num` = TRIM(SUBSTR(@_row,10,1)), `pun_merge_num` = TRIM(SUBSTR(@_row,11,4)), `exemption_type` = TRIM(SUBSTR(@_row,15,50)), `code` = TRIM(SUBSTR(@_row,65,5)), `exemption_percentage` = TRIM(SUBSTR(@_row,70,24)); 

Here is the content of the test2.dat file:

00300063900000School District                                   05   00000000000.000293000000 00300365500000State School Land Commission                      01   00000000000.125000000000 00301843300000State School Land Commission                      01   00000000000.125000000000 00302942700633State School Land Commission                      01   00000000000.125000000000 00302942800633State School Land Commission                      01   00000000000.125000000000 00303004100000Federal                                           02   00000000000.067632900000 00303004200000Federal                                           02   00000000000.125000000000 00303004600000Federal                                           02   00000000000.125000000000 00303004700000Federal                                           02   00000000000.125000000000 00303004800000Federal                                           02   00000000000.125000000000  

Find wide width sneakers & plus size shoes from Skechers!

You deserve to feel your best, inside and out. That’s where skechers outlet comes in. With styles for everyone in the family featuring the best comfort features around, you know you’ll never have to sacrifice the way you feel for the way you look.Looking for comfort? You’ve come to the right place. Looking for style? Still in the right place. That’s because Skechers shoes are known for combining the best of both worlds—so you never have to sacrifice the way you feel for the way you look. From sneakers and sandals to boots and booties, Skechers puts comfort front and center with styles for every season for everyone in the family. At Famous Footwear, you’ll find the Skechers memory foam styles you love, plus so many more of your soon-to-be favorites! So, get ready to step into something new.
Which skechers shoes for women are so you? Let us help you find your next favorite pair at Famous Footwear. For the trendsetters, check out our Skechers D’Lites sneakers. They comes in so many different colors, so you can rock whichever style that’s uniquely you. For easy-wear styles, slip-on shoes are always the right choice. Skechers Bobs is a fan favorite in the slip-on world. Add some more personality to your look with your favorite printed style! For when you want to be active without sacrificing style (AKA, always!), get going in the Skechers sneakers. Plus, find all the cutest styles for small toes, too. Kids’ Skechers shoes have as much personality as they do, featuring fun styles like light-ups, emojis, blinged-out and more.
Don’t forget to explore our selection of skechers shoes for men as well. Everyday sneakers and even trail-ready sneakers all live here at Famous Footwear. For the adventurers, gear up with the best men’s Skechers boots. Now you’re ready to explore. For your weekend activities, Skechers sneakers are the way to go. So easy, so comfortable, so you! The best part? Your favorites even feature Skechers memory foam for ultimate comfort. Talk about treating your feet.No matter your style, we have something you’ll love, with the comfort you love, from Skechers.
At the same time skechers store outlet has been surging, its peers have been struggling. The shift away from Technical running as fashion hurt nearly every brand that serves that category. No doubt some of Skechers success has come from the weakness in its peers.The athleisure trend has also contributed to the growth of Skechers. Millennials have brought a new focus on fitness and health to the marketplace.  People want to dress as if they are working out, even if they are not.  Skechers’ products are appropriate for both camps.  The products can perform AND they look cute.Nowhere is this Athleisure trend more evident than in training footwear, where Skechers is taking massive share from the market leaders. As Athleisure becomes more firmly entrenched in American culture, Skechers can thrive.

Images look bad with perfect paragraph width

I’m working on a WordPress template and trying to maintain perfect line width of ~70 characters. My blog has a lot of posts and most of the post contain at least one image per paragraph, usually more. So the site is quite media-heavy.

1. BAD

enter image description here

Screenshot above shows post content view with wrapper set to be 1140px wide, it’s extremely hard to read as there are up to 150 characters per line. Maybe at first everything looks a-okay but in reality it’s extremely tiring to read only after a few lines.

2. GOOD (?)

enter image description here

And here paragraphs are squashed to 700px what gives quite pleasant 50-80 characters per line.

In my opinion it looks quite alright but I’m not sure if it’s okay if the images are so much wider than text (they’re still at 1140px)? It looks fine at first but when I’m scrolling through 10 images per post my eyes are jumping from the middle of the page (text) to the left (images) and that’s becomes irritating quickly. Or maybe I’m overreacting and everything is in order?

3. MIXED (?)

enter image description here

Justifying the text might help here a little but nobody wants to read justified text. Also I feel like the images are way too small a 700px width, everything looks really compressed. I think it might be even worse than point 1, but I’m not sure.

My question is – how to tackle this issue? Is number 2 okay in your opinion? Maybe I should change something? Typography is really hard and any hints would be highly appreciated!

Igualar tamaño (width) en input y lista

Estoy intentando que un <input> y una lista tengan un mismo tamaño dentro de una página.

Para controlarlo, tengo ambos valores al 100%, pero al generar la lista de resultados, este es mas grande.

El <input> lo tengo dentro de un <div> por lo que cuando genero la lista, esta queda fuera y entiendo que por eso no me coge el tamaño correcto.

Estos son los valores que tengo en cada uno de los elementos:

.form-control {   width: 100%;  .dropdown-menu {   min-width: 100%; 

Hay forma de poder controlar los tamaños en este caso? Dejo subido el <input> para que se pueda ver el contenido CSS y una imagen con lo que sucede.

introducir la descripción de la imagen aquí