Add 3 zero after every n element in an array
Hi, I have an array that has 50 elements ( 0 and 1) . I would like to add 3 zero after every 5 elements . As below for the first 10 elements
10101010111111101001 should become 10101010110001111101001000
could you please help me on this one ? I would greatly appreciate if youd attach the code for it
thanks
Approach with for loop
"In theory, theory and practice are the same. In practice, they’re not."
Similar Messages
-
Hope someone can help me.
What I basically need help with is how to make Acrobat add a comma after every 6 characters in a text field:
XXXXXX,YYYYYY, ZZZZZZ etcI'm sorry, but I did not understand that (i'm using Acrobat Pro X)
Am I supposed to go to:
Text Field Properties > Format > Custom
and then use Custom Format Script or Custom Keystroke Script?
I tried both and it did not work.
And do the Text Field have to be named "chunkSize"?
Seems like it works. I had to move to the next formfield in order to see the effect.
Is it possible to make it happen in real time (as you type the comma is inserted?) -
DG4ODBC adds black spaces after every character
I am trying to set up HS using Oracle 10.2.0.5 on RHEL5 (64 bit), FreeTDS, and MS SQL Server.
The ODBC Driver works fine:
[oracle@phsbe1pr ~]$ isql sfasql_freetds_dsn sqlSinfoOne ***
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
SQL> select name, len( name ) from sys.objects where object_id < 20 ;
---------------------------------------------------------------------------------------------------------------------------------------------+
| name | |
---------------------------------------------------------------------------------------------------------------------------------------------+
| sysrscols | 9 |
| sysrowsets | 10 |
| sysallocunits | 13 |
| sysfiles1 | 9 |
| syspriorities | 13 |
| sysfgfrag | 9 |
---------------------------------------------------------------------------------------------------------------------------------------------+
SQLRowCount returns 6
6 rows fetched
SQL> quit
[oracle@phsbe1pr ~]$
[oracle@phsbe1pr ~]$ tsql -S SFASQL_FreeTDSName -U sqlSinfoOne -P ***
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> select name, len( name ) from sys.objects where object_id < 20
2> order by 1
3> go
name
sysallocunits 13
sysfgfrag 9
sysfiles1 9
syspriorities 13
sysrowsets 10
sysrscols 9
(6 rows affected)
1> exit
[oracle@phsbe1pr ~]$
But when I use the dblink i got every string doubled with spaces after every char:
[oracle@phsbe1pr ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Jul 23 17:22:25 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set linesize 120
SQL> column name format a40
SQL> select "name", length ( "name" )
2 from sys.objects@sfasql_link
3 where "object_id" < 20
4 order by 1
5 /
name LENGTH("NAME")
s y s a l l o c u n i t s 26
s y s f g f r a g 18
s y s f i l e s 1 18
s y s p r i o r i t i e s 26
s y s r o w s e t s 20
s y s r s c o l s 18
6 rows selected.
SQL>
What can I do ?
Mi init.ora is:
HS_FDS_CONNECT_INFO = SFASQL_DSN
HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so
HS_FDS_TRACE_LEVEL = off
HS_FDS_TRACE_FILE_NAME=/tmp/odbc_hs_sfa.trc
HS_FDS_SQLLEN_INTERPRETATION = 32
set ODBCINI=/etc/odbc.ini
adn odbc.ini contains:
[SFASQL_DSN]
Description = sqlserver
Driver = FreeTDS
# Servername = SFASQL_FreeTDSName
Server = phsspbe.perfumeholding.intra
Address = 172.17.0.45
Port = 1433
Database = SFA_INTERSCAMBIO
TDS_Version = 8.0
Language = us_english
TextSize = 1999
PacketSize = 1470
ClientCharset = ISO-8859-1
DumpFile = /tmp/odbc_sfasql_dsn.log
DumpFileAppend = Yes
DebugFlags =
Encryption = off
#Trace = Yes
#TraceFile = /tmp/odbc_sfasql_dsn.trc
Thank you for every answer!
Andrea1. Please add to the gateway init file HS_NLS_NCHAR=UCS2
Then test again with a new SQL*Plus session.
When it continues to fail, what's the character set of the Oracle database being used and how did you set the NLS_LANG in your environment? -
Every time I reboot, when I lauch Firefox, I get one tab for each "installed" extension, asking to "allow the install" of the extension.
Now that I'm thinking about it, the problem persists since firefox 5 or 6, but it is only now at 8 that it shows me a tab for each extension. Before the alerts were hidden in the extensions manager.
So, After I installed the extension, there is no reason to ask me again and again to "install it" or "allow it".
The "add-on compatibility reporter" I installed only a couple of days ago, so I can have Google toolbar back.
How can I get rid of this absurd problem?Do not double-click the file, but use "Open with" in the right-click context menu to open the file in a text editor like Notepad.
You can copy the file to another folder or let Windows create a copy with a number appended to the name in the same folder. -
Add a row after every n records
Hi
I have a query that returns only one column
Column1
a
b
c
d
g
e
f
g
h
I want to add 01 as the first row and then after 5 records i want to add 02 then 03 after another 5 records and so on i.e
Column1
01
a
b
c
d
e
02
f
g
h
How can this be done?Hi,
Nice post.
Regards salim.
other solution.
SELECT res
FROM t
model
dimension by( row_number()over(partition by 1 order by rownum) rn)
measures(col1,cast ( col1 as varchar2(20)) as res, count(1)over(partition by 1) cpt,trunc(rownum/5) diff)ignore nav
(diff[for rn from 1 to cpt[1]+trunc((cpt[1]+cpt[1]/5)/5) increment 1]=
case when diff[cv(rn)] is present then diff[cv(rn)]
else case when mod(cv(rn),5)=0 then
diff[cv(rn)-1]+1
else diff[cv(rn)-1]end
end,
res[for rn from 1 to cpt[1]+trunc((cpt[1]+cpt[1]/5)/5) increment 1]=
case when mod(cv(rn),5)=0 then
to_char((cv(rn)/5),'fm00')
else col1[cv(rn)-diff[cv(rn)]]end )
SQL> WITH t AS
2 (SELECT 'a' col1
3 FROM DUAL
4 UNION ALL
5 SELECT 'b'
6 FROM DUAL
7 UNION ALL
8 SELECT 'c'
9 FROM DUAL
10 UNION ALL
11 SELECT 'd'
12 FROM DUAL
13 UNION ALL
14 SELECT 'g'
15 FROM DUAL
16 UNION ALL
17 SELECT 'e'
18 FROM DUAL
19 UNION ALL
20 SELECT 'f'
21 FROM DUAL
22 UNION ALL
23 SELECT 'g'
24 FROM DUAL
25 UNION ALL
26 SELECT 'h'
27 FROM DUAL
28 UNION ALL
29 SELECT 'i'
30 FROM DUAL
31 UNION ALL
32 SELECT 'j'
33 FROM DUAL
34 UNION ALL
35 SELECT 'k'
36 FROM DUAL
37 UNION ALL
38 SELECT 'l'
39 FROM DUAL
40 UNION ALL
41 SELECT 'm'
42 FROM DUAL
43 UNION ALL
44 SELECT 'o'
45 FROM DUAL
46 UNION ALL
47 SELECT 'p'
48 FROM DUAL
49 UNION ALL
50 SELECT 'q'
51 FROM DUAL
52 UNION ALL
53 SELECT 'z'
54 FROM DUAL
55 UNION ALL
56 SELECT 'z'
57 FROM DUAL
58 UNION ALL
59 SELECT 'z'
60 FROM DUAL
61 UNION ALL
62 SELECT 'y'
63 FROM DUAL)
64 SELECT res
65 FROM t
66 model
67 dimension by( row_number()over(partition by 1 order by rownum) rn)
68 measures(col1,cast ( col1 as varchar2(20)) as res, count(1)over(partition by 1) cpt,trunc(rownu
m/5) diff)ignore nav
69 (diff[for rn from 1 to cpt[1]+trunc((cpt[1]+cpt[1]/5)/5) increment 1]=
70 case when diff[cv(rn)] is present then diff[cv(rn)]
71 else case when mod(cv(rn),5)=0 then
72 diff[cv(rn)-1]+1
73 else diff[cv(rn)-1]end
74 end,
75 res[for rn from 1 to cpt[1]+trunc((cpt[1]+cpt[1]/5)/5) increment 1]=
76 case when mod(cv(rn),5)=0 then
77 to_char((cv(rn)/5),'fm00')
78 else col1[cv(rn)-diff[cv(rn)]]end )
79
SQL> /
RES
a
b
c
d
01
g
e
f
g
02
h
i
j
k
03
l
m
o
p
04
q
z
z
z
05
y
26 ligne(s) sélectionnée(s).
SQL> Edited by: Salim Chelabi on 2009-04-15 13:35 -
Add period after every footnote number
I have a document with footnotes in the Word style, with the number superscripted. I want the footnote reference in the text to be superscripted, but not the corresponding number on the footnote. I'd like that to be the same size as the footnote text. I can change all these using find/change, but while I'm at it, I would like to add a period after every footnote number. Would someone be willing to suggest a way to do this? Thanks.
I'd suggest experimenting with the "Separator" category under Type > Document Footnote Options.
-
Stopping while loop after last element of 2d array is passed through
I posted something similar to this before, but what I got didn't work. So this time I'll try to be more clear with what I am trying to do. What I have done is combine two 1d arrays into a 2d array, and am using it to run an experiment. I split the 2d array into a 1d array by column, and am trying to get the while loop that the array is in to stop after the last element of the array is indexed. I need to use a while loop because the array is constantly updating because the number of elements can be changed while the program is running. What I am having trouble with is getting the while loop to stop after the last element has run, because the last element is subject to change. Any ideas?
ThanksI am trying to run a measurement using labview to control different instruments. The program is suppossed tp work in that it runs a measurement for each current setpoint inputed, for 1 magnetic field setpoint. So for example, if the magnetic field setpoint is 8000 gauss, and the two current setpoints are .00001 amp, and .0001 amp, it will run the meauserement twice for the 2 current setpoints for each magnetic field setpoint. What I am trying to do is that sometimes, I might have to edit the magnetic field setpoints while the program is running. I am having trouble with refreshing the magnetic field setpoints, which allows the user to input a new magnetic field setpoint while it is running.
-
How to add a button to every group's element in a presentation?
Hi all!
I am still a newbie with BPM. Just done the tutorial, a 2-day course and some experiments on my own. So, please, forgive my lack of knowledge.
I need to add a button to every element of a group in a presentation. You can think this group as a list of invoices and the button linked to another presentation where you will be able to edit attributes of the single invoice. Completed this procedure you could come back to the first presentation where the whole list will be visible. And so on, until the user clicks the end button to confirm changes and exit the screenflow.
I would like to use only simple presentation (not jsp). I have read about developers who create complex presentation, so I hope there are no limits about this issue.
Thank you all!
LucaThere's no easy way to achieve this. You'll have to provide a RootPaneUI delegate with a custom title pane implementation. There, you'll have to provide a custom layout to position your button. In addition, this approach will not work on look-and-feels that do not support decorated mode (such as Windows or GTK) since under such LAFs the title pane always comes from the OS.
-
''locking this thread as duplicate, please continue at [https://support.mozilla.org/en-US/questions/1038650 /questions/1038650]''
After every Firefox 34.0 reloading my add-ons have been switched off by unknown program or virus. Although i can switch them on and reboot firefox to fix it, but it is a little bit boring. How can i solve this problem?Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
You can try these free programs to scan for malware, which work with your existing antivirus software:
* [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
* [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
* [http://support.kaspersky.com/viruses/disinfection/5350 Anti-Rootkit Utility - TDSSKiller]
* [http://general-changelog-team.fr/en/downloads/viewdownload/20-outils-de-xplode/2-adwcleaner AdwCleaner] (for more info, see this [http://www.bleepingcomputer.com/download/adwcleaner/ alternate AdwCleaner download page])
* [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
* [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
[http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
Did this fix your problems? Please report back to us! -
After every Firefox 34.0 reloading my add-ons have been switched off by unknown program or virus. Although i can switch them on and reboot firefox one more time to fix it, but it is a little bit boring. How can i solve this problem?
Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
You can try these free programs to scan for malware, which work with your existing antivirus software:
* [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
* [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
* [http://support.kaspersky.com/viruses/disinfection/5350 Anti-Rootkit Utility - TDSSKiller]
* [http://general-changelog-team.fr/en/downloads/viewdownload/20-outils-de-xplode/2-adwcleaner AdwCleaner] (for more info, see this [http://www.bleepingcomputer.com/download/adwcleaner/ alternate AdwCleaner download page])
* [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
* [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
[http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
Did this fix your problems? Please report back to us! -
How do I add a transition between every clip in Premiere Elements 11?
Greetings -
Folks, I'm looking for a feature that even the cheesy old Windows Movie Maker used to have. I'm trying to figure out how to get Premiere Elements 11 to add a transition between every clip via some shortcut/quick means. I find it obnoxious and inefficient that I need to manually drag a transition between every clip. If I import 200 short clips that I took with my point and shoot camera, it'll take me over an hour alone just to put the transitions in place.
Is there any way to select a transition and have Premiere Elements add it between every clip? I've stumbled on the fact that you can click a transition and make it the "Default" but have not been able to figure out what that does for me.
Any help is appreciated.
Thank you.
AndyCDR0920 wrote:
........... but the time was set by defaul as 0 seconds and I have not been able to change that. Tips???
I think trying Edit > Preferences > General > Video Default Transition Duration will fix it. Mine came with 30 frames set at installation.
Bill S -
Can I remove photo shop 3 using windows add and remove after transfering photos to elements 10
can I remove photo shop 3 using windows add and remove after transfering photos to elements 10. Will I lose any of these photos in elements 10?
Yes you can remove it and your photos will not be removed. Un install it from add or remove or from the start menu.
-
After upgrading to Firefox 9.0.1, on first run after every reboot, the following warning appears for every installed Add-on.
"Another program on your computer would like to modify Firefox with the following add-on"
So, i have to "Enable" my installed Add-ons on each reboot.
Would you please help me !
P.S.: I found that these files (and some others) will be deleted on each reboot, and it happens on computer start up (not at shut down)!
extensions.ini
extensions.sqlite
extensions.sqlite-journal
And as i mentioned, i have the same anti virus on my laptop and desktop, but i have not any problem on laptop.Do you have security software that acts like a sandbox or uses virtualization to restore files on a next boot?
See also:
*http://kb.mozillazine.org/Preferences_not_saved
*https://support.mozilla.org/kb/Preferences+are+not+saved
It is possible that there is a problem with the file(s) that store the extensions registry.
Delete the files extensions.* (e.g. extensions.sqlite, extensions.ini, extensions.cache) and compatibility.ini in the Firefox profile folder to reset the extensions registry.
*https://support.mozilla.org/kb/Profiles
New files will be created when required.
See "Corrupt extension files":
*http://kb.mozillazine.org/Unable_to_install_themes_or_extensions
*https://support.mozilla.org/kb/Unable+to+install+add-ons
If you see disabled, not compatible, extensions in "Tools > Add-ons > Extensions" then click the Tools button at the left side of the Search Bar (or click the "Find Updates" button in older Firefox versions) to do a compatibility check or see if there is a compatibility update available. -
Inserting a calculated column after every column in cross tab, in crystal report 2011
HI,
I want to insert a calculated column after every column i a cross tab . The cross tab shows , sales by region for a number of years , for example from 2007 to 2013. The year can be changed based on the user parameter. How can I do that ?
ThanksHi Feroz,
To calculate the Percentage Change and also to show the Percentage sign, here's what you need to do:
1) Right-click the Calculated Column Header > Calculated Member > Edit ColumnValue Formula and use this code:
cdate(1890,01,01)
If the field used as the column is a datetime field, use this:
cdatetime(1890,01,01,0,0,0)
2) Right-click one of the zero values in the Percentage Column and select Calculated Member > Edit Calculation formula and use this code:
if CurrentColumnIndex = 2 then
If GridValueAt(CurrentRowIndex, CurrentColumnIndex-2, CurrentSummaryIndex) = 0 then
0
else
(GridValueAt(CurrentRowIndex, CurrentColumnIndex-1, CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, CurrentColumnIndex-2, CurrentSummaryIndex))/
GridValueAt(CurrentRowIndex, CurrentColumnIndex-2, CurrentSummaryIndex)
) * 100
else
If GridValueAt(CurrentRowIndex, CurrentColumnIndex-3, CurrentSummaryIndex) = 0 then
0
else
(GridValueAt(CurrentRowIndex, CurrentColumnIndex-1, CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, CurrentColumnIndex-3, CurrentSummaryIndex))/
GridValueAt(CurrentRowIndex, CurrentColumnIndex-3, CurrentSummaryIndex)
) * 100
3) Right-click one of the Values in the summary cells > Format Field > Number tab > Customize > Currency Symbol tab > Click the formula button beside 'Currency Symbol' and use this code:
If Year(GridRowColumnValue("Date_field")) = 1890 then
"%" else "$"
Note: Replace Date_field with the field name you've used as the Column in the Crosstab. The double-quotes ARE required and you should remove any curly braces that CR adds automatically.
4) You might want to use a similar code in the 'Position' formula too.
Let me know how this goes.
-Abhilash -
Can;t find what is wrong. Trying to add elements in two arrays
Hello everyone
I'm trying to take as input two numbers, convert them to arrays and add all the element of the array one by one. I want the result to be the sum of every element of the array. Let's say array1={1,2,3,4} and array2={2,6,4,3} I want the final result to be 3877.
If the sum of one element of the array is greater than nine, then I would put zero and add 1 to the element on the left.
Here is the code:
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
String numberOne = JOptionPane.showInputDialog
("Enter the first number: ");
String numberTwo = JOptionPane.showInputDialog
("Enter the second number: ");
//compare string length and make them equal length
int[]n1 = toArray(numberOne); // my first array
int[]n2 = toArray(numberTwo); // my second array
//call the method that ads both strings
int[]finalArray = arrSum(n1,n2);
JOptionPane.showMessageDialog(null, "The sum of the two numbers is: "
+ finalArray);
}//end of main
//method to create an array from a string
public static int[] toArray(String str)
int[]arr = new int[str.length()];
arr[0]=0;
for (int i=1; i<str.length(); i++)
arr= Character.digit(str.charAt(i),10);
return arr;
}//end of toArray
//method to add arrays by elements
public static int[]arrSum (int[]arr1, int[]arr2){
for (int i = arr1.length-1; i >=1; i--)
int sum = arr1[i] + arr2[i];
if (sum > 9)
{ sum -= 10;
arr1[i-1]++;
return arr1;
}//end of arrSum method
}Edited by: designbc01 on Feb 16, 2010 1:15 AMThe best advice I can give you is to break your problem up into smaller pieces. First, focus on a method that converts an input String into an array. When you have that working perfectly, then focus on creating a method that "adds" two arrays with the logic you described. When you have that working perfectly, then combine the two different pieces.
Why does your for loop in toArray( ) start with 1? The first index of a String, array, or pretty much anything else, is zero.
Maybe you are looking for
-
Hi there. I am having difficulty buying apps from the App Store. I recently changed my e-mail associated with my apple account. when i try to purchase an app, the cue to sign in does not show my new e-mail, but still shows my old e-mail. when I put i
-
Ipod classic 120GB sync problems
Whenever I try to sync my new iPod Classic 120GB with iTunes 8.1, it shows that it is transferring all the tracks, but when it is done, only a handful are transferred to the iPod. No error messages pop up, but when I sync it with an older version of
-
UPDATED iTunes and now cannot open it
I recently updated my iPhone to ios6 and then upgraded my iTunes on my laptop. Unfortunately, I now cannot open ITunes on my laptop. What gives?
-
Hi, I am creating an IDOC into ECC from PI. Could someone tell me how I can send the IDOC number that is generated in ECC back to the source system. Regards, Edited by: AbapLearner on Jun 19, 2011 6:28 PM
-
How to remotely fix my father's iMac
I am often called upon to fix my 83 year old father's iMac. I would love to be able to somehow remote into his computer and fix it that way vs having to drive all the way to his house. Is there a way of doing this? I don't quite understand the differ